[openib-general] [PATCH] Diags/ibnetdiscover: More changes for IB routers

Hal Rosenstock halr at voltaire.com
Mon Oct 16 10:44:50 PDT 2006


Diags/ibnetdiscover: More changes for IB routers

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: src/ibnetdiscover.c
===================================================================
--- src/ibnetdiscover.c	(revision 9827)
+++ src/ibnetdiscover.c	(working copy)
@@ -461,14 +461,30 @@ node_name(Node *node)
 void
 list_node(Node *node)
 {
+	char *node_type;
+
+	switch(node->type) {
+	case SWITCH_NODE:
+		node_type = "Switch";
+		break;
+	case CA_NODE:
+		node_type = "Ca";
+		break;
+	case ROUTER_NODE:
+		node_type = "Router";
+		break;
+	default:
+		node_type = "???";
+		break;
+	}
 #if __WORDSIZE == 64
 	fprintf(f, "%s\t : 0x%016lx ports %d devid 0x%x vendid 0x%x \"%s\"\n",
-		node->type == SWITCH_NODE ? "Switch" : "Ca",
+		node_type,
 		node->nodeguid, node->numports, node->devid, node->vendid,
 		clean_nodedesc(node->nodedesc));
 #else
 	fprintf(f, "%s\t : 0x%016Lx ports %d devid 0x%x vendid 0x%x \"%s\"\n",
-		node->type == SWITCH_NODE ? "Switch" : "Ca",
+		node_type,
 		node->nodeguid, node->numports, node->devid, node->vendid,
 		clean_nodedesc(node->nodedesc));
 #endif
@@ -558,14 +574,31 @@ out_switch(Node *node, int group)
 void
 out_ca(Node *node)
 {
+	char *node_type;
+	char *node_type2;
+
 	out_ids(node);
+	switch(node->type) {
+	case CA_NODE:
+		node_type = "ca";
+		node_type2 = "Ca";
+		break;
+	case ROUTER_NODE:
+		node_type = "router";
+		node_type2 = "Router";
+		break;
+	default:
+		node_type = "???";
+		node_type2 = "???";
+		break;
+	}
 #if __WORDSIZE == 64
-	fprintf(f, "%s=0x%lx\n", "caguid", node->nodeguid);
+	fprintf(f, "%s%s=0x%lx\n", node_type, "guid", node->nodeguid);
 #else
-	fprintf(f, "%s=0x%Lx\n", "caguid", node->nodeguid);
+	fprintf(f, "%s%s=0x%Lx\n", node_type, "guid", node->nodeguid);
 #endif
 	fprintf(f, "%s\t%d %s\t\t# %s\n",
-		"Ca", node->numports, node_name(node),
+		node_type2, node->numports, node_name(node),
 		clean_nodedesc(node->nodedesc));
 }
 
Index: include/ibnetdiscover.h
===================================================================
--- include/ibnetdiscover.h	(revision 9827)
+++ include/ibnetdiscover.h	(working copy)
@@ -38,6 +38,7 @@
 #define MAXHOPS	63
 #define CA_NODE		1
 #define SWITCH_NODE	2
+#define ROUTER_NODE	3
 
 /* Vendor IDs (for chassis based systems) */
 #define VTR_VENDOR_ID			0x8f1	/* Voltaire */







More information about the general mailing list