#include <omnetpp.h>
#include <string>
#include "IntServ.h"
#include "IPvXAddress.h"
Go to the source code of this file.
Function Documentation
Definition at line 83 of file common.cc.
Referenced by SCTPAssociation::processInitArrived(), and SCTPAssociation::sendInit().
{
if (addr.isIPv6())
{
if (addr.get6().getScope()==IPv6Address::UNSPECIFIED || addr.get6().getScope()==IPv6Address::MULTICAST)
return 0;
if (addr.get6().getScope()==IPv6Address::LOOPBACK)
return 1;
if (addr.get6().getScope()==IPv6Address::LINK)
return 2;
if (addr.get6().getScope()==IPv6Address::SITE)
return 3;
}
else
{
if (addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("0.0.0.0"), IPAddress("255.0.0.0")) ||
addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("224.0.0.0"), IPAddress("240.0.0.0")) ||
addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("198.18.0.0"), IPAddress("255.255.255.0")) ||
addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("192.88.99.0"), IPAddress("255.255.255.0")))
return 0;
if (addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("127.0.0.0"), IPAddress("255.0.0.0")))
return 1;
if (addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("169.254.0.0"), IPAddress("255.255.0.0")))
return 2;
if (addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("10.0.0.0"), IPAddress("255.0.0.0")) ||
addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("172.16.0.0"), IPAddress("255.240.0.0")) ||
addr.get4().maskedAddrAreEqual(addr.get4(), IPAddress("192.168.0.0"), IPAddress("255.255.0.0")))
return 3;
}
return 4;
}
std::string intToString |
( |
int |
i |
) |
|
Definition at line 22 of file common.cc.
{
std::ostringstream stream;
stream << i << std::flush;
std::string str(stream.str());
return str;
}
EroVector routeToEro |
( |
IPAddressVector |
rro |
) |
|
Definition at line 69 of file common.cc.
{
EroVector ero;
for(unsigned int i = 0; i < rro.size(); i++)
{
EroObj_t hop;
hop.L = false;
hop.node = rro[i];
ero.push_back(hop);
}
return ero;
}
std::string vectorToString |
( |
EroVector |
vec, |
|
|
const char * |
delim | |
|
) |
| | |
Definition at line 54 of file common.cc.
{
std::ostringstream stream;
for(unsigned int i = 0; i < vec.size(); i++)
{
stream << vec[i].node;
if(i < vec.size() - 1)
stream << delim;
}
stream << std::flush;
std::string str(stream.str());
return str;
}
std::string vectorToString |
( |
EroVector |
vec |
) |
|
std::string vectorToString |
( |
IPAddressVector |
vec, |
|
|
const char * |
delim | |
|
) |
| | |
Definition at line 35 of file common.cc.
{
std::ostringstream stream;
for(unsigned int i = 0; i < vec.size(); i++)
{
stream << vec[i];
if(i < vec.size() - 1)
stream << delim;
}
stream << std::flush;
std::string str(stream.str());
return str;
}
std::string vectorToString |
( |
IPAddressVector |
vec |
) |
|