Spinning Topp Logo BlackTopp Studios
inc
packet.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _networkpacket_cpp
42 #define _networkpacket_cpp
43 
44 #include "Network/platformincludes.h.cpp"
45 
46 #include "Network/packet.h"
47 
48 namespace
49 {
50  enum MTUValues
51  {
52  SmallestIPv4MTU = 576,
53  IPv4HeaderBaseSize = 20,
54  IPv4HeaderOptionsMaxSize = 40,
55 
56  SmallestIPv6MTU = 1500,
57  IPv6HeaderBaseSize = 40,
58  IPv6HeaderOptionsEstSize = 40,
59 
60  TCPHeaderBaseSize = 40,
61  TCPHeaderOptionsMaxSize = 40,
62 
63  UDPHeaderSize = 8
64  };
65 }
66 
67 namespace Mezzanine
68 {
69  namespace Network
70  {
71  ///////////////////////////////////////////////////////////////////////////////
72  // Packet Static Member Data
73 
74  const Whole Packet::DefaultIPv4MTU = SmallestIPv4MTU;
75  const Whole Packet::DefaultIPv6MTU = SmallestIPv6MTU;
76  const Whole Packet::DefaultUDPv4MsgSize = SmallestIPv4MTU - ( ( IPv4HeaderBaseSize + IPv4HeaderOptionsMaxSize ) + UDPHeaderSize );
77  const Whole Packet::DefaultUDPv6MsgSize = SmallestIPv6MTU - ( ( IPv6HeaderBaseSize + IPv6HeaderOptionsEstSize ) + UDPHeaderSize );
78  const Whole Packet::DefaultTCPv4MsgSize = SmallestIPv4MTU - ( ( IPv4HeaderBaseSize + IPv4HeaderOptionsMaxSize ) + ( TCPHeaderBaseSize + TCPHeaderOptionsMaxSize ) );
79  const Whole Packet::DefaultTCPv6MsgSize = SmallestIPv6MTU - ( ( IPv6HeaderBaseSize + IPv6HeaderOptionsEstSize ) + ( TCPHeaderBaseSize + TCPHeaderOptionsMaxSize ) );
80 
81  ///////////////////////////////////////////////////////////////////////////////
82  // Packet Methods
83 
85  { }
86 
88  { }
89 
90  ///////////////////////////////////////////////////////////////////////////////
91  // Utility
92 
94  { return this->GetExpectedSize() == this->GetSize(); }
95 
96  ///////////////////////////////////////////////////////////////////////////////
97  // Buffer Management
98  }//Network
99 }//Mezzanine
100 
101 #endif
static const Whole DefaultUDPv6MsgSize
The maximum size the message portion of a UDP packet can be without being rejected with IPv6...
Definition: packet.h:120
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
static const Whole DefaultTCPv6MsgSize
The maximum size the message portion of a TCP packet can be without segmenting with IPv6...
Definition: packet.h:124
static const Whole DefaultIPv4MTU
The maximum size an entire single transmission can be without fragmenting/rejection over IPv4...
Definition: packet.h:114
virtual ~Packet()
Class destructor.
Definition: packet.cpp:87
static const Whole DefaultTCPv4MsgSize
The maximum size the message portion of a TCP packet can be without segmenting with IPv4...
Definition: packet.h:122
virtual Whole GetExpectedSize() const =0
Gets the size this packet should be according to it's type.
Packet()
Class constructor.
Definition: packet.cpp:84
Boole IsExpectedSize() const
Gets whether or not this packet is the size it should be.
Definition: packet.cpp:93
static const Whole DefaultUDPv4MsgSize
The maximum size the message portion of a UDP packet can be without fragmenting/rejection with IPv4...
Definition: packet.h:118
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
virtual Whole GetSize() const =0
Gets the actual size of this packet.
static const Whole DefaultIPv6MTU
The maximum size an entire single transmission can be without fragmenting/rejection over IPv6...
Definition: packet.h:116