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