Commit 09cdc850 authored by Tarun Prabhu's avatar Tarun Prabhu

Per Jon's suggestion, removed all suspicious XStr references and

pointers not copied from the values returned by XStr. To test if this
was the cause of the memory corruption, the "fix" of performing a deep
copy of the virtual root before annotating. If this doesn't work,
re-enabling the fix should be easy enough.
parent fd697af0
......@@ -36,33 +36,32 @@ using namespace std;
annotate_rspec :: annotate_rspec ()
{
this->document = doc;
this->virtual_root = dynamic_cast<DOMElement*>(dynamic_cast<DOMNode*>(request_root)->cloneNode(true));
this->virtual_root = request_root;
// this->virtual_root = dynamic_cast<DOMElement*>(dynamic_cast<DOMNode*>(request_root)->cloneNode(true));
this->physical_elements = advertisement_elements;
vector<DOMElement*> lan_links
= getElementsHavingAttribute(this->virtual_root, "link", "is_lan");
vector<DOMElement*>::iterator it;
for (it = lan_links.begin(); it < lan_links.end(); it++)
{
DOMElement* lan_link = *it;
// Removing annotations inserted earlier
lan_link->removeAttribute(XStr("is_lan").x());
string lan_link_id
= string(XStr(lan_link->getAttribute(XStr("virtual_id").x())).c());
set<string> virtual_interface_ids;
DOMNodeList* interfaces
= lan_link->getElementsByTagName(XStr("interface_ref").x());
for (unsigned int j = 0; j < interfaces->getLength(); j++)
{
DOMElement* interface
= dynamic_cast<DOMElement*>(interfaces->item(j));
virtual_interface_ids.insert
(string(XStr(interface->getAttribute
(XStr("virtual_interface_id").x())).c()));
}
this->lan_links_map.insert
(pair< string, set<string> >(lan_link_id, virtual_interface_ids));
for (it = lan_links.begin(); it < lan_links.end(); it++) {
DOMElement* lan_link = *it;
// Removing annotations inserted earlier
lan_link->removeAttribute(XStr("is_lan").x());
string lan_link_id
= string(XStr(lan_link->getAttribute(XStr("virtual_id").x())).c());
set<string> virtual_interface_ids;
DOMNodeList* interfaces
= lan_link->getElementsByTagName(XStr("interface_ref").x());
for (unsigned int j = 0; j < interfaces->getLength(); j++) {
DOMElement* interface
= dynamic_cast<DOMElement*>(interfaces->item(j));
virtual_interface_ids.insert
(string(XStr(interface->getAttribute
(XStr("virtual_interface_id").x())).c()));
}
this->lan_links_map.insert
(pair< string, set<string> >(lan_link_id, virtual_interface_ids));
}
}
// Annotate a trivial link
......@@ -110,17 +109,17 @@ void annotate_rspec::annotate_element (const char* v_name, const char* p_name)
if (vlink->hasAttribute(XStr("generated_by_assign").x())) {
string str_lan_link
= string(XStr(vlink->getAttribute(XStr("lan_link").x())).c());
= string(XStr(vlink->getAttribute(XStr("lan_link").x())).c());
DOMElement* lan_link
= getElementByAttributeValue(this->virtual_root, "link",
"virtual_id",
str_lan_link.c_str());
= getElementByAttributeValue(this->virtual_root, "link",
"virtual_id",
str_lan_link.c_str());
DOMNodeList* component_hops
= vlink->getElementsByTagName(XStr("component_hop").x());
= vlink->getElementsByTagName(XStr("component_hop").x());
for (unsigned int i = 0; i < component_hops->getLength(); i++) {
DOMElement* component_hop
= dynamic_cast<DOMElement*>(component_hops->item(i));
copy_component_hop(lan_link, component_hop);
DOMElement* component_hop
= dynamic_cast<DOMElement*>(component_hops->item(i));
copy_component_hop(lan_link, component_hop);
}
}
}
......@@ -182,40 +181,37 @@ DOMElement* annotate_rspec::create_component_hop (DOMElement* vlink)
DOMElement* src_iface = dynamic_cast<DOMElement*>(interfaces->item(0));
DOMElement* dst_iface = dynamic_cast<DOMElement*>(interfaces->item(1));
const char* src_id
= XStr(src_iface->getAttribute(XStr("virtual_node_id").x())).c();
const char* dst_id
= XStr(dst_iface->getAttribute(XStr("virtual_node_id").x())).c();
string src_id=XStr(src_iface->getAttribute(XStr("virtual_node_id").x())).c();
string dst_id=XStr(dst_iface->getAttribute(XStr("virtual_node_id").x())).c();
DOMElement* src_vnode
= getElementByAttributeValue(this->virtual_root,
"node", "virtual_id", src_id);
"node", "virtual_id", src_id.c_str());
DOMElement* dst_vnode
= getElementByAttributeValue(this->virtual_root,
"node", "virtual_id", dst_id);
"node", "virtual_id", dst_id.c_str());
XStr src_component_id (find_urn(src_vnode, "component"));
XStr dst_component_id (find_urn(dst_vnode, "component"));
string src_component_id = XStr(find_urn(src_vnode, "component")).c();
string dst_component_id = XStr(find_urn(dst_vnode, "component")).c();
DOMElement* component_hop = doc->createElement(XStr("component_hop").x());
DOMElement* src_iface_clone
= dynamic_cast<DOMElement*>
(doc->importNode(dynamic_cast<DOMNode*>(src_iface),true));
= dynamic_cast<DOMElement*>(doc->importNode
(dynamic_cast<DOMNode*>(src_iface),true));
src_iface_clone->setAttribute(XStr("component_node_id").x(),
src_component_id.x());
XStr(src_component_id).x());
src_iface_clone->setAttribute(XStr("component_interface_id").x(),
XStr("loopback").x());
cerr << src_component_id.c() << " AND " << dst_component_id.c() << endl;
XStr("loopback").x());
DOMElement* dst_iface_clone
= dynamic_cast<DOMElement*>
(doc->importNode(dynamic_cast<DOMNode*>(dst_iface),true));
dst_iface_clone->setAttribute(XStr("component_node_id").x(),
dst_component_id.x());
XStr(dst_component_id).x());
dst_iface_clone->setAttribute(XStr("component_interface_id").x(),
XStr("loopback").x());
XStr("loopback").x());
component_hop->appendChild(src_iface_clone);
component_hop->appendChild(dst_iface_clone);
......@@ -244,10 +240,8 @@ DOMElement* annotate_rspec::create_component_hop (const DOMElement* plink,
DOMNodeList* vinterfaces
= vlink->getElementsByTagName(XStr("interface_ref").x());
DOMElement* vlink_src_iface
= dynamic_cast<DOMElement*>(vinterfaces->item(0));
DOMElement* vlink_dst_iface
= dynamic_cast<DOMElement*>(vinterfaces->item(1));
DOMElement* vlink_src_iface= dynamic_cast<DOMElement*>(vinterfaces->item(0));
DOMElement* vlink_dst_iface= dynamic_cast<DOMElement*>(vinterfaces->item(1));
// If the previous component hop is not specified (NULL),
// then the link is either direct
......@@ -263,11 +257,10 @@ DOMElement* annotate_rspec::create_component_hop (const DOMElement* plink,
if (prev_component_hop != NULL) {
// Find the destination of the previous component hop
DOMElement* prev_hop_dst_iface
= dynamic_cast<DOMElement*>
((prev_component_hop->getElementsByTagName
(XStr("interface_ref").x()))->item(1));
XStr prev_hop_dst_uuid (find_urn(prev_hop_dst_iface,
"component_node"));
= dynamic_cast<DOMElement*>((prev_component_hop->getElementsByTagName
(XStr("interface_ref").x()))->item(1));
string prev_hop_dst_uuid
= XStr(find_urn(prev_hop_dst_iface, "component_node")).c();
// We need to do this because in advertisements,
// all links are from nodes to switches
......@@ -275,17 +268,14 @@ DOMElement* annotate_rspec::create_component_hop (const DOMElement* plink,
// This is slightly more expensive,
// but definitely more robust than checking based on
// whether a destination interface was specified
if (strcmp(prev_hop_dst_uuid.c(),
XStr(find_urn(plink_dst_iface,
"component_node")).c()) == 0) {
if (prev_hop_dst_uuid == string(XStr(find_urn(plink_dst_iface,
"component_node")).c())) {
plink_src_iface_clone
= dynamic_cast<DOMElement*>
(doc->importNode(dynamic_cast<DOMNode*>
(plink_dst_iface), true));
= dynamic_cast<DOMElement*>(doc->importNode(dynamic_cast<DOMNode*>
(plink_dst_iface), true));
plink_dst_iface_clone
= dynamic_cast<DOMElement*>
(doc->importNode(dynamic_cast<DOMNode*>
(plink_src_iface), true));
= dynamic_cast<DOMElement*>(doc->importNode(dynamic_cast<DOMNode*>
(plink_src_iface), true));
}
}
......@@ -294,18 +284,18 @@ DOMElement* annotate_rspec::create_component_hop (const DOMElement* plink,
set_interface_as_link_endpoint
(plink_src_iface_clone,
XStr(vlink_src_iface->getAttribute
(XStr("virtual_node_id").x())).c(),
(XStr("virtual_node_id").x())).c(),
XStr(vlink_src_iface->getAttribute
(XStr("virtual_interface_id").x())).c());
(XStr("virtual_interface_id").x())).c());
// If the destination interface is an end point
if (endpoint_interface == DESTINATION || endpoint_interface == BOTH)
set_interface_as_link_endpoint
(plink_dst_iface_clone,
XStr(vlink_dst_iface->getAttribute
(XStr("virtual_node_id").x())).c(),
(XStr("virtual_node_id").x())).c(),
XStr(vlink_dst_iface->getAttribute
(XStr("virtual_interface_id").x())).c());
(XStr("virtual_interface_id").x())).c());
// Add interface specifications to the link in the single hop element
component_hop->appendChild(plink_src_iface_clone);
......@@ -400,44 +390,45 @@ void annotate_rspec::annotate_interface (const DOMElement* plink,
= vlink->getElementsByTagName(XStr("interface_ref").x());
DOMElement* vlink_iface
= dynamic_cast<DOMElement*>(vinterfaces->item(interface_number));
XStr vlink_iface_virtual_interface_id
(vlink_iface->getAttribute(XStr("virtual_interface_id").x()));
string vlink_iface_virtual_interface_id
= XStr(vlink_iface->getAttribute(XStr("virtual_interface_id").x())).c();
// Get the virtual_id of the node to which the interface belongs
XStr vlink_iface_virtual_node_id
(vlink_iface->getAttribute(XStr("virtual_node_id").x()));
string vlink_iface_virtual_node_id
= XStr(vlink_iface->getAttribute(XStr("virtual_node_id").x())).c();
DOMElement* vnode
= getElementByAttributeValue(this->virtual_root,
"node",
"virtual_id",
vlink_iface_virtual_node_id.c());
"node",
"virtual_id",
vlink_iface_virtual_node_id.c_str());
DOMElement* vnode_iface_decl
= getElementByAttributeValue(vnode, "interface", "virtual_id",
vlink_iface_virtual_interface_id.c());
XStr component_node_uuid (find_urn(vnode, "component"));
vlink_iface_virtual_interface_id.c_str());
string component_node_uuid = XStr(find_urn(vnode, "component")).c();
if (!is_trivial_link)
{
DOMElement* p_iface
= getElementByAttributeValue(plink, "interface_ref",
"component_node_uuid",
component_node_uuid.c());
= getElementByAttributeValue(plink, "interface_ref",
"component_node_uuid",
component_node_uuid.c_str());
if (p_iface == NULL)
{
p_iface = getElementByAttributeValue(plink, "interface_ref",
"component_node_urn",
component_node_uuid.c());
"component_node_urn",
component_node_uuid.c_str());
}
XStr component_interface_id
(p_iface->getAttribute(XStr("component_interface_id").x()));
vnode_iface_decl->setAttribute
(XStr("component_id").x(), component_interface_id.x());
string component_interface_id
= XStr(p_iface->getAttribute(XStr("component_interface_id").x())).c();
vnode_iface_decl->setAttribute (XStr("component_id").x(),
XStr(component_interface_id).x());
}
else
{
vnode_iface_decl->setAttribute
(XStr("component_id").x(), XStr("loopback").x());
vnode_iface_decl->setAttribute (XStr("component_id").x(),
XStr("loopback").x());
}
}
......@@ -446,25 +437,26 @@ void annotate_rspec::copy_component_spec(const DOMElement* src, DOMElement* dst)
{
if (src->hasAttribute (XStr("component_name").x()))
dst->setAttribute (XStr("component_name").x(),
XStr(src->getAttribute
(XStr("component_name").x())).x());
XStr(src->getAttribute
(XStr("component_name").x())).x());
dst->setAttribute (XStr("component_uuid").x(),
XStr(src->getAttribute(XStr("component_uuid").x())).x());
XStr(src->getAttribute(XStr("component_uuid").x())).x());
dst->setAttribute (XStr("component_manager_uuid").x(),
XStr(src->getAttribute
(XStr("component_manager_uuid").x())).x());
XStr(src->getAttribute
(XStr("component_manager_uuid").x())).x());
}
// If the interface belongs to an end point of the link,
// and additional virtual_id attribute has to be added to it
void annotate_rspec::set_interface_as_link_endpoint
(DOMElement* interface, const char* virtual_node_id,
const char* virtual_interface_id)
void
annotate_rspec::set_interface_as_link_endpoint (DOMElement* interface,
const char* virtual_node_id,
const char* virtual_iface_id)
{
interface->setAttribute(XStr("virtual_node_id").x(),
XStr(virtual_node_id).x());
XStr(virtual_node_id).x());
interface->setAttribute(XStr("virtual_interface_id").x(),
XStr(virtual_interface_id).x());
XStr(virtual_iface_id).x());
}
// Finds the next link in the path returned by assign
......@@ -472,22 +464,21 @@ void annotate_rspec::set_interface_as_link_endpoint
// from the source to destination,
// so you need to look at the entire path to find the next link
DOMElement* annotate_rspec::find_next_link_in_path (DOMElement *prev,
list<const char*>* links)
list<const char*>* links)
{
list<const char*>::iterator it;
DOMElement* link = NULL;
for (it = links->begin(); it != links->end(); ++it)
{
link = (this->physical_elements->find(*it))->second;
XStr link_src(find_urn(getNthInterface(link,0),
"component_node"));
XStr link_dst(find_urn(getNthInterface(link,1),
"component_node"));
XStr prev_dst(find_urn(getNthInterface(prev,1),
"component_node"));
if (strcmp(link_src.c(), prev_dst.c()) == 0
|| strcmp(link_dst.c(), prev_dst.c()) == 0)
{
string link_src = XStr(find_urn(getNthInterface(link,0),
"component_node")).c();
string link_dst = XStr(find_urn(getNthInterface(link,1),
"component_node")).c();
string prev_dst = XStr(find_urn(getNthInterface(prev,1),
"component_node")).c();
if ((link_src == prev_dst) || (link_dst == prev_dst)) {
links->remove(*it);
break;
}
......@@ -503,8 +494,7 @@ void annotate_rspec::cleanup()
vector<DOMElement*> generated_links
= getElementsHavingAttribute(this->virtual_root, "link",
"generated_by_assign");
for (it = generated_links.begin(); it < generated_links.end(); it++)
{
for (it = generated_links.begin(); it < generated_links.end(); it++) {
DOMNode* generated_link = dynamic_cast<DOMNode*>(*it);
dynamic_cast<DOMNode*>(this->virtual_root)->removeChild(generated_link);
}
......
......@@ -44,6 +44,7 @@ annotate_rspec_v2 :: annotate_rspec_v2 ()
{
this->document = doc;
this->virtual_root = request_root;
// this->virtual_root = dynamic_cast<DOMElement*>(dynamic_cast<DOMNode*>(request_root)->cloneNode(true));
this->physical_root = advt_root;
this->physical_elements = advertisement_elements;
......@@ -64,7 +65,7 @@ annotate_rspec_v2 :: annotate_rspec_v2 ()
set<string> virtual_interface_ids;
DOMNodeList* interfaces
= lan_link->getElementsByTagName(XStr("interface_ref").x());
for (int j = 0; j < interfaces->getLength(); j++) {
for (unsigned int j = 0; j < interfaces->getLength(); j++) {
DOMElement* interface = dynamic_cast<DOMElement*>(interfaces->item(j));
virtual_interface_ids.insert
(string(XStr(interface->getAttribute
......@@ -86,8 +87,8 @@ void annotate_rspec_v2::annotate_element (const char* v_name)
"link", "client_id", v_name);
annotate_interface (vlink, 0);
annotate_interface (vlink, 1);
DOMElement* hop = create_component_hop(vlink);
#ifndef DISABLE_LINK_ANNOTATION
DOMElement* hop = create_component_hop(vlink);
vlink->appendChild(hop);
#endif
}
......@@ -156,7 +157,7 @@ annotate_rspec_v2::annotate_element (const char* v_name, const char* p_name)
// This is called when an intraswitch or interswitch link has to be annotated
void annotate_rspec_v2::annotate_element (const char* v_name,
list<const char*>* links)
list<const char*>* links)
{
// We can't locate interfaces on the switches, so we don't add those
// to the annotation. The warning is only given the one time
......@@ -227,13 +228,6 @@ DOMElement* annotate_rspec_v2::create_component_hop (DOMElement* vlink)
string srcIfaceNodeId =this->lookupIface(this->vInterfaceMap,srcIfaceId,fnd);
string dstIfaceNodeId =this->lookupIface(this->vInterfaceMap,dstIfaceId,fnd);
DOMElement* srcVnode
= getElementByAttributeValue(this->virtual_root,
"node", "client_id", srcIfaceNodeId.c_str());
DOMElement* dstVnode
= getElementByAttributeValue(this->virtual_root,
"node", "client_id", dstIfaceNodeId.c_str());
DOMElement* srcIfaceClone
= dynamic_cast<DOMElement*>(doc->importNode
(dynamic_cast<DOMNode*>(srcIface),true));
......@@ -379,7 +373,7 @@ void annotate_rspec_v2::copy_component_hop(DOMElement* lan_link,
= string(XStr(lan_link->getAttribute(XStr("client_id").x())).c());
DOMNodeList* interfaces
= component_hop->getElementsByTagName(XStr("interface_ref").x());
for (int i = 0; i < interfaces->getLength(); i++) {
for (unsigned int i = 0; i < interfaces->getLength(); i++) {
DOMElement* interface = dynamic_cast<DOMElement*>(interfaces->item(i));
if (interface->hasAttribute(XStr("virtual_interface_id").x())) {
string str_virtual_interface_id
......@@ -621,12 +615,11 @@ string annotate_rspec_v2::getNodeForNthInterface (const DOMElement* link,
DOMNodeList* ifaces = link->getElementsByTagName(XStr("interface_ref").x());
if (ifaces->getLength() < number) {
cerr << "*** Link "
<< XStr(link->getAttribute(XStr("component_id").x())).c()
<< " has only " << ifaces->getLength() << " interfaces. "
<< "Interface number " << number << " requested." << endl;
<< XStr(link->getAttribute(XStr("component_id").x())).c()
<< " has only " << ifaces->getLength() << " interfaces. "
<< "Interface number " << number << " requested." << endl;
exit(EXIT_FATAL);
}
DOMElement* iface = dynamic_cast<DOMElement*>(ifaces->item(number));
string ifaceId = XStr(link->getAttribute(XStr("component_id").x())).c();
return (this->lookupIface(this->pInterfaceMap, ifaceId, found));
}
......
......@@ -37,7 +37,7 @@ emulab_extensions_parser::readFeaturesDesires (const DOMElement* ele, int& count
vector<struct fd> fds;
DOMNodeList* fdNodes = ele->getElementsByTagName(XStr("emulab:fd").x());
count = fdNodes->getLength();
for (int i = 0; i < fdNodes->getLength(); i++) {
for (unsigned int i = 0; i < fdNodes->getLength(); i++) {
fds.push_back(this->readFeatureDesire
(dynamic_cast<DOMElement*>(fdNodes->item(i))));
}
......@@ -61,7 +61,7 @@ vector<struct property> emulab_extensions_parser::readProperties
{
DOMNodeList* propNodes = elem->getElementsByTagName(XStr("property").x());
vector<struct property> properties;
for (int i = 0; i < propNodes->getLength(); i++) {
for (unsigned int i = 0; i < propNodes->getLength(); i++) {
properties.push_back(this->readProperty
(dynamic_cast<DOMElement*>(propNodes->item(i))));
}
......@@ -102,7 +102,7 @@ emulab_extensions_parser::readVClasses (const DOMElement* elem)
DOMNodeList* vclassNodes
= elem->getElementsByTagName(XStr("emulab:vclass").x());
vector<struct vclass> vclasses;
for (int i = 0; i < vclassNodes->getLength(); i++) {
for (unsigned int i = 0; i < vclassNodes->getLength(); i++) {
vclasses.push_back(this->readVClass
(dynamic_cast<DOMElement*>
(vclassNodes->item(i))));
......@@ -116,7 +116,7 @@ emulab_extensions_parser::readVClass (const DOMElement* tag)
vector<string> physTypes;
DOMNodeList* physNodes
= tag->getElementsByTagName(XStr("emulab:physical_type").x());
for (int i = 0; i < physNodes->getLength(); i++) {
for (unsigned int i = 0; i < physNodes->getLength(); i++) {
DOMElement* physNode = dynamic_cast<DOMElement*>(physNodes->item(i));
// XXX: This is nasty because the type name that we give assign
// has to be the concatation of the hardware type and sliver type
......
......@@ -149,7 +149,6 @@ int parse_advertisement(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
}
XMLDEBUG("Found rspec ver. " << rspecVersion << endl);
bool is_physical;
string type = XStr(advt_root->getAttribute(XStr("type").x())).c();
if (type != "advertisement") {
cout << "*** Rspec type must be \"advertisement\" in " << filename
......@@ -215,7 +214,6 @@ bool populate_nodes(DOMElement *root,
XMLDEBUG("Found " << nodeCount << " nodes in rspec" << endl);
int availableCount = 0;
int counter = 0;
for (size_t i = 0; i < nodeCount; i++) {
DOMNode *node = nodes->item(i);
// This should not be able to fail, because all elements in
......@@ -273,7 +271,6 @@ bool populate_nodes(DOMElement *root,
int typeCount;
vector<struct node_type>types = rspecParser->readNodeTypes(elt, typeCount);
bool switchAdded = false;
for (int i = 0; i < typeCount; i++) {
node_type type = types[i];
string typeName = type.typeName;
......
......@@ -288,7 +288,6 @@ bool populate_node(DOMElement* elt,
ptypes[typeName_c] = new tb_ptype(typeName_c);
}
ptypes[typeName_c]->add_slots(typeSlots);
tb_ptype *ptype = ptypes[typeName_c];
name_vclass_map::iterator dit = vclass_map.find(fstring(typeName.c_str()));
if (dit != vclass_map.end()) {
......@@ -537,8 +536,8 @@ bool populate_link (DOMElement* elt,
list<DOMElement*>::iterator it = links.begin();
for (int i = 0; i < ifaceCount; ++i) {
link_interface interface = interfaces[i];
const XMLCh* virtualIfaceId = XStr(interface.virtualIfaceId.c_str()).x();
const XMLCh* virtualNodeId = XStr(interface.virtualNodeId.c_str()).x();
string virtualIfaceId = XStr(interface.virtualIfaceId.c_str()).c();
string virtualNodeId = XStr(interface.virtualNodeId.c_str()).c();
string str_lan_interface_id = generate_virtualIfaceId(str_lan_id, i);
DOMElement* lan_interface = doc->createElement(XStr("interface").x());
......@@ -550,8 +549,8 @@ bool populate_link (DOMElement* elt,
DOMElement* link = doc->createElement(XStr("link").x());
request_root->appendChild(link);
link->setAttribute(XStr("virtual_id").x(),
XStr(interface.virtualNodeId
+ string(":") + str_lan_id).x());
XStr(interface.virtualNodeId
+ string(":") + str_lan_id).x());
appendChildTagWithData(link, "bandwidth",
rspecParser->numToString(bandwidth).c_str());
appendChildTagWithData(link, "latency",
......@@ -560,23 +559,23 @@ bool populate_link (DOMElement* elt,
rspecParser->numToString(packetLoss).c_str());
DOMElement* src_interface_ref
= doc->createElement(XStr("interface_ref").x());
= doc->createElement(XStr("interface_ref").x());
src_interface_ref->setAttribute(XStr("clientId").x(),
virtualIfaceId);
XStr(virtualIfaceId.c_str()).x());
link->appendChild(src_interface_ref);
DOMElement* dst_interface_ref
= doc->createElement(XStr("interface_ref").x());
= doc->createElement(XStr("interface_ref").x());
dst_interface_ref->setAttribute(XStr("clientId").x(),
XStr(str_lan_interface_id.c_str()).x());
XStr(str_lan_interface_id.c_str()).x());
link->appendChild(dst_interface_ref);
// Adding attributes to ensure that the element is handled
// correctly during annotation.
link->setAttribute(XStr("generated_by_assign").x(),
XStr("true").x());
XStr("true").x());
link->setAttribute(XStr("lan_link").x(),
XStr(virtualId.c_str()).x());
XStr(virtualId.c_str()).x());
links.insert(it, link);
}
......@@ -780,7 +779,7 @@ DOMElement* appendChildTagWithData (DOMElement* parent,
string generate_virtualNodeId (string virtual_id)
{
std::ostringstream oss;
ostringstream oss;
struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
......@@ -790,7 +789,7 @@ string generate_virtualNodeId (string virtual_id)
string generate_virtualIfaceId (string lan_name, int interface_number)
{
std::ostringstream oss;
ostringstream oss;
oss << lan_name << ":" << interface_number;
return oss.str();
}
......
......@@ -33,7 +33,6 @@ rspec_parser :: ~rspec_parser ()
struct link_interface rspec_parser :: getIface (const DOMElement* tag)
{
bool exists;
struct link_interface rv =
{
string(XStr(tag->getAttribute(XStr("virtual_node_id").x())).c()),
......@@ -109,7 +108,7 @@ vector<struct node_type> rspec_parser::readNodeTypes (const DOMElement* node,
bool isSwitch = false;
DOMNodeList* nodeTypes = node->getElementsByTagName(XStr("node_type").x());
vector<struct node_type> types;
for (int i = 0; i < nodeTypes->getLength(); i++) {
for (unsigned int i = 0; i < nodeTypes->getLength(); i++) {
DOMElement *tag = dynamic_cast<DOMElement*>(nodeTypes->item(i));
string typeName = XStr(tag->getAttribute(XStr("type_name").x())).c();
......@@ -143,32 +142,32 @@ rspec_parser::readInterfacesOnNode (const DOMElement* node,
DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x());
map< pair<string, string>, pair<string, string> > fixedInterfaces;
allUnique = true;
for (int i = 0; i < ifaces->getLength(); i++)
for (unsigned int i = 0; i < ifaces->getLength(); i++)
{
DOMElement* iface = dynamic_cast<DOMElement*>(ifaces->item(i));
bool hasAttr;
string nodeId = "";
string ifaceId = "";
if (this->rspecType == RSPEC_TYPE_ADVT) {
nodeId = this->readPhysicalId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("component_id").x())).c();
nodeId = this->readPhysicalId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("component_id").x())).c();
}
else { //(this->rspecType == RSPEC_TYPE_REQ)
nodeId = this->readVirtualId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("client_id").x())).c();
if (iface->hasAttribute(XStr("component_id").x())) {
bool hasComponentId;
string componentNodeId =
this->readPhysicalId (node, hasComponentId);
string componentIfaceId =
this->getAttribute(iface, "component_id");
fixedInterfaces.insert (make_pair
(make_pair(nodeId,ifaceId),
make_pair(componentNodeId,componentIfaceId)));
}
nodeId = this->readVirtualId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("client_id").x())).c();
if (iface->hasAttribute(XStr("component_id").x())) {
bool hasComponentId;
string componentNodeId =
this->readPhysicalId (node, hasComponentId);
string componentIfaceId =
this->getAttribute(iface, "component_id");
fixedInterfaces.insert (make_pair
(make_pair(nodeId,ifaceId),
make_pair(componentNodeId,componentIfaceId)));
}
}
allUnique &= ((this->ifacesSeen).insert
(pair<string, string>(nodeId, ifaceId))).second;
(pair<string, string>(nodeId, ifaceId))).second;
}
return (fixedInterfaces);
}
......@@ -177,9 +176,9 @@ rspec_parser::readInterfacesOnNode (const DOMElement* node,
// count should be 1 on success.
struct link_characteristics
rspec_parser :: readLinkCharacteristics (const DOMElement* link,
int& count,
int defaultBandwidth,
int unlimitedBandwidth)
int& count,
int defaultBandwidth,
int unlimitedBandwidth)
{
bool hasBandwidth, hasLatency, hasPacketLoss;
string strBw = this->readChild(link, "bandwidth", hasBandwidth);
......@@ -253,7 +252,7 @@ vector<struct link_type> rspec_parser::readLinkTypes (const DOMElement* link,
{
DOMNodeList* linkTypes = link->getElementsByTagName(XStr("link_type").x());
vector<struct link_type> types;
for (int i = 0; i < linkTypes->getLength(); i++) {
for (unsigned int i = 0; i < linkTypes->getLength(); i++) {
DOMElement *tag = dynamic_cast<DOMElement*>(linkTypes->item(i));
string name = XStr(tag->getAttribute(XStr("name").x())).c();
......
......@@ -136,41 +136,40 @@ map< pair<string, string>, pair<string, string> >
rspec_parser_v1::readInterfacesOnNode (const DOMElement* node,
bool& allUnique)
{
bool exists;
DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x());
map< pair<string, string>, pair<string, string> > fixedInterfaces;