From d11edeb3e7f0d4f21975dc7accdab93908d47ff2 Mon Sep 17 00:00:00 2001 From: luis Date: Tue, 22 Jun 2010 18:22:54 +0000 Subject: [PATCH] Changed send_frag_ip_packet() to make sure it accepts big MTU values, and fixed the format specifier, which was printing a signed integer when it should print an unsigned one --- libnetutil/netutil.cc | 6 +++--- libnetutil/netutil.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index 5bfee095e..1d0cddaeb 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -3188,10 +3188,10 @@ int send_ip_packet_eth_or_sd(int sd, struct eth_nfo *eth, u8 *packet, unsigned i * which gives us a right to cut TCP header after 8th byte * (shouldn't we inflate the header to 60 bytes too?) */ int send_frag_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, - unsigned int packetlen, unsigned int mtu) { + unsigned int packetlen, u32 mtu) { struct ip *ip = (struct ip *) packet; int headerlen = ip->ip_hl * 4; // better than sizeof(struct ip) - unsigned int datalen = packetlen - headerlen; + u32 datalen = packetlen - headerlen; int fdatalen = 0, res = 0; int fragment=0; @@ -3200,7 +3200,7 @@ int send_frag_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, assert(mtu > 0 && mtu % 8 == 0); // otherwise, we couldn't set Fragment offset (ip->ip_off) correctly if (datalen <= mtu) { - netutil_error("Warning: fragmentation (mtu=%i) requested but the payload is too small already (%i)", mtu, datalen); + netutil_error("Warning: fragmentation (mtu=%lu) requested but the payload is too small already (%lu)", (unsigned long)mtu, (unsigned long)datalen); return send_ip_packet_eth_or_sd(sd, eth, packet, packetlen); } diff --git a/libnetutil/netutil.h b/libnetutil/netutil.h index 58a315eb2..637598410 100644 --- a/libnetutil/netutil.h +++ b/libnetutil/netutil.h @@ -406,7 +406,7 @@ int send_ip_packet_eth_or_sd(int sd, struct eth_nfo *eth, u8 *packet, unsigned i * Minimal MTU for IPv4 is 68 and maximal IPv4 header size is 60 * which gives us a right to cut TCP header after 8th byte */ int send_frag_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, - unsigned int packetlen, unsigned int mtu); + unsigned int packetlen, u32 mtu); /* Wrapper for system function sendto(), which retries a few times when * the call fails. It also prints informational messages about the