コード例 #1
0
static void
foreachIndexDo(FILE *f, SmiNode *smiNode, ForEachIndexFunc func, void *data)
{
    SmiNode *indexNode = NULL, *iNode;
    SmiElement *smiElement;
    
    switch (smiNode->indexkind) {
    case SMI_INDEX_INDEX:
    case SMI_INDEX_REORDER:
	indexNode = smiNode;
	break;
    case SMI_INDEX_EXPAND:	/* TODO: we have to do more work here! */
	break;
    case SMI_INDEX_AUGMENT:
    case SMI_INDEX_SPARSE:
	indexNode = smiGetRelatedNode(smiNode);
	break;
    case SMI_INDEX_UNKNOWN:
	break;
    }
    if (indexNode) {
	for (smiElement = smiGetFirstElement(indexNode);
	     smiElement; smiElement = smiGetNextElement(smiElement)) {
	    iNode = smiGetElementNode(smiElement);
	    if (iNode) {
		(func) (f, smiNode, iNode, data);
	    }
	}
    }
}
コード例 #2
0
ファイル: dump-compliance.c プロジェクト: pan0007/libsmi
static void fprintCompliance(FILE *f, SmiNode *smiNode,
			     int *typelen, int *namelen, int pass)
{
    SmiElement *smiElement;
    SmiOption *smiOption;
    SmiRefinement *smiRefinement;
    int tlen = 0, nlen = 0;

    for (smiElement = smiGetFirstElement(smiNode);
	 smiElement;
	 smiElement = smiGetNextElement(smiElement)) {
	fprintGroup(f, smiGetElementNode(smiElement), 'm',
		    (pass == 1) ? &tlen : typelen,
		    (pass == 1) ? &nlen : namelen, pass);
	if (pass == 1) {
	    if (typelen) {
		*typelen = *typelen < tlen ? tlen : *typelen;
	    }
	    if (namelen) {
		*namelen = *namelen < nlen ? nlen : *namelen;
	    }
	}
    }

    for(smiOption = smiGetFirstOption(smiNode);
	smiOption;
	smiOption = smiGetNextOption(smiOption)) {
	fprintGroup(f, smiGetOptionNode(smiOption), 'c',
		    (pass == 1) ? &tlen : typelen,
		    (pass == 1) ? &nlen : namelen, pass);
	if (pass == 1) {
	    if (typelen) {
		*typelen = *typelen < tlen ? tlen : *typelen;
	    }
	    if (namelen) {
		*namelen = *namelen < nlen ? nlen : *namelen;
	    }
	}
    }

    for (smiRefinement = smiGetFirstRefinement(smiNode);
	 smiRefinement;
	 smiRefinement = smiGetNextRefinement(smiRefinement)) {
	fprintGroup(f, smiGetRefinementNode(smiRefinement), 'r',
		    (pass == 1) ? &tlen : typelen,
		    (pass == 1) ? &nlen : namelen, pass);
	if (pass == 1) {
	    if (typelen) {
		*typelen = *typelen < tlen ? tlen : *typelen;
	    }
	    if (namelen) {
		*namelen = *namelen < nlen ? nlen : *namelen;
	    }
	}
    }
}
コード例 #3
0
ファイル: dump-xml.c プロジェクト: pan0007/libsmi
static void fprintElementList(FILE *f, int indent, const char *tag,
			      SmiElement *smiElement)
{
    SmiModule *smiModule;
    SmiNode   *smiNode;

    for (; smiElement; smiElement = smiGetNextElement(smiElement)) {
	smiNode = smiGetElementNode(smiElement);
	smiModule = smiGetNodeModule(smiNode);
	fprintSegment(f, indent, "", 0);
	fprint(f, "<%s module=\"%s\" name=\"%s\"/>\n",
	       tag, smiModule->name, smiNode->name);
    }
}
コード例 #4
0
ファイル: dump-cm.c プロジェクト: pan0007/libsmi
/*
 * adds the index to an augmenting table (row-element)
 */
