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
This diff is collapsed.
...@@ -44,6 +44,7 @@ annotate_rspec_v2 :: annotate_rspec_v2 () ...@@ -44,6 +44,7 @@ annotate_rspec_v2 :: annotate_rspec_v2 ()
{ {
this->document = doc; this->document = doc;
this->virtual_root = request_root; 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_root = advt_root;
this->physical_elements = advertisement_elements; this->physical_elements = advertisement_elements;
...@@ -64,7 +65,7 @@ annotate_rspec_v2 :: annotate_rspec_v2 () ...@@ -64,7 +65,7 @@ annotate_rspec_v2 :: annotate_rspec_v2 ()
set<string> virtual_interface_ids; set<string> virtual_interface_ids;
DOMNodeList* interfaces DOMNodeList* interfaces
= lan_link->getElementsByTagName(XStr("interface_ref").x()); = 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)); DOMElement* interface = dynamic_cast<DOMElement*>(interfaces->item(j));
virtual_interface_ids.insert virtual_interface_ids.insert
(string(XStr(interface->getAttribute (string(XStr(interface->getAttribute
...@@ -86,8 +87,8 @@ void annotate_rspec_v2::annotate_element (const char* v_name) ...@@ -86,8 +87,8 @@ void annotate_rspec_v2::annotate_element (const char* v_name)
"link", "client_id", v_name); "link", "client_id", v_name);
annotate_interface (vlink, 0); annotate_interface (vlink, 0);
annotate_interface (vlink, 1); annotate_interface (vlink, 1);
DOMElement* hop = create_component_hop(vlink);
#ifndef DISABLE_LINK_ANNOTATION #ifndef DISABLE_LINK_ANNOTATION
DOMElement* hop = create_component_hop(vlink);
vlink->appendChild(hop); vlink->appendChild(hop);
#endif #endif
} }
...@@ -156,7 +157,7 @@ annotate_rspec_v2::annotate_element (const char* v_name, const char* p_name) ...@@ -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 // This is called when an intraswitch or interswitch link has to be annotated
void annotate_rspec_v2::annotate_element (const char* v_name, 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 // 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 // to the annotation. The warning is only given the one time
...@@ -227,13 +228,6 @@ DOMElement* annotate_rspec_v2::create_component_hop (DOMElement* vlink) ...@@ -227,13 +228,6 @@ DOMElement* annotate_rspec_v2::create_component_hop (DOMElement* vlink)
string srcIfaceNodeId =this->lookupIface(this->vInterfaceMap,srcIfaceId,fnd); string srcIfaceNodeId =this->lookupIface(this->vInterfaceMap,srcIfaceId,fnd);
string dstIfaceNodeId =this->lookupIface(this->vInterfaceMap,dstIfaceId,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 DOMElement* srcIfaceClone
= dynamic_cast<DOMElement*>(doc->importNode = dynamic_cast<DOMElement*>(doc->importNode
(dynamic_cast<DOMNode*>(srcIface),true)); (dynamic_cast<DOMNode*>(srcIface),true));
...@@ -379,7 +373,7 @@ void annotate_rspec_v2::copy_component_hop(DOMElement* lan_link, ...@@ -379,7 +373,7 @@ void annotate_rspec_v2::copy_component_hop(DOMElement* lan_link,
= string(XStr(lan_link->getAttribute(XStr("client_id").x())).c()); = string(XStr(lan_link->getAttribute(XStr("client_id").x())).c());
DOMNodeList* interfaces DOMNodeList* interfaces
= component_hop->getElementsByTagName(XStr("interface_ref").x()); = 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)); DOMElement* interface = dynamic_cast<DOMElement*>(interfaces->item(i));
if (interface->hasAttribute(XStr("virtual_interface_id").x())) { if (interface->hasAttribute(XStr("virtual_interface_id").x())) {
string str_virtual_interface_id string str_virtual_interface_id
...@@ -621,12 +615,11 @@ string annotate_rspec_v2::getNodeForNthInterface (const DOMElement* link, ...@@ -621,12 +615,11 @@ string annotate_rspec_v2::getNodeForNthInterface (const DOMElement* link,
DOMNodeList* ifaces = link->getElementsByTagName(XStr("interface_ref").x()); DOMNodeList* ifaces = link->getElementsByTagName(XStr("interface_ref").x());
if (ifaces->getLength() < number) { if (ifaces->getLength() < number) {
cerr << "*** Link " cerr << "*** Link "
<< XStr(link->getAttribute(XStr("component_id").x())).c() << XStr(link->getAttribute(XStr("component_id").x())).c()
<< " has only " << ifaces->getLength() << " interfaces. " << " has only " << ifaces->getLength() << " interfaces. "
<< "Interface number " << number << " requested." << endl; << "Interface number " << number << " requested." << endl;
exit(EXIT_FATAL); exit(EXIT_FATAL);
} }
DOMElement* iface = dynamic_cast<DOMElement*>(ifaces->item(number));
string ifaceId = XStr(link->getAttribute(XStr("component_id").x())).c(); string ifaceId = XStr(link->getAttribute(XStr("component_id").x())).c();
return (this->lookupIface(this->pInterfaceMap, ifaceId, found)); return (this->lookupIface(this->pInterfaceMap, ifaceId, found));
} }
......
...@@ -37,7 +37,7 @@ emulab_extensions_parser::readFeaturesDesires (const DOMElement* ele, int& count ...@@ -37,7 +37,7 @@ emulab_extensions_parser::readFeaturesDesires (const DOMElement* ele, int& count
vector<struct fd> fds; vector<struct fd> fds;
DOMNodeList* fdNodes = ele->getElementsByTagName(XStr("emulab:fd").x()); DOMNodeList* fdNodes = ele->getElementsByTagName(XStr("emulab:fd").x());
count = fdNodes->getLength(); 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 fds.push_back(this->readFeatureDesire
(dynamic_cast<DOMElement*>(fdNodes->item(i)))); (dynamic_cast<DOMElement*>(fdNodes->item(i))));
} }
...@@ -61,7 +61,7 @@ vector<struct property> emulab_extensions_parser::readProperties ...@@ -61,7 +61,7 @@ vector<struct property> emulab_extensions_parser::readProperties
{ {
DOMNodeList* propNodes = elem->getElementsByTagName(XStr("property").x()); DOMNodeList* propNodes = elem->getElementsByTagName(XStr("property").x());
vector<struct property> properties; 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 properties.push_back(this->readProperty
(dynamic_cast<DOMElement*>(propNodes->item(i)))); (dynamic_cast<DOMElement*>(propNodes->item(i))));
} }
...@@ -102,7 +102,7 @@ emulab_extensions_parser::readVClasses (const DOMElement* elem) ...@@ -102,7 +102,7 @@ emulab_extensions_parser::readVClasses (const DOMElement* elem)
DOMNodeList* vclassNodes DOMNodeList* vclassNodes
= elem->getElementsByTagName(XStr("emulab:vclass").x()); = elem->getElementsByTagName(XStr("emulab:vclass").x());
vector<struct vclass> vclasses; 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 vclasses.push_back(this->readVClass
(dynamic_cast<DOMElement*> (dynamic_cast<DOMElement*>
(vclassNodes->item(i)))); (vclassNodes->item(i))));
...@@ -116,7 +116,7 @@ emulab_extensions_parser::readVClass (const DOMElement* tag) ...@@ -116,7 +116,7 @@ emulab_extensions_parser::readVClass (const DOMElement* tag)
vector<string> physTypes; vector<string> physTypes;
DOMNodeList* physNodes DOMNodeList* physNodes
= tag->getElementsByTagName(XStr("emulab:physical_type").x()); = 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)); DOMElement* physNode = dynamic_cast<DOMElement*>(physNodes->item(i));
// XXX: This is nasty because the type name that we give assign // XXX: This is nasty because the type name that we give assign
// has to be the concatation of the hardware type and sliver type // 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) { ...@@ -149,7 +149,6 @@ int parse_advertisement(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
} }
XMLDEBUG("Found rspec ver. " << rspecVersion << endl); XMLDEBUG("Found rspec ver. " << rspecVersion << endl);
bool is_physical;
string type = XStr(advt_root->getAttribute(XStr("type").x())).c(); string type = XStr(advt_root->getAttribute(XStr("type").x())).c();
if (type != "advertisement") { if (type != "advertisement") {
cout << "*** Rspec type must be \"advertisement\" in " << filename cout << "*** Rspec type must be \"advertisement\" in " << filename
...@@ -215,7 +214,6 @@ bool populate_nodes(DOMElement *root, ...@@ -215,7 +214,6 @@ bool populate_nodes(DOMElement *root,
XMLDEBUG("Found " << nodeCount << " nodes in rspec" << endl); XMLDEBUG("Found " << nodeCount << " nodes in rspec" << endl);
int availableCount = 0; int availableCount = 0;
int counter = 0;
for (size_t i = 0; i < nodeCount; i++) { for (size_t i = 0; i < nodeCount; i++) {
DOMNode *node = nodes->item(i); DOMNode *node = nodes->item(i);
// This should not be able to fail, because all elements in // This should not be able to fail, because all elements in
...@@ -273,7 +271,6 @@ bool populate_nodes(DOMElement *root, ...@@ -273,7 +271,6 @@ bool populate_nodes(DOMElement *root,
int typeCount; int typeCount;
vector<struct node_type>types = rspecParser->readNodeTypes(elt, typeCount); vector<struct node_type>types = rspecParser->readNodeTypes(elt, typeCount);
bool switchAdded = false;
for (int i = 0; i < typeCount; i++) { for (int i = 0; i < typeCount; i++) {
node_type type = types[i]; node_type type = types[i];
string typeName = type.typeName; string typeName = type.typeName;
......
...@@ -288,7 +288,6 @@ bool populate_node(DOMElement* elt, ...@@ -288,7 +288,6 @@ bool populate_node(DOMElement* elt,
ptypes[typeName_c] = new tb_ptype(typeName_c); ptypes[typeName_c] = new tb_ptype(typeName_c);
} }
ptypes[typeName_c]->add_slots(typeSlots); ptypes[typeName_c]->add_slots(typeSlots);
tb_ptype *ptype = ptypes[typeName_c];
name_vclass_map::iterator dit = vclass_map.find(fstring(typeName.c_str())); name_vclass_map::iterator dit = vclass_map.find(fstring(typeName.c_str()));
if (dit != vclass_map.end()) { if (dit != vclass_map.end()) {
...@@ -537,8 +536,8 @@ bool populate_link (DOMElement* elt, ...@@ -537,8 +536,8 @@ bool populate_link (DOMElement* elt,
list<DOMElement*>::iterator it = links.begin(); list<DOMElement*>::iterator it = links.begin();
for (int i = 0; i < ifaceCount; ++i) { for (int i = 0; i < ifaceCount; ++i) {
link_interface interface = interfaces[i]; link_interface interface = interfaces[i];
const XMLCh* virtualIfaceId = XStr(interface.virtualIfaceId.c_str()).x(); string virtualIfaceId = XStr(interface.virtualIfaceId.c_str()).c();
const XMLCh* virtualNodeId = XStr(interface.virtualNodeId.c_str()).x(); string virtualNodeId = XStr(interface.virtualNodeId.c_str()).c();
string str_lan_interface_id = generate_virtualIfaceId(str_lan_id, i); string str_lan_interface_id = generate_virtualIfaceId(str_lan_id, i);
DOMElement* lan_interface = doc->createElement(XStr("interface").x()); DOMElement* lan_interface = doc->createElement(XStr("interface").x());
...@@ -550,8 +549,8 @@ bool populate_link (DOMElement* elt, ...@@ -550,8 +549,8 @@ bool populate_link (DOMElement* elt,
DOMElement* link = doc->createElement(XStr("link").x()); DOMElement* link = doc->createElement(XStr("link").x());
request_root->appendChild(link); request_root->appendChild(link);
link->setAttribute(XStr("virtual_id").x(), link->setAttribute(XStr("virtual_id").x(),
XStr(interface.virtualNodeId XStr(interface.virtualNodeId
+ string(":") + str_lan_id).x()); + string(":") + str_lan_id).x());
appendChildTagWithData(link, "bandwidth", appendChildTagWithData(link, "bandwidth",
rspecParser->numToString(bandwidth).c_str()); rspecParser->numToString(bandwidth).c_str());
appendChildTagWithData(link, "latency", appendChildTagWithData(link, "latency",
...@@ -560,23 +559,23 @@ bool populate_link (DOMElement* elt, ...@@ -560,23 +559,23 @@ bool populate_link (DOMElement* elt,
rspecParser->numToString(packetLoss).c_str()); rspecParser->numToString(packetLoss).c_str());
DOMElement* src_interface_ref DOMElement* src_interface_ref
= doc->createElement(XStr("interface_ref").x()); = doc->createElement(XStr("interface_ref").x());
src_interface_ref->setAttribute(XStr("clientId").x(), src_interface_ref->setAttribute(XStr("clientId").x(),
virtualIfaceId); XStr(virtualIfaceId.c_str()).x());
link->appendChild(src_interface_ref); link->appendChild(src_interface_ref);
DOMElement* dst_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(), 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); link->appendChild(dst_interface_ref);
// Adding attributes to ensure that the element is handled // Adding attributes to ensure that the element is handled
// correctly during annotation. // correctly during annotation.
link->setAttribute(XStr("generated_by_assign").x(), link->setAttribute(XStr("generated_by_assign").x(),
XStr("true").x()); XStr("true").x());
link->setAttribute(XStr("lan_link").x(), link->setAttribute(XStr("lan_link").x(),
XStr(virtualId.c_str()).x()); XStr(virtualId.c_str()).x());
links.insert(it, link); links.insert(it, link);
} }
...@@ -780,7 +779,7 @@ DOMElement* appendChildTagWithData (DOMElement* parent, ...@@ -780,7 +779,7 @@ DOMElement* appendChildTagWithData (DOMElement* parent,
string generate_virtualNodeId (string virtual_id) string generate_virtualNodeId (string virtual_id)
{ {
std::ostringstream oss; ostringstream oss;
struct timeval tv; struct timeval tv;
struct timezone tz; struct timezone tz;
gettimeofday(&tv, &tz); gettimeofday(&tv, &tz);
...@@ -790,7 +789,7 @@ string generate_virtualNodeId (string virtual_id) ...@@ -790,7 +789,7 @@ string generate_virtualNodeId (string virtual_id)
string generate_virtualIfaceId (string lan_name, int interface_number) string generate_virtualIfaceId (string lan_name, int interface_number)
{ {
std::ostringstream oss; ostringstream oss;
oss << lan_name << ":" << interface_number; oss << lan_name << ":" << interface_number;
return oss.str(); return oss.str();
} }
......
...@@ -33,7 +33,6 @@ rspec_parser :: ~rspec_parser () ...@@ -33,7 +33,6 @@ rspec_parser :: ~rspec_parser ()
struct link_interface rspec_parser :: getIface (const DOMElement* tag) struct link_interface rspec_parser :: getIface (const DOMElement* tag)
{ {
bool exists;
struct link_interface rv = struct link_interface rv =
{ {
string(XStr(tag->getAttribute(XStr("virtual_node_id").x())).c()), string(XStr(tag->getAttribute(XStr("virtual_node_id").x())).c()),
...@@ -109,7 +108,7 @@ vector<struct node_type> rspec_parser::readNodeTypes (const DOMElement* node, ...@@ -109,7 +108,7 @@ vector<struct node_type> rspec_parser::readNodeTypes (const DOMElement* node,
bool isSwitch = false; bool isSwitch = false;
DOMNodeList* nodeTypes = node->getElementsByTagName(XStr("node_type").x()); DOMNodeList* nodeTypes = node->getElementsByTagName(XStr("node_type").x());
vector<struct node_type> types; 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)); DOMElement *tag = dynamic_cast<DOMElement*>(nodeTypes->item(i));
string typeName = XStr(tag->getAttribute(XStr("type_name").x())).c(); string typeName = XStr(tag->getAttribute(XStr("type_name").x())).c();
...@@ -143,32 +142,32 @@ rspec_parser::readInterfacesOnNode (const DOMElement* node, ...@@ -143,32 +142,32 @@ rspec_parser::readInterfacesOnNode (const DOMElement* node,
DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x()); DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x());
map< pair<string, string>, pair<string, string> > fixedInterfaces; map< pair<string, string>, pair<string, string> > fixedInterfaces;
allUnique = true; 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)); DOMElement* iface = dynamic_cast<DOMElement*>(ifaces->item(i));
bool hasAttr; bool hasAttr;
string nodeId = ""; string nodeId = "";
string ifaceId = ""; string ifaceId = "";
if (this->rspecType == RSPEC_TYPE_ADVT) { if (this->rspecType == RSPEC_TYPE_ADVT) {
nodeId = this->readPhysicalId (node, hasAttr); nodeId = this->readPhysicalId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("component_id").x())).c(); ifaceId = XStr(iface->getAttribute(XStr("component_id").x())).c();
} }
else { //(this->rspecType == RSPEC_TYPE_REQ) else { //(this->rspecType == RSPEC_TYPE_REQ)
nodeId = this->readVirtualId (node, hasAttr); nodeId = this->readVirtualId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("client_id").x())).c(); ifaceId = XStr(iface->getAttribute(XStr("client_id").x())).c();
if (iface->hasAttribute(XStr("component_id").x())) { if (iface->hasAttribute(XStr("component_id").x())) {
bool hasComponentId; bool hasComponentId;
string componentNodeId = string componentNodeId =
this->readPhysicalId (node, hasComponentId); this->readPhysicalId (node, hasComponentId);
string componentIfaceId = string componentIfaceId =
this->getAttribute(iface, "component_id"); this->getAttribute(iface, "component_id");
fixedInterfaces.insert (make_pair fixedInterfaces.insert (make_pair
(make_pair(nodeId,ifaceId), (make_pair(nodeId,ifaceId),
make_pair(componentNodeId,componentIfaceId))); make_pair(componentNodeId,componentIfaceId)));
} }
} }
allUnique &= ((this->ifacesSeen).insert allUnique &= ((this->ifacesSeen).insert
(pair<string, string>(nodeId, ifaceId))).second; (pair<string, string>(nodeId, ifaceId))).second;
} }
return (fixedInterfaces); return (fixedInterfaces);
} }
...@@ -177,9 +176,9 @@ rspec_parser::readInterfacesOnNode (const DOMElement* node, ...@@ -177,9 +176,9 @@ rspec_parser::readInterfacesOnNode (const DOMElement* node,
// count should be 1 on success. // count should be 1 on success.
struct link_characteristics struct link_characteristics
rspec_parser :: readLinkCharacteristics (const DOMElement* link, rspec_parser :: readLinkCharacteristics (const DOMElement* link,
int& count, int& count,
int defaultBandwidth, int defaultBandwidth,
int unlimitedBandwidth) int unlimitedBandwidth)
{ {
bool hasBandwidth, hasLatency, hasPacketLoss; bool hasBandwidth, hasLatency, hasPacketLoss;
string strBw = this->readChild(link, "bandwidth", hasBandwidth); string strBw = this->readChild(link, "bandwidth", hasBandwidth);
...@@ -253,7 +252,7 @@ vector<struct link_type> rspec_parser::readLinkTypes (const DOMElement* link, ...@@ -253,7 +252,7 @@ vector<struct link_type> rspec_parser::readLinkTypes (const DOMElement* link,
{ {
DOMNodeList* linkTypes = link->getElementsByTagName(XStr("link_type").x()); DOMNodeList* linkTypes = link->getElementsByTagName(XStr("link_type").x());
vector<struct link_type> types; 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)); DOMElement *tag = dynamic_cast<DOMElement*>(linkTypes->item(i));
string name = XStr(tag->getAttribute(XStr("name").x())).c(); string name = XStr(tag->getAttribute(XStr("name").x())).c();
......
...@@ -136,41 +136,40 @@ map< pair<string, string>, pair<string, string> > ...@@ -136,41 +136,40 @@ map< pair<string, string>, pair<string, string> >
rspec_parser_v1::readInterfacesOnNode (const DOMElement* node, rspec_parser_v1::readInterfacesOnNode (const DOMElement* node,
bool& allUnique) bool& allUnique)
{ {
bool exists;
DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x()); DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x());
map< pair<string, string>, pair<string, string> > fixedInterfaces; map< pair<string, string>, pair<string, string> > fixedInterfaces;
allUnique = true; 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)); DOMElement* iface = dynamic_cast<DOMElement*>(ifaces->item(i));
bool hasAttr; bool hasAttr;
string nodeId = ""; string nodeId = "";
string ifaceId = ""; string ifaceId = "";
if (this->rspecType == RSPEC_TYPE_ADVT) { if (this->rspecType == RSPEC_TYPE_ADVT) {
nodeId = this->readPhysicalId (node, hasAttr); nodeId = this->readPhysicalId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("component_id").x())).c(); ifaceId = XStr(iface->getAttribute(XStr("component_id").x())).c();
} }
else { //(this->rspecType == RSPEC_TYPE_REQ) else { //(this->rspecType == RSPEC_TYPE_REQ)
nodeId = this->readVirtualId (node, hasAttr); nodeId = this->readVirtualId (node, hasAttr);
ifaceId = XStr(iface->getAttribute(XStr("virtual_id").x())).c(); ifaceId = XStr(iface->getAttribute(XStr("virtual_id").x())).c();
if (iface->hasAttribute(XStr("component_id").x())) { if (iface->hasAttribute(XStr("component_id").x())) {
bool hasComponentId; bool hasComponentId;
string componentNodeId = this->readPhysicalId (node, hasComponentId); string componentNodeId = this->readPhysicalId (node, hasComponentId);
string componentIfaceId = this->getAttribute(iface, "component_id"); string componentIfaceId = this->getAttribute(iface, "component_id");
fixedInterfaces.insert (make_pair fixedInterfaces.insert (make_pair
(make_pair(nodeId,ifaceId), (make_pair(nodeId,ifaceId),
make_pair(componentNodeId, make_pair(componentNodeId,
componentIfaceId))); componentIfaceId)));
} }
} }
//cout << "(" << nodeId << "," << ifaceId << ")" << endl; //cout << "(" << nodeId << "," << ifaceId << ")" << endl;
allUnique &= ((this->ifacesSeen).insert allUnique &= ((this->ifacesSeen).insert
(pair<string, string>(nodeId, ifaceId))).second; (pair<string, string>(nodeId, ifaceId))).second;
} }
return fixedInterfaces; return fixedInterfaces;
} }
string rspec_parser_v1 :: readSubnodeOf (const DOMElement* tag, string rspec_parser_v1 :: readSubnodeOf (const DOMElement* tag,
bool& isSubnode, bool& isSubnode,
int& count) int& count)
{ {
count = (tag->getElementsByTagName(XStr("subnode_of").x()))->getLength(); count = (tag->getElementsByTagName(XStr("subnode_of").x()))->getLength();
......
...@@ -143,7 +143,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node, ...@@ -143,7 +143,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node,
return vector<struct node_type>(); return vector<struct node_type>();
} }
for (int j = 0; j < sliverTypes->getLength(); j++) { for (unsigned int j = 0; j < sliverTypes->getLength(); j++) {
DOMElement* slNode = dynamic_cast<DOMElement*>(sliverTypes->item(j)); DOMElement* slNode = dynamic_cast<DOMElement*>(sliverTypes->item(j));
string slTypeName = this->getAttribute(slNode, "name"); string slTypeName = this->getAttribute(slNode, "name");
string typeName = this->convertType(defHw, slTypeName); string typeName = this->convertType(defHw, slTypeName);
...@@ -152,7 +152,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node, ...@@ -152,7 +152,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node,
} }
} }
for (int i = 0; i < hardwareTypes->getLength(); i++) { for (unsigned int i = 0; i < hardwareTypes->getLength(); i++) {
DOMElement* hardwareNode DOMElement* hardwareNode
= dynamic_cast<DOMElement*>(hardwareTypes->item(i)); = dynamic_cast<DOMElement*>(hardwareTypes->item(i));
...@@ -186,7 +186,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node, ...@@ -186,7 +186,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node,
types.push_back(type); types.push_back(type);
} }
for (int j = 0; j < sliverTypes->getLength(); j++) { for (unsigned int j = 0; j < sliverTypes->getLength(); j++) {
DOMElement* slNode = dynamic_cast<DOMElement*>(sliverTypes->item(j)); DOMElement* slNode = dynamic_cast<DOMElement*>(sliverTypes->item(j));
string slTypeName = this->getAttribute(slNode, "name"); string slTypeName = this->getAttribute(slNode, "name");
string typeName = this->convertType(hwTypeName, slTypeName); string typeName = this->convertType(hwTypeName, slTypeName);
...@@ -211,7 +211,7 @@ rspec_parser_v2::readInterfacesOnNode (const DOMElement* node, ...@@ -211,7 +211,7 @@ rspec_parser_v2::readInterfacesOnNode (const DOMElement* node,
DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x()); DOMNodeList* ifaces = node->getElementsByTagName(XStr("interface").x());
map< pair<string, string>, pair<string, string> > fixedInterfaces; map< pair<string, string>, pair<string, string> > fixedInterfaces;
allUnique = true; 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)); DOMElement* iface = dynamic_cast<DOMElement*>(ifaces->item(i));
bool hasAttr; bool hasAttr;
string nodeId = ""; string nodeId = "";
...@@ -261,7 +261,7 @@ rspec_parser_v2::readLinkTypes (const DOMElement* link, int& typeCount) ...@@ -261,7 +261,7 @@ rspec_parser_v2::readLinkTypes (const DOMElement* link, int& typeCount)
{ {
DOMNodeList* linkTypes = link->getElementsByTagName(XStr("link_type").x()); DOMNodeList* linkTypes = link->getElementsByTagName(XStr("link_type").x());
vector<struct link_type> types; 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)); DOMElement* tag = dynamic_cast<DOMElement*>(linkTypes->item(i));
string name = this->getAttribute(tag, "name"); string name = this->getAttribute(tag, "name");
...@@ -279,7 +279,7 @@ string rspec_parser_v2::readSubnodeOf (const DOMElement* node, ...@@ -279,7 +279,7 @@ string rspec_parser_v2::readSubnodeOf (const DOMElement* node,
int cnt = 0; int cnt = 0;
string parent = ""; string parent = "";
DOMNodeList* relations = node->getElementsByTagName(XStr("relations").x()); DOMNodeList* relations = node->getElementsByTagName(XStr("relations").x());
for (int i = 0, cnt = 0; i < relations->getLength(); i++) { for (unsigned int i = 0, cnt = 0; i < relations->getLength(); i++) {
DOMElement* relation = dynamic_cast<DOMElement*>(relations->item(0)); DOMElement* relation = dynamic_cast<DOMElement*>(relations->item(0));
string type = this->getAttribute(node, "type"); string type = this->getAttribute(node, "type");
if (type == "parent") { if (type == "parent") {
......
...@@ -82,18 +82,17 @@ void print_solution(const solution &s) { ...@@ -82,18 +82,17 @@ void print_solution(const solution &s) {
cout << "unassigned: " << vn->name << endl; cout << "unassigned: " << vn->name << endl;
} else { } else {
#ifdef WITH_XML #ifdef WITH_XML
const char* node_name = XStr(vn -> name).c(); string node_name = XStr(vn -> name).c();
const char* assigned_to string assigned_to =XStr(get(pvertex_pmap,s.get_assignment(*vit))->name).c();
= XStr (get(pvertex_pmap,s.get_assignment(*vit))->name).c() ;
if (both_inputs_rspec) { if (both_inputs_rspec) {
rspec_annotater->annotate_element(node_name, assigned_to); rspec_annotater->annotate_element(node_name.c_str(), assigned_to.c_str());
if (rspec_annotater->is_generated_element("node", if (rspec_annotater->is_generated_element("node", "virtual_id",
"virtual_id", node_name.c_str())) {
node_name))
continue; continue;
}
} }
else if (both_inputs_xml) { else if (both_inputs_xml) {
vtop_annotater->annotate_element(node_name, assigned_to); vtop_annotater->annotate_element(node_name.c_str(), assigned_to.c_str());
} }
#endif #endif
cout << vn->name << " " cout << vn->name << " "
......
...@@ -36,7 +36,7 @@ void setChildValue(const DOMElement* parent, const char* tag, const char* value) ...@@ -36,7 +36,7 @@ void setChildValue(const DOMElement* parent, const char* tag, const char* value)
DOMElement* getNodeByName (const DOMElement *root, const char* name) DOMElement* getNodeByName (const DOMElement *root, const char* name)
{ {
DOMNodeList *list = root -> getElementsByTagName(XStr("node").x()); DOMNodeList *list = root -> getElementsByTagName(XStr("node").x());
for (int i = 0; i < list -> getLength() ; ++i) for (unsigned int i = 0; i < list -> getLength() ; ++i)
{ {
DOMElement *ele = dynamic_cast<DOMElement*>(list->item(i)); DOMElement *ele = dynamic_cast<DOMElement*>(list->item(i));
if (strcmp(XStr(ele->getAttribute(XStr("name").x())).c(),name) == 0) if (strcmp(XStr(ele->getAttribute(XStr("name").x())).c(),name) == 0)
...@@ -48,7 +48,7 @@ DOMElement* getNodeByName (const DOMElement *root, const char* name) ...@@ -48,7 +48,7 @@ DOMElement* getNodeByName (const DOMElement *root, const char* name)
DOMElement* getElementByAttributeValue (const DOMElement* root, const char* tag, const char* attribute_name, const char* attribute_value) DOMElement* getElementByAttributeValue (const DOMElement* root, const char* tag, const char* attribute_name, const char* attribute_value)
{ {
DOMNodeList *list = root -> getElementsByTagName(XStr(tag).x()); DOMNodeList *list = root -> getElementsByTagName(XStr(tag).x());
for (int i = 0; i < list -> getLength() ; ++i) for (unsigned int i = 0; i < list -> getLength() ; ++i)
{ {
DOMElement *ele = dynamic_cast<DOMElement*>(list->item(i));