#include <IPv6Datagram.h>
Public Member Functions | |
IPv6Datagram (const char *name=NULL, int kind=0) | |
IPv6Datagram (const IPv6Datagram &other) | |
IPv6Datagram & | operator= (const IPv6Datagram &other) |
virtual IPv6Datagram * | dup () const |
virtual void | setExtensionHeaderArraySize (unsigned int size) |
virtual void | setExtensionHeader (unsigned int k, const IPv6ExtensionHeaderPtr &extensionHeader_var) |
virtual unsigned int | getExtensionHeaderArraySize () const |
virtual IPv6ExtensionHeaderPtr & | getExtensionHeader (unsigned int k) |
virtual void | addExtensionHeader (IPv6ExtensionHeader *eh, int atPos=-1) |
virtual int | calculateHeaderByteLength () const |
Protected Types | |
typedef std::vector < IPv6ExtensionHeader * > | ExtensionHeaders |
Protected Attributes | |
ExtensionHeaders | extensionHeaders |
typedef std::vector<IPv6ExtensionHeader*> IPv6Datagram::ExtensionHeaders [protected] |
IPv6Datagram::IPv6Datagram | ( | const char * | name = NULL , |
|
int | kind = 0 | |||
) | [inline] |
IPv6Datagram::IPv6Datagram | ( | const IPv6Datagram & | other | ) | [inline] |
IPv6Datagram & IPv6Datagram::operator= | ( | const IPv6Datagram & | other | ) |
00032 { 00033 IPv6Datagram_Base::operator=(other); 00034 00035 for (ExtensionHeaders::const_iterator i=other.extensionHeaders.begin(); i!=other.extensionHeaders.end(); ++i) 00036 { 00037 // addExtensionHeader((*i)->dup()); FIXME unfortunately ExtensionHeader doesn't have dup(), 00038 // so for now we have to resort to the following unsafe and unextensible nasty solution 00039 IPv6ExtensionHeader *eh = (*i); 00040 IPv6ExtensionHeader *dupEh = NULL; 00041 if (dynamic_cast<IPv6HopByHopOptionsHeader*>(eh)) { 00042 dupEh = new IPv6HopByHopOptionsHeader(); 00043 *dupEh = *(IPv6HopByHopOptionsHeader *)eh; 00044 } else if (dynamic_cast<IPv6RoutingHeader*>(eh)) { 00045 dupEh = new IPv6RoutingHeader(); 00046 *dupEh = *(IPv6RoutingHeader *)eh; 00047 } else if (dynamic_cast<IPv6FragmentHeader*>(eh)) { 00048 dupEh = new IPv6FragmentHeader(); 00049 *dupEh = *(IPv6FragmentHeader *)eh; 00050 } else if (dynamic_cast<IPv6DestinationOptionsHeader*>(eh)) { 00051 dupEh = new IPv6DestinationOptionsHeader(); 00052 *dupEh = *(IPv6DestinationOptionsHeader *)eh; 00053 } else if (dynamic_cast<IPv6AuthenticationHeader*>(eh)) { 00054 dupEh = new IPv6AuthenticationHeader(); 00055 *dupEh = *(IPv6AuthenticationHeader *)eh; 00056 } else if (dynamic_cast<IPv6EncapsulatingSecurityPayloadHeader*>(eh)) { 00057 dupEh = new IPv6EncapsulatingSecurityPayloadHeader(); 00058 *dupEh = *(IPv6EncapsulatingSecurityPayloadHeader *)eh; 00059 } else { 00060 throw cRuntimeError(this, "unrecognised HeaderExtension subclass %s in IPv6Datagram::operator=()", eh->getClassName()); 00061 } 00062 addExtensionHeader(dupEh); 00063 } 00064 00065 return *this; 00066 }
virtual IPv6Datagram* IPv6Datagram::dup | ( | ) | const [inline, virtual] |
void IPv6Datagram::setExtensionHeaderArraySize | ( | unsigned int | size | ) | [virtual] |
void IPv6Datagram::setExtensionHeader | ( | unsigned int | k, | |
const IPv6ExtensionHeaderPtr & | extensionHeader_var | |||
) | [virtual] |
unsigned int IPv6Datagram::getExtensionHeaderArraySize | ( | ) | const [virtual] |
Returns the number of extension headers in this datagram
00074 { 00075 return extensionHeaders.size(); 00076 }
IPv6ExtensionHeaderPtr & IPv6Datagram::getExtensionHeader | ( | unsigned int | k | ) | [virtual] |
Returns the kth extension header in this datagram
00079 { 00080 static IPv6ExtensionHeaderPtr null; 00081 if (k>=extensionHeaders.size()) 00082 return (null=NULL); 00083 return extensionHeaders[k]; 00084 }
void IPv6Datagram::addExtensionHeader | ( | IPv6ExtensionHeader * | eh, | |
int | atPos = -1 | |||
) | [virtual] |
Adds an extension header to the datagram, at the given position. The default (atPos==-1) is to add the header at the end.
Referenced by operator=().
00092 { 00093 if (atPos<0 || atPos>=(int)extensionHeaders.size()) 00094 { 00095 extensionHeaders.push_back(eh); 00096 return; 00097 } 00098 00099 // insert at position atPos, shift up the rest of the array 00100 extensionHeaders.insert(extensionHeaders.begin()+atPos, eh); 00101 }
int IPv6Datagram::calculateHeaderByteLength | ( | ) | const [virtual] |
Calculates the length of the IPv6 header plus the extension headers.
Referenced by IPv6FragBuf::addFragment().
00104 { 00105 int len = 40; 00106 for (unsigned int i=0; i<extensionHeaders.size(); i++) 00107 len += extensionHeaders[i]->getByteLength(); 00108 return len; 00109 }
ExtensionHeaders IPv6Datagram::extensionHeaders [protected] |
Referenced by addExtensionHeader(), calculateHeaderByteLength(), getExtensionHeader(), getExtensionHeaderArraySize(), and operator=().