diff --git a/mud b/mud index 1fe5190..c1b501b 160000 --- a/mud +++ b/mud @@ -1 +1 @@ -Subproject commit 1fe5190e8a2cf6aeef64cbf956545f0134e4f56f +Subproject commit c1b501bc19e29d3f388dce9b73ca8f9f43a85027 diff --git a/src/ip.h b/src/ip.h index e1b5b4d..cf238ff 100644 --- a/src/ip.h +++ b/src/ip.h @@ -4,6 +4,7 @@ struct ip_common { uint8_t version; + uint8_t tc; uint8_t proto; uint8_t hdr_size; uint16_t size; @@ -24,11 +25,13 @@ static inline int ip_get_common (struct ip_common *ic, const uint8_t *data, size switch (ic->version) { case 4: + ic->tc = data[1]; ic->proto = data[9]; ic->hdr_size = (data[0]&0xF)<<2; ic->size = ((data[2]<<8)|data[3]); return 0; case 6: + ic->tc = ((data[0]&0xF)<<4)|(data[1]>>4); ic->proto = data[6]; ic->hdr_size = 40; ic->size = ((data[4]<<8)|data[5])+40; diff --git a/src/main.c b/src/main.c index ef63cea..40be8b1 100644 --- a/src/main.c +++ b/src/main.c @@ -384,6 +384,8 @@ int main (int argc, char **argv) size_t send_size = 0; size_t send_limit = 0; + int send_tc = 0; + int send_next_tc = 0; while (!gt.quit) { FD_SET(tun_fd, &rfds); @@ -438,16 +440,26 @@ int main (int argc, char **argv) send_size += r; - if (send_size<=mtu) + int update_tc = (ic.tc&0xFC)>(send_tc&0xFC); + + if (send_size<=mtu) { send_limit = send_size; + if ((ic.tc&0xFC)>(send_tc&0xFC)) + send_tc = ic.tc; + } else { + if ((ic.tc&0xFC)>(send_next_tc&0xFC)) + send_next_tc = ic.tc; + } } } - if (send_limit && mud_send(mud, send.buf, send_limit)==send_limit) { + if (send_limit && mud_send(mud, send.buf, send_limit, send_tc)==send_limit) { if (send_size>send_limit) memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit); send_size -= send_limit; send_limit = send_size; + send_tc = send_next_tc; + send_next_tc = 0; } mud_push(mud);