Compare commits
2 Commits
v0.0.59-mu
...
v0.0.61-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73ce84ccf7 | ||
|
|
91bb0b1231 |
2
mud
2
mud
Submodule mud updated: 1fe5190e8a...a22476f18a
3
src/ip.h
3
src/ip.h
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
struct ip_common {
|
struct ip_common {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
|
uint8_t tc;
|
||||||
uint8_t proto;
|
uint8_t proto;
|
||||||
uint8_t hdr_size;
|
uint8_t hdr_size;
|
||||||
uint16_t 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) {
|
switch (ic->version) {
|
||||||
case 4:
|
case 4:
|
||||||
|
ic->tc = data[1];
|
||||||
ic->proto = data[9];
|
ic->proto = data[9];
|
||||||
ic->hdr_size = (data[0]&0xF)<<2;
|
ic->hdr_size = (data[0]&0xF)<<2;
|
||||||
ic->size = ((data[2]<<8)|data[3]);
|
ic->size = ((data[2]<<8)|data[3]);
|
||||||
return 0;
|
return 0;
|
||||||
case 6:
|
case 6:
|
||||||
|
ic->tc = ((data[0]&0xF)<<4)|(data[1]>>4);
|
||||||
ic->proto = data[6];
|
ic->proto = data[6];
|
||||||
ic->hdr_size = 40;
|
ic->hdr_size = 40;
|
||||||
ic->size = ((data[4]<<8)|data[5])+40;
|
ic->size = ((data[4]<<8)|data[5])+40;
|
||||||
|
|||||||
16
src/main.c
16
src/main.c
@@ -384,6 +384,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
size_t send_size = 0;
|
size_t send_size = 0;
|
||||||
size_t send_limit = 0;
|
size_t send_limit = 0;
|
||||||
|
int send_tc = 0;
|
||||||
|
int send_next_tc = 0;
|
||||||
|
|
||||||
while (!gt.quit) {
|
while (!gt.quit) {
|
||||||
FD_SET(tun_fd, &rfds);
|
FD_SET(tun_fd, &rfds);
|
||||||
@@ -438,16 +440,26 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
send_size += r;
|
send_size += r;
|
||||||
|
|
||||||
if (send_size<=mtu)
|
int update_tc = (ic.tc&0xFC)>(send_tc&0xFC);
|
||||||
|
|
||||||
|
if (send_size<=mtu) {
|
||||||
send_limit = send_size;
|
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)
|
if (send_size>send_limit)
|
||||||
memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit);
|
memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit);
|
||||||
send_size -= send_limit;
|
send_size -= send_limit;
|
||||||
send_limit = send_size;
|
send_limit = send_size;
|
||||||
|
send_tc = send_next_tc;
|
||||||
|
send_next_tc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mud_push(mud);
|
mud_push(mud);
|
||||||
|
|||||||
Reference in New Issue
Block a user