Skip to content

Commit

Permalink
Forward tos/tclass to mud
Browse files Browse the repository at this point in the history
  • Loading branch information
angt committed Jul 25, 2016
1 parent 84156a9 commit 91bb0b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mud
Submodule mud updated 2 files
+66 −51 mud.c
+1 −1 mud.h
3 changes: 3 additions & 0 deletions src/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

struct ip_common {
uint8_t version;
uint8_t tc;
uint8_t proto;
uint8_t hdr_size;
uint16_t size;
Expand All @@ -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;
Expand Down
16 changes: 14 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 91bb0b1

Please sign in to comment.