|
INET Framework for OMNeT++/OMNEST
|
#include <xmlParser.h>
Static Public Member Functions | |
| static cXMLElement * | GetDevice (const char *deviceType, const char *deviceId, const char *configFile) |
| static cXMLElement * | GetInterface (cXMLElement *iface, cXMLElement *device) |
| static cXMLElement * | GetStaticRoute6 (cXMLElement *route, cXMLElement *device) |
| static cXMLElement * | GetOspfProcess6 (cXMLElement *process, cXMLElement *device) |
| static cXMLElement * | GetIPv6Address (cXMLElement *addr, cXMLElement *iface) |
| static cXMLElement * | GetAdvPrefix (cXMLElement *prefix, cXMLElement *iface) |
| static cXMLElement * | GetIsisRouting (cXMLElement *device) |
| static bool | Str2Int (int *retValue, const char *str) |
| static bool | Str2Bool (bool *ret, const char *str) |
Definition at line 33 of file xmlParser.h.
| cXMLElement * xmlParser::GetAdvPrefix | ( | cXMLElement * | prefix, |
| cXMLElement * | iface | ||
| ) | [static] |
Definition at line 85 of file xmlParser.cc.
Referenced by DeviceConfigurator::loadInterfaceConfig().
{
// initial call of the method - get first "NdpAdvPrefix" child node
if (iface != NULL){
prefix = iface->getFirstChildWithTag("NdpAdvPrefix");
// repeated call - get another "NdpAdvPrefix" sibling node
}else if (prefix != NULL){
prefix = prefix->getNextSiblingWithTag("NdpAdvPrefix");
}else{
prefix = NULL;
}
return prefix;
}
| cXMLElement * xmlParser::GetDevice | ( | const char * | deviceType, |
| const char * | deviceId, | ||
| const char * | configFile | ||
| ) | [static] |
Definition at line 22 of file xmlParser.cc.
Referenced by DeviceConfigurator::initialize(), AnsaOspfRouting6::initialize(), and ISIS::initialize().
{
// get access to the XML file (if exists)
cXMLElement *config = ev.getXMLDocument(configFile);
if (config == NULL)
return NULL;
string type = deviceType;
string id = deviceId;
if (type.empty() || id.empty())
return NULL;
// create string that describes device node, such as <Router id="10.0.0.1">
string deviceNodePath = type;
deviceNodePath += "[@id='";
deviceNodePath += id;
deviceNodePath += "']";
// get access to the device node
cXMLElement *device = config->getElementByPath(deviceNodePath.c_str());
return device;
}
| cXMLElement * xmlParser::GetInterface | ( | cXMLElement * | iface, |
| cXMLElement * | device | ||
| ) | [static] |
Definition at line 48 of file xmlParser.cc.
Referenced by DeviceConfigurator::initialize(), AnsaOspfRouting6::initialize(), DeviceConfigurator::loadInterfaceConfig(), and AnsaOspfRouting6::loadInterfaceConfig().
{
// initial call of the method - find <Interfaces> and get first "Interface" node
if (device != NULL){
cXMLElement *ifaces = device->getFirstChildWithTag("Interfaces");
if (ifaces == NULL)
return NULL;
iface = ifaces->getFirstChildWithTag("Interface");
// repeated call - get another "Interface" sibling node
}else if (iface != NULL){
iface = iface->getNextSiblingWithTag("Interface");
}else{
iface = NULL;
}
return iface;
}
| cXMLElement * xmlParser::GetIPv6Address | ( | cXMLElement * | addr, |
| cXMLElement * | iface | ||
| ) | [static] |
Definition at line 69 of file xmlParser.cc.
Referenced by DeviceConfigurator::loadInterfaceConfig(), and AnsaOspfRouting6::loadInterfaceConfig().
{
// initial call of the method - get first "IPv6Address" child node
if (iface != NULL){
addr = iface->getFirstChildWithTag("IPv6Address");
// repeated call - get another "IPv6Address" sibling node
}else if (addr != NULL){
addr = addr->getNextSiblingWithTag("IPv6Address");
}else{
addr = NULL;
}
return addr;
}
| cXMLElement * xmlParser::GetIsisRouting | ( | cXMLElement * | device | ) | [static] |
Definition at line 216 of file xmlParser.cc.
Referenced by ISIS::initialize().
{
if(device == NULL)
return NULL;
cXMLElement *routing = device->getFirstChildWithTag("Routing");
if(routing == NULL)
return NULL;
cXMLElement * isis = routing->getFirstChildWithTag("ISIS");
return isis;
}
| cXMLElement * xmlParser::GetOspfProcess6 | ( | cXMLElement * | process, |
| cXMLElement * | device | ||
| ) | [static] |
Definition at line 127 of file xmlParser.cc.
Referenced by AnsaOspfRouting6::initialize(), and AnsaOspfRouting6::loadOspfRouting().
{
// initial call of the method - get <Routing6> -> <Ospf>
// and then first "Process" child node
if (device != NULL){
cXMLElement *routing = device->getFirstChildWithTag("Routing6");
if (routing == NULL)
return NULL;
cXMLElement *ospf = routing->getFirstChildWithTag("Ospf");
if (ospf == NULL)
return NULL;
process = ospf->getFirstChildWithTag("Process");
// repeated call - get another "Process" sibling node
}else if (process != NULL){
process = process->getNextSiblingWithTag("Process");
}else{
process = NULL;
}
return process;
}
| cXMLElement * xmlParser::GetStaticRoute6 | ( | cXMLElement * | route, |
| cXMLElement * | device | ||
| ) | [static] |
Definition at line 101 of file xmlParser.cc.
Referenced by DeviceConfigurator::initialize(), and DeviceConfigurator::loadStaticRouting().
{
// initial call of the method - find <Routing6> -> <Static>
// and then get first "Route" child node
if (device != NULL){
cXMLElement *routing = device->getFirstChildWithTag("Routing6");
if (routing == NULL)
return NULL;
cXMLElement *staticRouting = routing->getFirstChildWithTag("Static");
if (staticRouting == NULL)
return NULL;
route = staticRouting->getFirstChildWithTag("Route");
// repeated call - get another "Route" sibling node
}else if (route != NULL){
route = route->getNextSiblingWithTag("Route");
}else{
route = NULL;
}
return route;
}
| bool xmlParser::Str2Bool | ( | bool * | ret, |
| const char * | str | ||
| ) | [static] |
Definition at line 176 of file xmlParser.cc.
Referenced by DeviceConfigurator::loadInterfaceConfig().
{
if ( (strcmp(str, "yes") == 0)
|| (strcmp(str, "enabled") == 0)
|| (strcmp(str, "on") == 0)
|| (strcmp(str, "true") == 0)){
*ret = true;
return true;
}
if ( (strcmp(str, "no") == 0)
|| (strcmp(str, "disabled") == 0)
|| (strcmp(str, "off") == 0)
|| (strcmp(str, "false") == 0)){
*ret = false;
return true;
}
int value;
if (Str2Int(&value, str)){
if (value == 1){
*ret = true;
return true;
}
if (value == 0){
*ret = false;
return true;
}
}
return false;
}
| bool xmlParser::Str2Int | ( | int * | retValue, |
| const char * | str | ||
| ) | [static] |
Definition at line 156 of file xmlParser.cc.
Referenced by DeviceConfigurator::loadInterfaceConfig(), AnsaOspfRouting6::loadInterfaceConfig(), AnsaOspfRouting6::loadOspfRouting(), DeviceConfigurator::loadStaticRouting(), and Str2Bool().
{
if (retValue == NULL || str == NULL){
return false;
}
char *tail = NULL;
long value = 0;
errno = 0;
value = strtol(str, &tail, 0);
if (*tail != '\0' || errno == ERANGE || errno == EINVAL || value < INT_MIN || value > INT_MAX){
return false;
}
*retValue = (int) value;
return true;
}