static void diaPrintAugmentIndex(GraphNode *tNode)
{
    GraphEdge  *tEdge;
    SmiElement *smiElement;

    for (tEdge = graphGetFirstEdgeByNode(graph, tNode);
	 tEdge;
	 tEdge = graphGetNextEdgeByNode(graph, tEdge, tNode)) {
	if (tEdge->indexkind == SMI_INDEX_AUGMENT) {
	    for (smiElement = smiGetFirstElement(
		smiGetFirstChildNode(tEdge->startNode->smiNode));
		 smiElement;
		 smiElement = smiGetNextElement(smiElement)) {
		if (!cmpSmiNodes(tNode->smiNode, tEdge->startNode->smiNode)) {
		    diaPrintXMLAttribute(smiGetElementNode(smiElement),1);
		}
	    }
	}
    }
}
コード例 #5
0
static void fprintNotifications(FILE *f, SmiModule *smiModule)
{
    int		 i, j;
    SmiNode	 *smiNode;
    SmiElement   *smiElement;
    
    for(i = 0, smiNode = smiGetFirstNode(smiModule,
					 SMI_NODEKIND_NOTIFICATION);
	smiNode;
	smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_NOTIFICATION)) {

	if (!i && !silent) {
	    fprint(f, "//\n// NOTIFICATION DEFINITIONS\n//\n\n");
	}

	fprintSegment(f, INDENT, "", 0);
	fprint(f, "notification %s {\n", smiNode->name);

	if (smiNode->oid) {
	    fprintSegment(f, 2 * INDENT, "oid", INDENTVALUE);
	    fprint(f, "%s;\n", getOidString(smiNode, 0));
	}

	if ((smiElement = smiGetFirstElement(smiNode))) {
	    fprintSegment(f, 2 * INDENT, "objects", INDENTVALUE);
	    fprint(f, "(");
	    for (j = 0; smiElement;
		 j++, smiElement = smiGetNextElement(smiElement)) {
		if (j) {
		    fprint(f, ", ");
		}
		fprintWrapped(f, INDENTVALUE + 1,
			      smiGetElementNode(smiElement)->name);
		/* TODO: non-local name if non-local */
	    } /* TODO: empty? -> print error */
	    fprint(f, ");\n");
	}
	
	if ((smiNode->status != SMI_STATUS_CURRENT) &&
	    (smiNode->status != SMI_STATUS_UNKNOWN) &&
	    (smiNode->status != SMI_STATUS_MANDATORY) &&
	    (smiNode->status != SMI_STATUS_OPTIONAL)) {
	    fprintSegment(f, 2 * INDENT, "status", INDENTVALUE);
	    fprint(f, "%s;\n", getStringStatus(smiNode->status));
	}
	
	if (smiNode->description) {
	    fprintSegment(f, 2 * INDENT, "description", INDENTVALUE);
	    fprint(f, "\n");
	    fprintMultilineString(f, 2 * INDENT, smiNode->description);
	    fprint(f, ";\n");
	}

	if (smiNode->reference) {
	    fprintSegment(f, 2 * INDENT, "reference", INDENTVALUE);
	    fprint(f, "\n");
	    fprintMultilineString(f, 2 * INDENT, smiNode->reference);
	    fprint(f, ";\n");
	}

	fprintSegment(f, INDENT, "", 0);
	fprint(f, "};\n\n");
	i++;
    }
}
コード例 #6
0
static void fprintObjects(FILE *f, SmiModule *smiModule)
{
    int		 i, j;
    SmiNode	 *smiNode, *relatedNode;
    SmiElement   *smiElement;
    SmiType	 *smiType;
    int		 indent = 0;
    int		 lastindent = -1;
    char	 *s = NULL;
    SmiNodekind  nodekinds;

    nodekinds =  SMI_NODEKIND_NODE | SMI_NODEKIND_TABLE |
	SMI_NODEKIND_ROW | SMI_NODEKIND_COLUMN | SMI_NODEKIND_SCALAR |
	SMI_NODEKIND_CAPABILITIES;
    
    for(i = 0, smiNode = smiGetFirstNode(smiModule, nodekinds);
	smiNode; smiNode = smiGetNextNode(smiNode, nodekinds)) {

	if (smiNode->nodekind == SMI_NODEKIND_NODE) {
	    indent = 0;
	    s = "node";
	} else if (smiNode->nodekind == SMI_NODEKIND_CAPABILITIES) {
	    indent = 0;
	    s = "node";
	} else if (smiNode->nodekind == SMI_NODEKIND_TABLE) {
	    indent = 0;
	    s = "table";
	} else if (smiNode->nodekind == SMI_NODEKIND_ROW) {
	    indent = 1;
	    s = "row";
	} else if (smiNode->nodekind == SMI_NODEKIND_COLUMN) {
	    indent = 2;
	    s = "column";
	} else if (smiNode->nodekind == SMI_NODEKIND_SCALAR) {
	    indent = 0;
	    s = "scalar";
	}

	if (!i && !silent) {
	    fprint(f, "//\n// OBJECT DEFINITIONS\n//\n\n");
	}

	for (j = lastindent; j >= indent; j--) {
	    fprintSegment(f, (1 + j) * INDENT, "", 0);
	    fprint(f, "};\n");
	}
	fprint(f, "\n");
	lastindent = indent;
	
	if (smiNode->nodekind == SMI_NODEKIND_CAPABILITIES) {
	    fprintSegment(f, (1 + indent) * INDENT, "", 0);
	    fprint(f, "-- This has been an SMIv2 AGENT-CAPABILITIES node:\n");
	}
	
	fprintSegment(f, (1 + indent) * INDENT, "", 0);
	fprint(f, "%s %s {\n", s, smiNode->name);
	
	if (smiNode->oid) {
	    fprintSegment(f, (2 + indent) * INDENT, "oid", INDENTVALUE);
	    fprint(f, "%s;\n", getOidString(smiNode, 0));
	}

	smiType = smiGetNodeType(smiNode);
	if (smiType && (smiType->basetype != SMI_BASETYPE_UNKNOWN)) {
	    fprintSegment(f, (2 + indent) * INDENT, "type", INDENTVALUE);
	    if (!smiType->name) {
		/*
		 * an implicitly restricted type.
		 */
		fprint(f, "%s", getTypeString(smiType->basetype,
					      smiGetParentType(smiType)));
		fprintSubtype(f, smiType);
		fprint(f, ";\n");
	    } else {
		fprint(f, "%s;\n",
		       getTypeString(smiType->basetype, smiType));
	    }
	}

	if ((smiNode->nodekind != SMI_NODEKIND_TABLE) &&
	    (smiNode->nodekind != SMI_NODEKIND_ROW) &&
	    (smiNode->nodekind != SMI_NODEKIND_CAPABILITIES) &&
	    (smiNode->nodekind != SMI_NODEKIND_NODE)) {
	    if (smiNode->access != SMI_ACCESS_UNKNOWN) {
		fprintSegment(f, (2 + indent) * INDENT, "access", INDENTVALUE);
		fprint(f, "%s;\n", getAccessString(smiNode->access));
	    }
	}

	relatedNode = smiGetRelatedNode(smiNode);
	switch (smiNode->indexkind) {
	case SMI_INDEX_INDEX:
	    if (smiNode->implied) {
		fprintSegment(f, (2 + indent) * INDENT, "index implied",
			      INDENTVALUE);
	    } else {
		fprintSegment(f, (2 + indent) * INDENT, "index", INDENTVALUE);
	    }
	    fprint(f, "(");
	    for (j = 0, smiElement = smiGetFirstElement(smiNode); smiElement;
		 j++, smiElement = smiGetNextElement(smiElement)) {
		if (j) {
		    fprint(f, ", ");
		}
		fprintWrapped(f, INDENTVALUE + 1,
			      smiGetElementNode(smiElement)->name);
		/* TODO: non-local name if non-local */
	    } /* TODO: empty? -> print error */
	    fprint(f, ");\n");
	    break;
	case SMI_INDEX_AUGMENT:
	    if (relatedNode) {
		fprintSegment(f, (2 + indent) * INDENT, "augments",
			      INDENTVALUE);
		fprint(f, "%s;\n", relatedNode->name);
		/* TODO: non-local name if non-local */
	    } /* TODO: else print error */
	    break;
	case SMI_INDEX_REORDER:
	    if (relatedNode) {
		fprintSegment(f, (2 + indent) * INDENT, "", 0);
		fprint(f, "reorders %s", relatedNode->name);
		/* TODO: non-local name if non-local */
		if (smiNode->implied) {
		    fprint(f, " implied");
		}
		fprint(f, " (");
		for (j = 0, smiElement = smiGetFirstElement(smiNode);
		     smiElement;
		     j++, smiElement = smiGetNextElement(smiElement)) {
		    if (j) {
			fprint(f, ", ");
		    }
		    fprintWrapped(f, INDENTVALUE + 1,
				  smiGetElementNode(smiElement)->name);
		    /* TODO: non-local name if non-local */
		} /* TODO: empty? -> print error */
		fprint(f, ");\n");
	    } /* TODO: else print error */
	    break;
	case SMI_INDEX_SPARSE:
	    if (relatedNode) {
		fprintSegment(f, (2 + indent) * INDENT, "sparse", INDENTVALUE);
		fprint(f, "%s;\n", relatedNode->name);
		/* TODO: non-local name if non-local */
	    } /* TODO: else print error */
	    break;
	case SMI_INDEX_EXPAND:
	    if (relatedNode) {
		fprintSegment(f, (2 + indent) * INDENT, "", 0);
		fprint(f, "expands %s", relatedNode->name);
		/* TODO: non-local name if non-local */
		if (smiNode->implied) {
		    fprint(f, " implied");
		}
		fprint(f, " (");
		for (j = 0, smiElement = smiGetFirstElement(smiNode);
		     smiElement;
		     j++, smiElement = smiGetNextElement(smiElement)) {
		    if (j) {
			fprint(f, ", ");
		    }
		    fprintWrapped(f, INDENTVALUE + 1,
				  smiGetElementNode(smiElement)->name);
		    /* TODO: non-local name if non-local */
		} /* TODO: empty? -> print error */
		fprint(f, ");\n");
	    } /* TODO: else print error */
	    break;
	case SMI_INDEX_UNKNOWN:
	    break;
	}
	
	if (smiNode->create) {
	    fprintSegment(f, (2 + indent) * INDENT, "create", INDENTVALUE);
	    /* TODO: create list */
	    fprint(f, ";\n");
	}
	
	if (smiNode->value.basetype != SMI_BASETYPE_UNKNOWN) {
	    fprintSegment(f, (2 + indent) * INDENT, "default", INDENTVALUE);
	    fprint(f, "%s", getValueString(&smiNode->value, smiType));
	    fprint(f, ";\n");
	}
	
	if (smiNode->format) {
	    fprintSegment(f, (2 + indent) * INDENT, "format", INDENTVALUE);
	    fprint(f, "\"%s\";\n",smiNode->format);
	}
	if (smiNode->units) {
	    fprintSegment(f, (2 + indent) * INDENT, "units", INDENTVALUE);
	    fprint(f, "\"%s\";\n", smiNode->units);
	}
	if ((smiNode->status != SMI_STATUS_CURRENT) &&
	    (smiNode->status != SMI_STATUS_UNKNOWN) &&
	    (smiNode->status != SMI_STATUS_MANDATORY) &&
	    (smiNode->status != SMI_STATUS_OPTIONAL)) {
	    fprintSegment(f, (2 + indent) * INDENT, "status", INDENTVALUE);
	    fprint(f, "%s;\n", getStringStatus(smiNode->status));
	}
	if (smiNode->description) {
	    fprintSegment(f, (2 + indent) * INDENT, "description",
			  INDENTVALUE);
	    fprint(f, "\n");
	    fprintMultilineString(f, (2 + indent) * INDENT,
				  smiNode->description);
	    fprint(f, ";\n");
	}
	if (smiNode->reference) {
	    fprintSegment(f, (2 + indent) * INDENT, "reference",
			  INDENTVALUE);
	    fprint(f, "\n");
	    fprintMultilineString(f, (2 + indent) * INDENT,
				  smiNode->reference);
	    fprint(f, ";\n");
	}
	i++;
    }
    
    if (i) {
	fprintSegment(f, (1 + indent) * INDENT, "", 0);
	fprint(f, "};\n\n");
    }
}
コード例 #7
0
static void fprintCompliances(FILE *f, SmiModule *smiModule)
{
    int		  i, j;
    SmiNode	  *smiNode, *smiNode2;
    SmiType	  *smiType;
    SmiOption	  *smiOption;
    SmiRefinement *smiRefinement;
    SmiElement    *smiElement;
    
    for(i = 0, smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_COMPLIANCE);
	smiNode; smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_COMPLIANCE)) {
	
	if (!i && !silent) {
	    fprint(f, "//\n// COMPLIANCE DEFINITIONS\n//\n\n");
	}

	fprintSegment(f, INDENT, "", 0);
	fprint(f, "compliance %s {\n", smiNode->name);
	    
	if (smiNode->oid) {
	    fprintSegment(f, 2 * INDENT, "oid", INDENTVALUE);
	    fprint(f, "%s;\n", getOidString(smiNode, 0));
	}
	    
	if ((smiNode->status != SMI_STATUS_CURRENT) &&
	    (smiNode->status != SMI_STATUS_UNKNOWN) &&
	    (smiNode->status != SMI_STATUS_MANDATORY) &&
	    (smiNode->status != SMI_STATUS_OPTIONAL)) {
	    fprintSegment(f, 2 * INDENT, "status", INDENTVALUE);
	    fprint(f, "%s;\n", getStringStatus(smiNode->status));
	}
	    
	if (smiNode->description) {
	    fprintSegment(f, 2 * INDENT, "description", INDENTVALUE);
	    fprint(f, "\n");
	    fprintMultilineString(f, 2 * INDENT, smiNode->description);
	    fprint(f, ";\n");
	}
	    
	if (smiNode->reference) {
	    fprintSegment(f, 2 * INDENT, "reference", INDENTVALUE);
	    fprint(f, "\n");
	    fprintMultilineString(f, 2 * INDENT, smiNode->reference);
	    fprint(f, ";\n");
	}

	if ((smiElement = smiGetFirstElement(smiNode))) {
	    fprint(f, "\n");
	    fprintSegment(f, 2 * INDENT, "mandatory", INDENTVALUE);
	    fprint(f, "(");
	    for (j = 0; smiElement;
		 j++, smiElement = smiGetNextElement(smiElement)) {
		if (j) {
		    fprint(f, ", ");
		}
		fprintWrapped(f, INDENTVALUE + 1,
			      smiGetElementNode(smiElement)->name);
		/* TODO: non-local name if non-local */
	    } /* TODO: empty? -> print error */
	    fprint(f, ");\n");
	}
	
	if ((smiOption = smiGetFirstOption(smiNode))) {
	    fprint(f, "\n");
	    for(; smiOption; smiOption = smiGetNextOption(smiOption)) {
		smiNode2 = smiGetOptionNode(smiOption);
		fprintSegment(f, 2 * INDENT, "", 0);
		fprint(f, "optional %s {\n", smiNode2->name);
		fprintSegment(f, 3 * INDENT, "description", INDENTVALUE);
		fprint(f, "\n");
		fprintMultilineString(f, 3 * INDENT, smiOption->description);
		fprint(f, ";\n");
		fprintSegment(f, 2 * INDENT, "};\n", 0);
	    }
	}
	
	if ((smiRefinement = smiGetFirstRefinement(smiNode))) {
	    fprint(f, "\n");
	    for(; smiRefinement;
		smiRefinement = smiGetNextRefinement(smiRefinement)) {
		fprintSegment(f, 2 * INDENT, "", 0);
		fprint(f, "refine %s {\n",
		       smiGetRefinementNode(smiRefinement)->name);

		smiType = smiGetRefinementType(smiRefinement);
		if (smiType) {
		    fprintSegment(f, 3 * INDENT, "type", INDENTVALUE);
		    fprint(f, "%s",
			   getTypeString(smiType->basetype,
					 smiGetParentType(smiType)));
		    fprintSubtype(f, smiType);
		    fprint(f, ";\n");
		}

		smiType = smiGetRefinementWriteType(smiRefinement);
		if (smiType) {
		    fprintSegment(f, 3 * INDENT, "writetype", INDENTVALUE);
		    fprint(f, "%s",
			   getTypeString(smiType->basetype,
					 smiGetParentType(smiType)));
		    fprintSubtype(f, smiType);
		    fprint(f, ";\n");
		}

		if (smiRefinement->access != SMI_ACCESS_UNKNOWN) {
		    fprintSegment(f, 3 * INDENT, "access", INDENTVALUE);
		    fprint(f, "%s;\n", getAccessString(smiRefinement->access));
		}
		fprintSegment(f, 3 * INDENT, "description", INDENTVALUE);
		fprint(f, "\n");
		fprintMultilineString(f, 3 * INDENT,
				      smiRefinement->description);
		fprint(f, ";\n");
		fprintSegment(f, 2 * INDENT, "};\n", 0);
	    }
	}
	
	fprintSegment(f, INDENT, "", 0);
	fprint(f, "};\n\n");
	i++;
    }
}
コード例 #8
0
ファイル: dump-compliance.c プロジェクト: pan0007/libsmi
static void fprintGroup(FILE *f, SmiNode *smiNode, char c,
			int *typelen, int *namelen, int pass)
{
    SmiElement *smiElement;
    SmiNode *smiObject;
    SmiModule *smiModule;
    char *type_name;
    int tlen = 9, nlen = 9;

    switch (smiNode->nodekind) {
    case SMI_NODEKIND_GROUP:
	for (smiElement = smiGetFirstElement(smiNode);
	     smiElement;
	     smiElement = smiGetNextElement(smiElement)) {
	    smiObject = smiGetElementNode(smiElement);
	    smiModule = smiGetNodeModule(smiNode);
	    type_name = getTypeName(smiObject);
	    if (pass == 1) {
		if (type_name) {
		    int newlen = strlen(type_name);
		    tlen = (tlen < newlen) ? newlen : tlen;
		}
		if (smiObject->name) {
		    int newlen = strlen(smiObject->name);
		    nlen = (nlen < newlen) ? newlen : nlen;
		}
	    } else if (pass == 2) {
		fprintf(f, "  %c%c%s %-*s %-*s (%s)\n",
			getStatusChar(smiObject->status), c,
			getFlags(smiObject),
			*typelen, type_name ? type_name : "-",
			*namelen, smiObject->name, smiNode->name);
	    }
	    xfree(type_name);
	}
	break;
    case SMI_NODEKIND_SCALAR:
    case SMI_NODEKIND_COLUMN:
	smiObject = smiNode;
	type_name = getTypeName(smiObject);
	if (pass == 1) {
	    if (type_name) {
		int newlen = strlen(type_name);
		tlen = tlen < newlen ? newlen : tlen;
	    }
	    if (smiObject->name) {
		int newlen = strlen(smiObject->name);
		nlen = (nlen < newlen) ? newlen : nlen;
	    }
	} else if (pass == 2) {
	    fprintf(f, "  %c%c%s %-*s %s\n",
		    getStatusChar(smiObject->status), 'r',
		    getFlags(smiObject),
		    *typelen, type_name ? type_name : "-",
		    smiObject->name);
	}
	xfree(type_name);
	break;
    default:
	break;
    }

    if (pass == 1) {
	if (typelen) *typelen = tlen;
	if (namelen) *namelen = nlen;
    }
}
コード例 #9
0
ファイル: dump-sizes.c プロジェクト: pan0007/libsmi
static int
ber_len_varbind(SmiNode *smiNode, len_type flags)
{
     SmiNode *row;
     SmiSubid oid[128];
     unsigned int oidlen = sizeof(oid)/sizeof(oid[0]);
     int len = 0;
#ifdef DUMP_OID
     int x;
#endif

     switch (smiNode->nodekind) {
     case SMI_NODEKIND_SCALAR:
	  for (oidlen = 0; oidlen < smiNode->oidlen; oidlen++) {
	       oid[oidlen] = smiNode->oid[oidlen];
	  }
	  oid[oidlen++] = 0;
	  break;
     case SMI_NODEKIND_COLUMN:
	  for (oidlen = 0; oidlen < smiNode->oidlen; oidlen++) {
	       oid[oidlen] = smiNode->oid[oidlen];
	  }
	  row = smiGetParentNode(smiNode);
	  if (row) {
	       SmiNode *indexNode = NULL, *iNode;
	       SmiElement *smiElement;
	       
	       switch (row->indexkind) {
	       case SMI_INDEX_INDEX:
	       case SMI_INDEX_REORDER:
		    indexNode = row;
		    break;
	       case SMI_INDEX_EXPAND: /* TODO: we have to do more work here! */
		    break;
	       case SMI_INDEX_AUGMENT:
	       case SMI_INDEX_SPARSE:
		    indexNode = smiGetRelatedNode(row);
		    break;
	       case SMI_INDEX_UNKNOWN:
		    break;
	       }
	       if (indexNode) {
		    for (smiElement = smiGetFirstElement(indexNode);
			 smiElement;
			 smiElement = smiGetNextElement(smiElement)) {
			 iNode = smiGetElementNode(smiElement);
			 append_index(oid, &oidlen, iNode, flags);
		    }
	       }
	  }
	  break;
     default:
	  return 0;
     }

#ifdef DUMP_OID
     fprintf(stderr, "%-32s\t", smiNode->name);
     for (x = 0; x < oidlen; x++) {
	  fprintf(stderr, ".%u", oid[x]);
     }
     fprintf(stderr, "\n");
#endif

     len += ber_len_oid(oid, oidlen);
     len += ber_len_val(smiGetNodeType(smiNode), flags);
     len += ber_len_length(len) + 1;

     return len;
}
コード例 #10
0
ファイル: dump-sizes.c プロジェクト: pan0007/libsmi
static void
dumpSizeOfNotificationPDU(FILE *f, SmiModule *smiModule, SmiNode *smiNode)
{
     SmiElement *smiElement;
     SmiNode *varNode;
     int worst = 0;
     int best = 0;
     int avg = 0;
     int w, b, a;
     int len = 0;
     static const SmiSubid snmpTrapOid0[]
	  = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
     static const int snmpTrapOid0Len
	  = sizeof(snmpTrapOid0) / sizeof(SmiSubid);
     
     b = 15, w = 19, a = 18;
     best += b, worst += w, avg += a;
     
     len += ber_len_oid(smiNode->oid, smiNode->oidlen);
     len += ber_len_oid(snmpTrapOid0, snmpTrapOid0Len);
     len += ber_len_length(len) + 1;
     b = len, w = len, a = len;
     best += b, worst += w, avg += a;
     
     for (smiElement = smiGetFirstElement(smiNode);
	  smiElement;
	  smiElement = smiGetNextElement(smiElement)) {
	  varNode = smiGetElementNode(smiElement);
	  if (! varNode) continue;

	  b = ber_len_varbind(varNode, len_min);
	  a = ber_len_varbind(varNode, len_mean);
	  w = ber_len_varbind(varNode, len_max);
	  
	  best += b, worst += w, avg += a;
     }

     /* varbind list sequence length and tag */
     best  += ber_len_length(best)  + 1;
     avg   += ber_len_length(avg)   + 1;
     worst += ber_len_length(worst) + 1;
     
     /* request-id as defined in RFC 3416 */
     best += ber_len_int32(0);
     avg += ber_len_int32(1073741824);
     worst += ber_len_int32(-214783648);
     
     /* error-status as defined in RFC 3416 */
     best += ber_len_int32(0);
     avg += ber_len_int32(0);
     worst += ber_len_int32(18);
     
     /* error-index as defined in RFC 3416 */
     best += ber_len_int32(0);
     avg += ber_len_int32(0);
     worst += ber_len_int32(0);

     /* PDU sequence length and tag */
     best  += ber_len_length(best)  + 1;
     avg += ber_len_length(avg) + 1;
     worst += ber_len_length(worst) + 1;
     
     fprintf(f, "%-23s %-23s \t%d\t[%d..%d]\n", smiModule->name, smiNode->name,
	     avg, best, worst);

     if (detail) {
	 b = 15, w = 19, a = 18;
	 fprintf(f, "%-23s %-23s \t%d\t[%d..%d]\n",
		 "", "sysUpTime", a, b, w);
	 
	 len = 0;
	 len += ber_len_oid(smiNode->oid, smiNode->oidlen);
	 len += ber_len_oid(snmpTrapOid0, snmpTrapOid0Len);
	 len += ber_len_length(len) + 1;
	 b = len, w = len, a = len;
	 fprintf(f, "%-23s %-23s \t%d\t[%d..%d]\n",
		 "", "snmpTrapOID", a, b, w);
	 
	 for (smiElement = smiGetFirstElement(smiNode);
	      smiElement;
	      smiElement = smiGetNextElement(smiElement)) {
	     varNode = smiGetElementNode(smiElement);
	     if (! varNode) continue;
	     
	     b = ber_len_varbind(varNode, len_min);
	     a = ber_len_varbind(varNode, len_mean);
	     w = ber_len_varbind(varNode, len_max);
	     
	     fprintf(f, "%-23s %-23s \t%d\t[%d..%d]\n",
		     "", varNode->name, a, b, w);
	 }
     }
}
コード例 #11
0
ファイル: dump-cm.c プロジェクト: pan0007/libsmi
/*
 * diaCalcSize
 *
 * Calculates the size of a given node for the UML representation.
 */
