Support different IPv4 and IPv6 MTUs.

Closes #688.
This commit is contained in:
John Hood
2015-11-16 02:35:18 -05:00
parent b742e958b6
commit 3fa42cb8bb
6 changed files with 64 additions and 15 deletions
+5 -4
View File
@@ -154,8 +154,9 @@ bool Fragment::operator==( const Fragment &x ) const
&& ( initialized == x.initialized ) && ( contents == x.contents );
}
vector<Fragment> Fragmenter::make_fragments( const Instruction &inst, int MTU )
vector<Fragment> Fragmenter::make_fragments( const Instruction &inst, size_t MTU )
{
MTU -= Fragment::frag_header_len;
if ( (inst.old_num() != last_instruction.old_num())
|| (inst.new_num() != last_instruction.new_num())
|| (inst.ack_num() != last_instruction.ack_num())
@@ -182,9 +183,9 @@ vector<Fragment> Fragmenter::make_fragments( const Instruction &inst, int MTU )
string this_fragment;
bool final = false;
if ( int( payload.size() + HEADER_LEN ) > MTU ) {
this_fragment = string( payload.begin(), payload.begin() + MTU - HEADER_LEN );
payload = string( payload.begin() + MTU - HEADER_LEN, payload.end() );
if ( payload.size() > MTU ) {
this_fragment = string( payload.begin(), payload.begin() + MTU );
payload = string( payload.begin() + MTU, payload.end() );
} else {
this_fragment = payload;
payload.clear();