LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2007 Georgia Tech Research Corporation | 3 * Copyright (c) 2007 Georgia Tech Research Corporation |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 } | 256 } |
257 | 257 |
258 it = buf.Begin (); | 258 it = buf.Begin (); |
259 /* we don't CompleteChecksum ( ~ ) now */ | 259 /* we don't CompleteChecksum ( ~ ) now */ |
260 return ~(it.CalculateIpChecksum (hdrSize)); | 260 return ~(it.CalculateIpChecksum (hdrSize)); |
261 } | 261 } |
262 | 262 |
263 uint16_t | 263 uint16_t |
264 TcpHeader::CalculateHeaderChecksum(uint32_t size) const | 264 TcpHeader::CalculateHeaderChecksum(uint32_t size) const |
265 { | 265 { |
266 return CalculateHeaderChecksum(static_cast<uint16_t>(size)); | 266 return CalculateHeaderChecksum(static_cast<uint16_t> (size)); |
267 } | 267 } |
268 | 268 |
269 bool | 269 bool |
270 TcpHeader::IsChecksumOk (void) const | 270 TcpHeader::IsChecksumOk (void) const |
271 { | 271 { |
272 return m_goodChecksum; | 272 return m_goodChecksum; |
273 } | 273 } |
274 | 274 |
275 TypeId | 275 TypeId |
276 TcpHeader::GetTypeId (void) | 276 TcpHeader::GetTypeId (void) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 if (optionSize != op->GetSerializedSize ()) | 404 if (optionSize != op->GetSerializedSize ()) |
405 { | 405 { |
406 NS_LOG_ERROR ("Option did not deserialize correctly"); | 406 NS_LOG_ERROR ("Option did not deserialize correctly"); |
407 break; | 407 break; |
408 } | 408 } |
409 if (optionLen >= optionSize) | 409 if (optionLen >= optionSize) |
410 { | 410 { |
411 optionLen -= optionSize; | 411 optionLen -= optionSize; |
412 i.Next (optionSize); | 412 i.Next (optionSize); |
413 m_options.push_back (op); | 413 m_options.push_back (op); |
414 m_optionsLen += static_cast<uint8_t>(optionSize); | 414 m_optionsLen += static_cast<uint8_t> (optionSize); |
415 } | 415 } |
416 else | 416 else |
417 { | 417 { |
418 NS_LOG_ERROR ("Option exceeds TCP option space; option discarded"); | 418 NS_LOG_ERROR ("Option exceeds TCP option space; option discarded"); |
419 break; | 419 break; |
420 } | 420 } |
421 if (op->GetKind () == TcpOption::END) | 421 if (op->GetKind () == TcpOption::END) |
422 { | 422 { |
423 while (optionLen) | 423 while (optionLen) |
424 { | 424 { |
(...skipping 30 matching lines...) Expand all Loading... |
455 | 455 |
456 for (i = m_options.begin (); i != m_options.end (); ++i) | 456 for (i = m_options.begin (); i != m_options.end (); ++i) |
457 { | 457 { |
458 len += (*i)->GetSerializedSize (); | 458 len += (*i)->GetSerializedSize (); |
459 } | 459 } |
460 // Option list may not include padding; need to pad up to word boundary | 460 // Option list may not include padding; need to pad up to word boundary |
461 if (len % 4) | 461 if (len % 4) |
462 { | 462 { |
463 len += 4 - (len % 4); | 463 len += 4 - (len % 4); |
464 } | 464 } |
465 return static_cast<uint8_t>(len >> 2); | 465 return static_cast<uint8_t> (len >> 2); |
466 } | 466 } |
467 | 467 |
468 bool | 468 bool |
469 TcpHeader::AppendOption (Ptr<const TcpOption> option) | 469 TcpHeader::AppendOption (Ptr<const TcpOption> option) |
470 { | 470 { |
471 if (m_optionsLen + option->GetSerializedSize () <= m_maxOptionsLen) | 471 if (m_optionsLen + option->GetSerializedSize () <= m_maxOptionsLen) |
472 { | 472 { |
473 if (!TcpOption::IsKindKnown (option->GetKind ())) | 473 if (!TcpOption::IsKindKnown (option->GetKind ())) |
474 { | 474 { |
475 NS_LOG_WARN ("The option kind " << static_cast<int> (option->GetKind (
)) << " is unknown"); | 475 NS_LOG_WARN ("The option kind " << static_cast<int> (option->GetKind (
)) << " is unknown"); |
476 return false; | 476 return false; |
477 } | 477 } |
478 | 478 |
479 if (option->GetKind () != TcpOption::END) | 479 if (option->GetKind () != TcpOption::END) |
480 { | 480 { |
481 m_options.push_back (option); | 481 m_options.push_back (option); |
482 m_optionsLen += static_cast<uint8_t>(option->GetSerializedSize ()); | 482 m_optionsLen += static_cast<uint8_t> (option->GetSerializedSize ()); |
483 | 483 |
484 uint32_t totalLen = 20 + 3 + m_optionsLen; | 484 uint32_t totalLen = 20 + 3 + m_optionsLen; |
485 m_length = static_cast<uint8_t>(totalLen >> 2); | 485 m_length = static_cast<uint8_t> (totalLen >> 2); |
486 } | 486 } |
487 | 487 |
488 return true; | 488 return true; |
489 } | 489 } |
490 | 490 |
491 return false; | 491 return false; |
492 } | 492 } |
493 | 493 |
494 const TcpHeader::TcpOptionList& | 494 const TcpHeader::TcpOptionList& |
495 TcpHeader::GetOptionList () const | 495 TcpHeader::GetOptionList () const |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 544 } |
545 | 545 |
546 std::ostream& | 546 std::ostream& |
547 operator<< (std::ostream& os, TcpHeader const & tc) | 547 operator<< (std::ostream& os, TcpHeader const & tc) |
548 { | 548 { |
549 tc.Print (os); | 549 tc.Print (os); |
550 return os; | 550 return os; |
551 } | 551 } |
552 | 552 |
553 } // namespace ns3 | 553 } // namespace ns3 |
LEFT | RIGHT |