mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-28 20:45:12 +00:00
Fixed format string warnings when compiling for 32 bit systems
This commit is contained in:
parent
34e2285f22
commit
07181e6a6a
26
src/client.c
26
src/client.c
@ -152,7 +152,7 @@ immediate_mode_defaults()
|
|||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
#define QTRACK_DEBUG(l, ...) \
|
#define QTRACK_DEBUG(l, ...) \
|
||||||
if (this.debug >= l) {\
|
if (this.debug >= l) {\
|
||||||
TIMEPRINT("[QTRACK (%lu/%lu), ? %lu, TO %lu, S %lu/%lu] ", this.num_pending, PENDING_QUERIES_LENGTH, \
|
TIMEPRINT("[QTRACK (%" L "u/%" L "u), ? %" L "u, TO %" L "u, S %" L "u/%" L "u] ", this.num_pending, PENDING_QUERIES_LENGTH, \
|
||||||
this.num_untracked, this.num_timeouts, window_sending(this.outbuf, NULL), this.outbuf->numitems); \
|
this.num_untracked, this.num_timeouts, window_sending(this.outbuf, NULL), this.outbuf->numitems); \
|
||||||
fprintf(stderr, __VA_ARGS__);\
|
fprintf(stderr, __VA_ARGS__);\
|
||||||
fprintf(stderr, "\n");\
|
fprintf(stderr, "\n");\
|
||||||
@ -333,7 +333,7 @@ send_query(uint8_t *hostname)
|
|||||||
struct query q;
|
struct query q;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
DEBUG(3, "TX: pkt len %lu: hostname '%s'", strlen((char *)hostname), hostname);
|
DEBUG(3, "TX: pkt len %" L "u: hostname '%s'", strlen((char *)hostname), hostname);
|
||||||
|
|
||||||
this.chunkid += 7727;
|
this.chunkid += 7727;
|
||||||
if (this.chunkid == 0)
|
if (this.chunkid == 0)
|
||||||
@ -529,7 +529,7 @@ send_next_frag()
|
|||||||
if (datacmc >= 36)
|
if (datacmc >= 36)
|
||||||
datacmc = 0;
|
datacmc = 0;
|
||||||
|
|
||||||
DEBUG(3, " SEND DATA: seq %d, ack %d, len %lu, s%d e%d c%d flags %1X",
|
DEBUG(3, " SEND DATA: seq %d, ack %d, len %" L "u, s%d e%d c%d flags %1X",
|
||||||
f->seqID, f->ack_other, f->len, f->start, f->end, f->compressed, hdr[2] >> 4);
|
f->seqID, f->ack_other, f->len, f->start, f->end, f->compressed, hdr[2] >> 4);
|
||||||
|
|
||||||
id = send_query(buf);
|
id = send_query(buf);
|
||||||
@ -910,7 +910,7 @@ parse_data(uint8_t *data, size_t len, fragment *f, int *immediate)
|
|||||||
up_wsize = data[4];
|
up_wsize = data[4];
|
||||||
dn_start_seq = data[5];
|
dn_start_seq = data[5];
|
||||||
up_start_seq = data[6];
|
up_start_seq = data[6];
|
||||||
DEBUG(3, "PING pkt data=%lu WS: up=%u, dn=%u; Start: up=%u, dn=%u",
|
DEBUG(3, "PING pkt data=%" L "u WS: up=%u, dn=%u; Start: up=%u, dn=%u",
|
||||||
len - headerlen, up_wsize, dn_wsize, up_start_seq, dn_start_seq);
|
len - headerlen, up_wsize, dn_wsize, up_start_seq, dn_start_seq);
|
||||||
}
|
}
|
||||||
f->len = len - headerlen;
|
f->len = len - headerlen;
|
||||||
@ -931,7 +931,7 @@ tunnel_tun()
|
|||||||
if ((read = read_tun(this.tun_fd, in, sizeof(in))) <= 0)
|
if ((read = read_tun(this.tun_fd, in, sizeof(in))) <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
DEBUG(2, " IN: %lu bytes on tunnel, to be compressed: %d", read, this.compression_up);
|
DEBUG(2, " IN: %" L "u bytes on tunnel, to be compressed: %d", read, this.compression_up);
|
||||||
|
|
||||||
if (this.conn != CONN_DNS_NULL || this.compression_up) {
|
if (this.conn != CONN_DNS_NULL || this.compression_up) {
|
||||||
datalen = sizeof(out);
|
datalen = sizeof(out);
|
||||||
@ -945,7 +945,7 @@ tunnel_tun()
|
|||||||
if (this.conn == CONN_DNS_NULL) {
|
if (this.conn == CONN_DNS_NULL) {
|
||||||
/* Check if outgoing buffer can hold data */
|
/* Check if outgoing buffer can hold data */
|
||||||
if (window_buffer_available(this.outbuf) < (read / MAX_FRAGSIZE) + 1) {
|
if (window_buffer_available(this.outbuf) < (read / MAX_FRAGSIZE) + 1) {
|
||||||
DEBUG(1, " Outgoing buffer full (%lu/%lu), not adding data!",
|
DEBUG(1, " Outgoing buffer full (%" L "u/%" L "u), not adding data!",
|
||||||
this.outbuf->numitems, this.outbuf->length);
|
this.outbuf->numitems, this.outbuf->length);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1002,14 +1002,14 @@ tunnel_dns()
|
|||||||
if (this.lazymode) {
|
if (this.lazymode) {
|
||||||
|
|
||||||
if (this.send_query_recvcnt < 500 && this.num_servfail < 4) {
|
if (this.send_query_recvcnt < 500 && this.num_servfail < 4) {
|
||||||
fprintf(stderr, "Hmm, that's %ld SERVFAILs. Your data should still go through...\n", this.num_servfail);
|
fprintf(stderr, "Hmm, that's %" L "d SERVFAILs. Your data should still go through...\n", this.num_servfail);
|
||||||
|
|
||||||
} else if (this.send_query_recvcnt < 500 && this.num_servfail >= 10 &&
|
} else if (this.send_query_recvcnt < 500 && this.num_servfail >= 10 &&
|
||||||
this.autodetect_server_timeout && this.max_timeout_ms >= 500 && this.num_servfail % 5 == 0) {
|
this.autodetect_server_timeout && this.max_timeout_ms >= 500 && this.num_servfail % 5 == 0) {
|
||||||
|
|
||||||
this.max_timeout_ms -= 200;
|
this.max_timeout_ms -= 200;
|
||||||
double target_timeout = (float) this.max_timeout_ms / 1000.0;
|
double target_timeout = (float) this.max_timeout_ms / 1000.0;
|
||||||
fprintf(stderr, "Too many SERVFAILs (%ld), reducing timeout to"
|
fprintf(stderr, "Too many SERVFAILs (%" L "d), reducing timeout to"
|
||||||
" %.1f secs. (use -I%.1f next time on this network)\n",
|
" %.1f secs. (use -I%.1f next time on this network)\n",
|
||||||
this.num_servfail, target_timeout, target_timeout);
|
this.num_servfail, target_timeout, target_timeout);
|
||||||
|
|
||||||
@ -1041,7 +1041,7 @@ tunnel_dns()
|
|||||||
if (read == 5 && !strncmp("BADIP", (char *)cbuf, 5)) {
|
if (read == 5 && !strncmp("BADIP", (char *)cbuf, 5)) {
|
||||||
this.num_badip++;
|
this.num_badip++;
|
||||||
if (this.num_badip % 5 == 1) {
|
if (this.num_badip % 5 == 1) {
|
||||||
fprintf(stderr, "BADIP (%ld): Server rejected sender IP address (maybe iodined -c will help), or server "
|
fprintf(stderr, "BADIP (%" L "d): Server rejected sender IP address (maybe iodined -c will help), or server "
|
||||||
"kicked us due to timeout. Will exit if no downstream data is received in 60 seconds.\n", this.num_badip);
|
"kicked us due to timeout. Will exit if no downstream data is received in 60 seconds.\n", this.num_badip);
|
||||||
}
|
}
|
||||||
return -1; /* nothing done */
|
return -1; /* nothing done */
|
||||||
@ -1059,7 +1059,7 @@ tunnel_dns()
|
|||||||
got_response(q.id, immediate, 0);
|
got_response(q.id, immediate, 0);
|
||||||
|
|
||||||
if ((this.debug >= 3 && res) || (this.debug >= 2 && !res))
|
if ((this.debug >= 3 && res) || (this.debug >= 2 && !res))
|
||||||
fprintf(stderr, " RX %s; frag ID %3u, ACK %3d, compression %d, datalen %lu, s%d e%d\n",
|
fprintf(stderr, " RX %s; frag ID %3u, ACK %3d, compression %d, datalen %" L "u, s%d e%d\n",
|
||||||
res ? "PING" : "DATA", f.seqID, f.ack_other, f.compressed, f.len, f.start, f.end);
|
res ? "PING" : "DATA", f.seqID, f.ack_other, f.compressed, f.len, f.start, f.end);
|
||||||
|
|
||||||
|
|
||||||
@ -1100,7 +1100,7 @@ tunnel_dns()
|
|||||||
if (compressed) {
|
if (compressed) {
|
||||||
buflen = sizeof(buf);
|
buflen = sizeof(buf);
|
||||||
if ((res = uncompress(buf, &buflen, cbuf, datalen)) != Z_OK) {
|
if ((res = uncompress(buf, &buflen, cbuf, datalen)) != Z_OK) {
|
||||||
DEBUG(1, "Uncompress failed (%d) for data len %lu: reassembled data corrupted or incomplete!", res, datalen);
|
DEBUG(1, "Uncompress failed (%d) for data len %" L "u: reassembled data corrupted or incomplete!", res, datalen);
|
||||||
datalen = 0;
|
datalen = 0;
|
||||||
} else {
|
} else {
|
||||||
datalen = buflen;
|
datalen = buflen;
|
||||||
@ -1189,7 +1189,7 @@ client_tunnel()
|
|||||||
|
|
||||||
sending--;
|
sending--;
|
||||||
total--;
|
total--;
|
||||||
QTRACK_DEBUG(3, "Sent a query to fill server lazy buffer to %lu, will send another %d",
|
QTRACK_DEBUG(3, "Sent a query to fill server lazy buffer to %" L "u, will send another %d",
|
||||||
this.lazymode ? this.windowsize_down : 1, total);
|
this.lazymode ? this.windowsize_down : 1, total);
|
||||||
|
|
||||||
if (sending > 0 || (total > 0 && this.lazymode)) {
|
if (sending > 0 || (total > 0 && this.lazymode)) {
|
||||||
@ -2409,7 +2409,7 @@ handshake_set_timeout()
|
|||||||
char in[4096];
|
char in[4096];
|
||||||
int read, id;
|
int read, id;
|
||||||
|
|
||||||
fprintf(stderr, "Setting window sizes to %lu frags upstream, %lu frags downstream...\n",
|
fprintf(stderr, "Setting window sizes to %" L "u frags upstream, %" L "u frags downstream...\n",
|
||||||
this.windowsize_up, this.windowsize_down);
|
this.windowsize_up, this.windowsize_down);
|
||||||
|
|
||||||
fprintf(stderr, "Calculating round-trip time...");
|
fprintf(stderr, "Calculating round-trip time...");
|
||||||
|
26
src/common.h
26
src/common.h
@ -45,6 +45,32 @@ extern const unsigned char raw_header[RAW_HDR_LEN];
|
|||||||
|
|
||||||
#define DNS_PORT 53
|
#define DNS_PORT 53
|
||||||
|
|
||||||
|
#if _WIN32 || _WIN64
|
||||||
|
#if _WIN64
|
||||||
|
#define BITS_64
|
||||||
|
#else
|
||||||
|
#define BITS_32
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC__
|
||||||
|
#if __x86_64__ || __ppc64__
|
||||||
|
#define BITS_64 1
|
||||||
|
#else
|
||||||
|
#define BITS_32 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Determine appropriate format specifier for long int on 32/64 bit systems */
|
||||||
|
#if BITS_64
|
||||||
|
#define FMT_LONG "l"
|
||||||
|
#else
|
||||||
|
#define FMT_LONG ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* For convenience and shortness */
|
||||||
|
#define L FMT_LONG
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
#endif
|
#endif
|
||||||
|
30
src/server.c
30
src/server.c
@ -103,7 +103,7 @@ send_raw(int fd, uint8_t *buf, size_t buflen, int user, int cmd, struct sockaddr
|
|||||||
|
|
||||||
#define QMEM_DEBUG(l, u, ...) \
|
#define QMEM_DEBUG(l, u, ...) \
|
||||||
if (server.debug >= l) {\
|
if (server.debug >= l) {\
|
||||||
TIMEPRINT("[QMEM u%d (%lu/%u)] ", u, users[u].qmem.num_pending, users[u].outgoing->windowsize); \
|
TIMEPRINT("[QMEM u%d (%" L "u/%u)] ", u, users[u].qmem.num_pending, users[u].outgoing->windowsize); \
|
||||||
fprintf(stderr, __VA_ARGS__);\
|
fprintf(stderr, __VA_ARGS__);\
|
||||||
fprintf(stderr, "\n");\
|
fprintf(stderr, "\n");\
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ qmem_append(int userid, struct query *q)
|
|||||||
buf->start = (buf->start + 1) % QMEM_LEN;
|
buf->start = (buf->start + 1) % QMEM_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMEM_DEBUG(5, userid, "add query ID %d, timeout %lu ms", q->id, timeval_to_ms(&users[userid].dns_timeout));
|
QMEM_DEBUG(5, userid, "add query ID %d, timeout %" L "u ms", q->id, timeval_to_ms(&users[userid].dns_timeout));
|
||||||
|
|
||||||
/* Copy query into buffer */
|
/* Copy query into buffer */
|
||||||
memcpy(&buf->queries[buf->end].q, q, sizeof(struct query));
|
memcpy(&buf->queries[buf->end].q, q, sizeof(struct query));
|
||||||
@ -314,7 +314,7 @@ qmem_max_wait(int *touser, struct query **sendq)
|
|||||||
q->id, age_ms, immediate ? "immediate" : "lazy", timeval_to_ms(&u->dns_timeout));
|
q->id, age_ms, immediate ? "immediate" : "lazy", timeval_to_ms(&u->dns_timeout));
|
||||||
|
|
||||||
sent++;
|
sent++;
|
||||||
QMEM_DEBUG(4, userid, "ANSWER q id %d, ACK %d; sent %lu of %lu + sending another %lu",
|
QMEM_DEBUG(4, userid, "ANSWER q id %d, ACK %d; sent %" L "u of %" L "u + sending another %" L "u",
|
||||||
q->id, u->next_upstream_ack, sent, total, sending);
|
q->id, u->next_upstream_ack, sent, total, sending);
|
||||||
|
|
||||||
send_data_or_ping(userid, q, 0, immediate);
|
send_data_or_ping(userid, q, 0, immediate);
|
||||||
@ -339,7 +339,7 @@ qmem_max_wait(int *touser, struct query **sendq)
|
|||||||
if (server.debug >= 5) {
|
if (server.debug >= 5) {
|
||||||
time_t soonest_ms = timeval_to_ms(&soonest);
|
time_t soonest_ms = timeval_to_ms(&soonest);
|
||||||
if (nextq && nextuser >= 0) {
|
if (nextq && nextuser >= 0) {
|
||||||
QMEM_DEBUG(5, nextuser, "can wait for %lu ms, will send id %d", soonest_ms, nextq->id);
|
QMEM_DEBUG(5, nextuser, "can wait for %" L "u ms, will send id %d", soonest_ms, nextq->id);
|
||||||
} else {
|
} else {
|
||||||
if (nextuser < 0)
|
if (nextuser < 0)
|
||||||
nextuser = 0;
|
nextuser = 0;
|
||||||
@ -347,7 +347,7 @@ qmem_max_wait(int *touser, struct query **sendq)
|
|||||||
/* only if resending some frags */
|
/* only if resending some frags */
|
||||||
QMEM_DEBUG(5, nextuser, "Resending some fragments")
|
QMEM_DEBUG(5, nextuser, "Resending some fragments")
|
||||||
} else {
|
} else {
|
||||||
QMEM_DEBUG(2, nextuser, "Don't need to send anything to any users, waiting %lu ms", soonest_ms);
|
QMEM_DEBUG(2, nextuser, "Don't need to send anything to any users, waiting %" L "u ms", soonest_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ send_data_or_ping(int userid, struct query *q, int ping, int immediate)
|
|||||||
if (datalen + headerlen > sizeof(pkt)) {
|
if (datalen + headerlen > sizeof(pkt)) {
|
||||||
/* Should never happen, or at least user should be warned about
|
/* Should never happen, or at least user should be warned about
|
||||||
* fragsize > MAX_FRAGLEN earlier on */
|
* fragsize > MAX_FRAGLEN earlier on */
|
||||||
warnx("send_frag_or_dataless: fragment too large to send! (%lu)", datalen);
|
warnx("send_frag_or_dataless: fragment too large to send! (%" L "u)", datalen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (f)
|
if (f)
|
||||||
@ -535,7 +535,7 @@ user_send_data(int userid, uint8_t *indata, size_t len, int compressed)
|
|||||||
datalen = sizeof(out);
|
datalen = sizeof(out);
|
||||||
ret = uncompress(out, &datalen, indata, len);
|
ret = uncompress(out, &datalen, indata, len);
|
||||||
if (ret != Z_OK) {
|
if (ret != Z_OK) {
|
||||||
DEBUG(1, "FAIL: Uncompress == %d: %lu bytes to user %d!", ret, len, userid);
|
DEBUG(1, "FAIL: Uncompress == %d: %" L "u bytes to user %d!", ret, len, userid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -800,7 +800,7 @@ handle_full_packet(int userid, uint8_t *data, size_t len, int compressed)
|
|||||||
if (ret == Z_OK) {
|
if (ret == Z_OK) {
|
||||||
hdr = (struct ip*) (out + 4);
|
hdr = (struct ip*) (out + 4);
|
||||||
touser = find_user_by_ip(hdr->ip_dst.s_addr);
|
touser = find_user_by_ip(hdr->ip_dst.s_addr);
|
||||||
DEBUG(2, "FULL PKT: %lu bytes from user %d (touser %d)", len, userid, touser);
|
DEBUG(2, "FULL PKT: %" L "u bytes from user %d (touser %d)", len, userid, touser);
|
||||||
if (touser == -1) {
|
if (touser == -1) {
|
||||||
/* send the uncompressed packet to tun device */
|
/* send the uncompressed packet to tun device */
|
||||||
write_tun(server.tun_fd, rawdata, rawlen);
|
write_tun(server.tun_fd, rawdata, rawlen);
|
||||||
@ -823,7 +823,7 @@ handle_raw_login(uint8_t *packet, size_t len, struct query *q, int fd, int useri
|
|||||||
char myhash[16];
|
char myhash[16];
|
||||||
|
|
||||||
if (len < 16) {
|
if (len < 16) {
|
||||||
DEBUG(2, "Invalid raw login packet: length %lu < 16 bytes!", len);
|
DEBUG(2, "Invalid raw login packet: length %" L "u < 16 bytes!", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,7 +833,7 @@ handle_raw_login(uint8_t *packet, size_t len, struct query *q, int fd, int useri
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(1, "RX-raw: login, len %lu, from user %d", len, userid);
|
DEBUG(1, "RX-raw: login, len %" L "u, from user %d", len, userid);
|
||||||
|
|
||||||
/* User sends hash of seed + 1 */
|
/* User sends hash of seed + 1 */
|
||||||
login_calculate(myhash, 16, server.password, users[userid].seed + 1);
|
login_calculate(myhash, 16, server.password, users[userid].seed + 1);
|
||||||
@ -867,7 +867,7 @@ handle_raw_data(uint8_t *packet, size_t len, struct query *q, int userid)
|
|||||||
|
|
||||||
/* copy to packet buffer, update length */
|
/* copy to packet buffer, update length */
|
||||||
|
|
||||||
DEBUG(3, "RX-raw: full pkt raw, length %lu, from user %d", len, userid);
|
DEBUG(3, "RX-raw: full pkt raw, length %" L "u, from user %d", len, userid);
|
||||||
|
|
||||||
handle_full_packet(userid, packet, len, 1);
|
handle_full_packet(userid, packet, len, 1);
|
||||||
}
|
}
|
||||||
@ -904,7 +904,7 @@ raw_decode(uint8_t *packet, size_t len, struct query *q, int dns_fd)
|
|||||||
raw_cmd = RAW_HDR_GET_CMD(packet);
|
raw_cmd = RAW_HDR_GET_CMD(packet);
|
||||||
raw_user = RAW_HDR_GET_USR(packet);
|
raw_user = RAW_HDR_GET_USR(packet);
|
||||||
|
|
||||||
DEBUG(3, "RX-raw: client %s, user %d, raw command 0x%02X, length %lu",
|
DEBUG(3, "RX-raw: client %s, user %d, raw command 0x%02X, length %" L "u",
|
||||||
format_addr(&q->from, q->fromlen), raw_user, raw_cmd, len);
|
format_addr(&q->from, q->fromlen), raw_user, raw_cmd, len);
|
||||||
|
|
||||||
packet += RAW_HDR_LEN;
|
packet += RAW_HDR_LEN;
|
||||||
@ -1122,7 +1122,7 @@ write_dns(int fd, struct query *q, char *data, size_t datalen, char downenc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(3, "TX: client %s ID %5d, %lu bytes data, type %d, name '%10s'",
|
DEBUG(3, "TX: client %s ID %5d, %" L "u bytes data, type %d, name '%10s'",
|
||||||
format_addr(&q->from, q->fromlen), q->id, datalen, q->type, q->name);
|
format_addr(&q->from, q->fromlen), q->id, datalen, q->type, q->name);
|
||||||
|
|
||||||
sendto(fd, buf, len, 0, (struct sockaddr*)&q->from, q->fromlen);
|
sendto(fd, buf, len, 0, (struct sockaddr*)&q->from, q->fromlen);
|
||||||
@ -1149,7 +1149,7 @@ handle_null_request(int dns_fd, struct query *q, int domain_len)
|
|||||||
|
|
||||||
memcpy(in, q->name, MIN(domain_len, sizeof(in)));
|
memcpy(in, q->name, MIN(domain_len, sizeof(in)));
|
||||||
|
|
||||||
DEBUG(3, "NULL request length %d/%lu, command '%c'", domain_len, sizeof(in), in[0]);
|
DEBUG(3, "NULL request length %d/%" L "u, command '%c'", domain_len, sizeof(in), in[0]);
|
||||||
|
|
||||||
if(in[0] == 'V' || in[0] == 'v') { /* Version request */
|
if(in[0] == 'V' || in[0] == 'v') { /* Version request */
|
||||||
uint32_t version = !PROTOCOL_VERSION;
|
uint32_t version = !PROTOCOL_VERSION;
|
||||||
@ -1544,7 +1544,7 @@ handle_null_request(int dns_fd, struct query *q, int domain_len)
|
|||||||
|
|
||||||
read = unpack_data(unpacked, sizeof(unpacked), in + 1, domain_len - 1, b32);
|
read = unpack_data(unpacked, sizeof(unpacked), in + 1, domain_len - 1, b32);
|
||||||
if (read < UPSTREAM_PING) {
|
if (read < UPSTREAM_PING) {
|
||||||
DEBUG(1, "Invalid ping! Length %lu", read);
|
DEBUG(1, "Invalid ping! Length %" L "u", read);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
src/window.c
24
src/window.c
@ -155,7 +155,7 @@ window_process_incoming_fragment(struct frag_buffer *w, fragment *f)
|
|||||||
}
|
}
|
||||||
/* Place fragment into correct location in buffer */
|
/* Place fragment into correct location in buffer */
|
||||||
ssize_t dest = WRAP(w->window_start + SEQ_OFFSET(startid, f->seqID));
|
ssize_t dest = WRAP(w->window_start + SEQ_OFFSET(startid, f->seqID));
|
||||||
WDEBUG(" Putting frag seq %u into frags[%lu + %u = %lu]",
|
WDEBUG(" Putting frag seq %u into frags[%" L "u + %u = %" L "u]",
|
||||||
f->seqID, w->window_start, SEQ_OFFSET(startid, f->seqID), dest);
|
f->seqID, w->window_start, SEQ_OFFSET(startid, f->seqID), dest);
|
||||||
|
|
||||||
/* Check if fragment already received */
|
/* Check if fragment already received */
|
||||||
@ -192,7 +192,7 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, size_t maxlen, int
|
|||||||
if (w->direction != WINDOW_RECVING)
|
if (w->direction != WINDOW_RECVING)
|
||||||
return 0;
|
return 0;
|
||||||
if (w->frags[w->chunk_start].start == 0 && w->numitems > 0) {
|
if (w->frags[w->chunk_start].start == 0 && w->numitems > 0) {
|
||||||
WDEBUG("chunk_start (%lu) pointing to non-start fragment (seq %u, len %lu)!",
|
WDEBUG("chunk_start (%" L "u) pointing to non-start fragment (seq %u, len %" L "u)!",
|
||||||
w->chunk_start, w->frags[w->chunk_start].seqID, w->frags[w->chunk_start].len);
|
w->chunk_start, w->frags[w->chunk_start].seqID, w->frags[w->chunk_start].len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -208,12 +208,12 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, size_t maxlen, int
|
|||||||
f = &w->frags[woffs];
|
f = &w->frags[woffs];
|
||||||
fraglen = f->len;
|
fraglen = f->len;
|
||||||
if (fraglen == 0 || f->seqID != curseq) {
|
if (fraglen == 0 || f->seqID != curseq) {
|
||||||
WDEBUG("Missing next frag %u [%lu], got seq %u (%lu bytes) instead! Not reassembling!",
|
WDEBUG("Missing next frag %u [%" L "u], got seq %u (%" L "u bytes) instead! Not reassembling!",
|
||||||
curseq, woffs, f->seqID, fraglen);
|
curseq, woffs, f->seqID, fraglen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WDEBUG(" Fragment seq %u, data length %lu, data offset %lu, total len %lu, maxlen %lu",
|
WDEBUG(" Fragment seq %u, data length %" L "u, data offset %" L "u, total len %" L "u, maxlen %" L "u",
|
||||||
f->seqID, fraglen, dest - data, datalen, maxlen);
|
f->seqID, fraglen, dest - data, datalen, maxlen);
|
||||||
memcpy(dest, f->data, MIN(fraglen, maxlen));
|
memcpy(dest, f->data, MIN(fraglen, maxlen));
|
||||||
dest += fraglen;
|
dest += fraglen;
|
||||||
@ -225,7 +225,7 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, size_t maxlen, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fraglen > maxlen) {
|
if (fraglen > maxlen) {
|
||||||
WDEBUG("Data buffer too small! Reassembled %lu bytes.", datalen);
|
WDEBUG("Data buffer too small! Reassembled %" L "u bytes.", datalen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, size_t maxlen, int
|
|||||||
window_tick(w);
|
window_tick(w);
|
||||||
|
|
||||||
if (f->end == 1) {
|
if (f->end == 1) {
|
||||||
WDEBUG("Found end of chunk! (seqID %u, chunk len %lu, datalen %lu)", f->seqID, i, datalen);
|
WDEBUG("Found end of chunk! (seqID %u, chunk len %" L "u, datalen %" L "u)", f->seqID, i, datalen);
|
||||||
end = 1;
|
end = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, size_t maxlen, int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WDEBUG("Reassembled %lu bytes from %lu frags; %scompressed!", datalen, i + 1, *compression ? "" : "un");
|
WDEBUG("Reassembled %" L "u bytes from %" L "u frags; %scompressed!", datalen, i + 1, *compression ? "" : "un");
|
||||||
/* Clear all used fragments */
|
/* Clear all used fragments */
|
||||||
size_t p;
|
size_t p;
|
||||||
ITER_FORWARD(w->chunk_start, WRAP(w->chunk_start + i + 1), w->length, p,
|
ITER_FORWARD(w->chunk_start, WRAP(w->chunk_start + i + 1), w->length, p,
|
||||||
@ -340,7 +340,7 @@ window_get_next_sending_fragment(struct frag_buffer *w, int *other_ack)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f)
|
if (f)
|
||||||
WDEBUG("Not sending any fragments (last frag checked: retries %u, seqid %u, len %lu)",
|
WDEBUG("Not sending any fragments (last frag checked: retries %u, seqid %u, len %" L "u)",
|
||||||
f->retries, f->seqID, f->len);
|
f->retries, f->seqID, f->len);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ window_ack(struct frag_buffer *w, int seqid)
|
|||||||
if (f->acks > 0)
|
if (f->acks > 0)
|
||||||
WDEBUG("DUPE ACK: %d ACKs for seqId %u", f->acks, seqid);
|
WDEBUG("DUPE ACK: %d ACKs for seqId %u", f->acks, seqid);
|
||||||
f->acks ++;
|
f->acks ++;
|
||||||
WDEBUG(" ACK frag seq %u, ACKs %u, len %lu, s %u e %u", f->seqID, f->acks, f->len, f->start, f->end);
|
WDEBUG(" ACK frag seq %u, ACKs %u, len %" L "u, s %u e %u", f->seqID, f->acks, f->len, f->start, f->end);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ window_tick(struct frag_buffer *w)
|
|||||||
unsigned old_start_id = w->start_seq_id;
|
unsigned old_start_id = w->start_seq_id;
|
||||||
#endif
|
#endif
|
||||||
w->start_seq_id = (w->start_seq_id + 1) % MAX_SEQ_ID;
|
w->start_seq_id = (w->start_seq_id + 1) % MAX_SEQ_ID;
|
||||||
WDEBUG("moving window forwards; %lu-%lu (%u) to %lu-%lu (%u) len=%lu",
|
WDEBUG("moving window forwards; %" L "u-%" L "u (%u) to %" L "u-%" L "u (%u) len=%" L "u",
|
||||||
w->window_start, w->window_end, old_start_id, AFTER(w, 1),
|
w->window_start, w->window_end, old_start_id, AFTER(w, 1),
|
||||||
AFTER(w, w->windowsize + 1), w->start_seq_id, w->length);
|
AFTER(w, w->windowsize + 1), w->start_seq_id, w->length);
|
||||||
if (w->direction == WINDOW_SENDING) {
|
if (w->direction == WINDOW_SENDING) {
|
||||||
@ -429,7 +429,7 @@ window_add_outgoing_data(struct frag_buffer *w, uint8_t *data, size_t len, int c
|
|||||||
compressed &= 1;
|
compressed &= 1;
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
static fragment f;
|
static fragment f;
|
||||||
WDEBUG("add data len %lu, %lu frags, max fragsize %u", len, n, w->maxfraglen);
|
WDEBUG("add data len %" L "u, %" L "u frags, max fragsize %u", len, n, w->maxfraglen);
|
||||||
for (size_t i = 0; i < n; i++) {
|
for (size_t i = 0; i < n; i++) {
|
||||||
memset(&f, 0, sizeof(f));
|
memset(&f, 0, sizeof(f));
|
||||||
f.len = MIN(len - offset, w->maxfraglen);
|
f.len = MIN(len - offset, w->maxfraglen);
|
||||||
@ -441,7 +441,7 @@ window_add_outgoing_data(struct frag_buffer *w, uint8_t *data, size_t len, int c
|
|||||||
f.ack_other = -1;
|
f.ack_other = -1;
|
||||||
window_append_fragment(w, &f);
|
window_append_fragment(w, &f);
|
||||||
w->cur_seq_id = (w->cur_seq_id + 1) % MAX_SEQ_ID;
|
w->cur_seq_id = (w->cur_seq_id + 1) % MAX_SEQ_ID;
|
||||||
WDEBUG(" fragment len %lu, seqID %u, s %u, end %u, dOffs %lu", f.len, f.seqID, f.start, f.end, offset);
|
WDEBUG(" fragment len %" L "u, seqID %u, s %u, end %u, dOffs %" L "u", f.len, f.seqID, f.start, f.end, offset);
|
||||||
offset += f.len;
|
offset += f.len;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
Loading…
Reference in New Issue
Block a user