static GraphNode *diaCalcSize(GraphNode *node)
{
    GraphEdge  *tEdge;
    SmiNode    *tNode,*ppNode;
    SmiElement *smiElement;
    SmiModule  *module;

    if (node->smiNode->nodekind == SMI_NODEKIND_SCALAR) return node;
    
    node->dia.w = (strlen(node->smiNode->name)+4) * HEADFONTSIZETABLE
	+ HEADSPACESIZETABLE;
    
    node->dia.h = TABLEHEIGHT;
    for (smiElement = smiGetFirstElement(
	smiGetFirstChildNode(node->smiNode));
	 smiElement;
	 smiElement = smiGetNextElement(smiElement)) {
	
	tNode = smiGetElementNode(smiElement);
	
	node->dia.w = max(node->dia.w, (strlen(tNode->name) +
					strlen(algGetTypeName(tNode)) +
					strlen(INDEXPROPERTY))
		      * ATTRFONTSIZE
		      + ATTRSPACESIZE);
	node->dia.h += TABLEELEMHEIGHT;
    }
    
    for (tEdge = graphGetFirstEdgeByNode(graph,node);
	 tEdge;
	 tEdge = graphGetNextEdgeByNode(graph, tEdge, node)) {
	if (tEdge->startNode == node &&
	    tEdge->endNode->smiNode->nodekind == SMI_NODEKIND_SCALAR) {
	    node->dia.h += TABLEELEMHEIGHT;
	    tNode = tEdge->endNode->smiNode;
	    
	    node->dia.w = max(node->dia.w, (strlen(tNode->name) +
				    strlen(algGetTypeName(tNode)))
			  * ATTRFONTSIZE
			  + ATTRSPACESIZE);		
	}
    }

    if (PRINT_DETAILED_ATTR && node->smiNode->nodekind == SMI_NODEKIND_TABLE) {
	module  = smiGetNodeModule(node->smiNode);

	for (tNode = smiGetFirstNode(module, SMI_NODEKIND_COLUMN);
	     tNode;
	     tNode = smiGetNextNode(tNode, SMI_NODEKIND_COLUMN)) {
	    ppNode = smiGetParentNode(tNode);
	    ppNode = smiGetParentNode(ppNode);

	    if (cmpSmiNodes(node->smiNode, ppNode)) {
		int len;
		char *typeName;

		typeName = algGetTypeName(tNode);
		len = strlen(tNode->name) + (typeName ? strlen(typeName) : 0);
		node->dia.h += TABLEELEMHEIGHT;
		node->dia.w = max(node->dia.w, len)
		    * ATTRFONTSIZE
		    + ATTRSPACESIZE;
	    }
	}
    }
    
    return node;
}
コード例 #12
0
ファイル: dump-cm.c プロジェクト: pan0007/libsmi
static void diaPrintXMLObject(GraphNode *node, float x, float y)
{
    SmiElement *smiElement;
    
    if (!node) return;
    if (node->dia.flags & DIA_PRINT_FLAG) return;

    node->dia.x = x;
    node->dia.y = y;
    node->dia.flags |= DIA_PRINT_FLAG; /* object is now printed */
    
    printf("    <object type=\"UML - Class\" version=\"0\" id=\"%s\">\n",
	   node->smiNode->name);
    printf("      <attribute name=\"obj_pos\">\n");
    printf("       <point val=\"%.2f,%.2f\"/>\n",x,y);
    printf("      </attribute>\n");
    printf("     <attribute name=\"obj_bb\">\n");
    printf("       <rectangle val=\"0.0,0.0;0.0,0.0\"/>\n");
    printf("     </attribute>\n");
    printf("     <attribute name=\"elem_corner\">\n");
    printf("       <point val=\"%.2f,%.2f\"/>\n",x,y);
    printf("     </attribute>\n");
    printf("     <attribute name=\"elem_width\">\n");
    printf("       <real val=\"%.2f\"/>\n",node->dia.w);
    printf("     </attribute>\n");
    printf("     <attribute name=\"elem_height\">\n");
    printf("       <real val=\"%.2f\"/>\n",node->dia.h);
    printf("     </attribute>\n");
    printf("     <attribute name=\"name\">\n");
    printf("       <string>#%s#</string>\n",
	   smiGetFirstChildNode(node->smiNode)->name);
    printf("     </attribute>\n");
    printf("     <attribute name=\"stereotype\">\n");
    printf("        <string>#%s#</string>\n", STEREOTYPE);
    printf("     </attribute>\n");
    printf("     <attribute name=\"abstract\">\n");
    printf("       <boolean val=\"false\"/>\n");
    printf("     </attribute>\n");
    printf("     <attribute name=\"suppress_attributes\">\n");
    printf("        <boolean val=\"false\"/>\n");    
    printf("      </attribute>\n");   
    printf("      <attribute name=\"suppress_operations\">\n");
    printf("        <boolean val=\"true\"/>\n");
    printf("      </attribute>\n");
    printf("     <attribute name=\"visible_attributes\">\n");
    printf("       <boolean val=\"true\"/>\n");
    printf("     </attribute>\n");
    printf("     <attribute name=\"visible_operations\">\n");
    printf("        <boolean val=\"false\"/>\n");
    printf("      </attribute>\n");

    printf("     <attribute name=\"attributes\">\n");

    if (node->smiNode->nodekind == SMI_NODEKIND_TABLE) {

	diaPrintXMLRelatedScalars(node);

	diaPrintAugmentIndex(node);
	
	for (smiElement = smiGetFirstElement(
	    smiGetFirstChildNode(node->smiNode));
	     smiElement;
	     smiElement = smiGetNextElement(smiElement)) {
	    diaPrintXMLAttribute(smiGetElementNode(smiElement),1);
	}

	if (PRINT_DETAILED_ATTR) {
	    diaPrintXMLAllColumns(node);
	}
    }
    
    printf("      </attribute>\n");
    
    printf("     <attribute name=\"operations\"/>\n");
    printf("    <attribute name=\"template\">\n");
    printf("      <boolean val=\"false\"/>\n");
    printf("    </attribute>\n");
    printf("     <attribute name=\"templates\"/>\n");
    printf("   </object>\n");
}