Libsmi
Threads by month
- ----- 2025 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1999 -----
- December
- November
- October
- September
- August
- July
- June
November 2008
- 7 participants
- 7 discussions

Invalid use of 2nd arg to setAttributeList() in lib/parser-sming.y from 0.4.8
by Albert Chin 30 Nov '08
by Albert Chin 30 Nov '08
30 Nov '08
In lib/parser-sming.y from 0.4.8:
bitsOrEnumerationSpec
{
List *p;
$$ = duplicateTypeToAttribute(smiHandle->typeBitsPtr,
classPtr, thisParserPtr);
setAttributeParentType($$, smiHandle->typeBitsPtr);
if ($1) {
setAttributeList($$, $1);
for (p = $1; p; p = p->nextPtr)
((NamedNumber *)(p->ptr))->typePtr = (Type*)$$;
}
bitsFlag = 0; /* reset flag */
}
}
In lib/parser-sming.c, this expands to:
typedef union YYSTYPE
{
char *id; /* identifier name */
int rc; /* >=0: ok, <0: error */
...
}
...
{
List *p;
(yyval.attributePtr) = duplicateTypeToAttribute(smiHandle->typeBitsPtr,
classPtr, thisParserPtr);
setAttributeParentType((yyval.attributePtr), smiHandle->typeBitsPtr);
if ((yyvsp[(1) - (3)].rc)) {
setAttributeList((yyval.attributePtr), (yyvsp[(1) - (3)].rc));
for (p = (yyvsp[(1) - (3)].rc); p; p = p->nextPtr)
((NamedNumber *)(p->ptr))->typePtr = (Type*)(yyval.attributePtr);
}
bitsFlag = 0; /* reset flag */
;}
break;
yyvsp is of type YYVSP so (yyvsp[(1) - (3)].rc) is of type int. But, the
prototype of setAttributeList() according to data.h is:
extern void setAttributeList(Attribute *attributePtr, List *listPtr);
So, how is the above code expected to work?
--
albert chin (china(a)thewrittenword.com)
1
0
Hi!
When importing a MIB requesting another MIB and when this later MIB is
not available, the first MIB is imported but nodes information are then
incomplete. For example, they contain empty OID or even random OID.
Is there a way to forbid the import of MIB when OID information would be
incomplete?
Thanks.
--
BOFH excuse #142:
new guy cross-connected phone lines with ac power bus.
1
0
I've run into a possible problem in SVN version of libsmi. I have not done
any debugging, so this is just a bug report:
When I do:
smidump -f python TCP-MIB.txt
for the following MIB text:
tcpMaxConn OBJECT-TYPE
SYNTAX Integer32 (-1 | 0..2147483647)
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The limit on the total number of TCP connections the entity
can support. In entities where the maximum number of
connections is dynamic, this object should contain the
value -1."
::= { tcp 4 }
smidump generates:
"tcpMaxConn" : {
"nodetype" : "scalar",
"moduleName" : "TCP-MIB",
"oid" : "1.3.6.1.2.1.6.4",
"status" : "current",
"syntax" : {
"type" : {
"basetype" : "Integer32",
"ranges" : [
{
"min" : "-1",
"max" : "2147483647"
},
],
"range" : {
"min" : "4294967295",
"max" : "2147483647"
},
},
},
"access" : "readonly",
"description" :
""" [skipped] """,
}, # scalar
Where range constraints seem to be broken at:
1. Range minimum (0) gets converted into 4294967295.
2. Single value constraint (-1) gets translated into a value
range constraint with wildly inflated upper range (2147483647).
Current stable release (0.4.5) behaves differently (yet, incorrectly) in
this respect:
"tcpMaxConn" : {
"nodetype" : "scalar",
"moduleName" : "TCP-MIB",
"oid" : "1.3.6.1.2.1.6.4",
"status" : "current",
"syntax" : {
"type" : {
"basetype" : "Integer32",
"range" : {
"min" : "-1",
"max" : "2147483647"
},
},
},
"access" : "readonly",
"description" :
""" [skipped] """,
}, # scalar
Is there currently a fix for this issue?
Thanks,
ilya
2
17
While, going through the XML version of this that I Downloaded from
Simpleweb:
http://www.simpleweb.org/ietf/mibs/modules/IETF/xmlv2/HOST-RESOURCES-MIB.xml
This may be just an issue with my understanding of this rfc, but
the Module Identifier / identity node is listed as
hostResourcesMibModule is found in the Document as hrAdmininfo.1 which
would make the OID of the Module Identifier be { 1.3.6.1.2.1.25.7.1 }
when the Logical OID for the Module Identifier (for me at least) would
be { 1.3.6.1.2.1.25 } thus giving you the Base OID of this module which
all other OIDs in the module are sub-interfaces of.
what am I doing wrong?
2
1
Hello, previously I've reported on this mailing list about test
failures. Now we've managed to localize them. So may be it's possible to
fix some of them upstream?
1. smidump-sming test failure [1]. As Juergen told [2] it's Ok. Why
don't you disable this test then? We already do this with the following
command:
sed -i '/^[[:space:]]*smidump-sming.test \\$/d' test/Makefile
2. smidump-orig-smiv2 failure[1]. This test failure caused by different
locale settings and export LC_ALL=C fixes the problem [3]. May be it's
good idea to add this into test suit itself?
3. smidump-cm fails. Initially it was reproduced on hppa, but later we
found that it caused by compiler optimizations. So if you build with -Os
or -O3 this test fails [4]. Now we forced building of libsmi only with
-O2.
Will you accept patches for 1. and 2? Of course they are trivial... The
test failure 3. is strange. Seems that code relies on some float
pointing operations but code itself is not very reliable although I have
not investigated it further and don't know where that code resides. What
do you think?
[1] http://mail.ibr.cs.tu-bs.de/pipermail/libsmi/2008-March/001005.html
[2] http://mail.ibr.cs.tu-bs.de/pipermail/libsmi/2008-March/001014.html
[3] http://mail.ibr.cs.tu-bs.de/pipermail/libsmi/2008-March/001025.html
[4] https://bugs.gentoo.org/show_bug.cgi?id=218541
--
Peter.
3
6
Juergen,
This is the diff from a previous copy I had.
Br,
--
- Yigal
....................
diff -c "c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c.~1~" "c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c"
*** c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c.~1~ Wed Feb 20 22:20:23 2008
--- c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c Mon Nov 3 22:43:25 2008
***************
*** 8,14 ****
* See the file "COPYING" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
! * @(#) $Id: smi.c 7734 2008-02-15 07:49:14Z schoenw $
*/
#include <config.h>
--- 8,14 ----
* See the file "COPYING" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
! * @(#) $Id: smi.c 10607 2008-10-31 11:28:57Z kanev $
*/
#include <config.h>
***************
*** 25,30 ****
--- 25,33 ----
#include <pwd.h>
#endif
+ /* yh-chnages Thu Feb 21 2008 */
+ #include <limits.h>
+
#include "smi.h"
#include "data.h"
#include "error.h"
***************
*** 41,46 ****
--- 44,54 ----
#include "parser-sming.h"
#endif
+ #ifdef BACKEND_YANG
+ #include "scanner-yang.h"
+ #include "parser-yang.h"
+ #endif
+
#ifdef HAVE_DMALLOC_H
#include <dmalloc.h>
#endif
***************
*** 764,770 ****
for (listPtr = typePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
--- 772,778 ----
for (listPtr = typePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
***************
*** 813,819 ****
for (listPtr = attributePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
--- 821,827 ----
for (listPtr = attributePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
***************
*** 921,927 ****
SmiIdentity *smiGetFirstIdentity(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
--- 929,935 ----
SmiIdentity *smiGetFirstIdentity(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
***************
*** 953,959 ****
SmiIdentity *smiGetIdentity(SmiModule *smiModulePtr, char *identity)
{
! if (!smiModulePtr) {
return NULL;
}
else
--- 961,967 ----
SmiIdentity *smiGetIdentity(SmiModule *smiModulePtr, char *identity)
{
! if (!smiModulePtr) {
return NULL;
}
else
***************
*** 961,969 ****
SmiIdentity *ide;
for(ide = smiGetFirstIdentity(smiModulePtr);
! ide;
! ide = smiGetNextIdentity(ide))
! if(!strncmp(ide->name,identity,64))return ide;
return NULL;
}
--- 969,977 ----
SmiIdentity *ide;
for(ide = smiGetFirstIdentity(smiModulePtr);
! ide;
! ide = smiGetNextIdentity(ide))
! if(!strncmp(ide->name,identity,64))return ide;
return NULL;
}
***************
*** 978,984 ****
SmiClass *smiGetFirstClass(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
--- 986,992 ----
SmiClass *smiGetFirstClass(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
***************
*** 1010,1016 ****
SmiClass *smiGetClass(SmiModule *smiModulePtr, char *class)
{
! if (!smiModulePtr) {
return NULL;
}
else
--- 1018,1024 ----
SmiClass *smiGetClass(SmiModule *smiModulePtr, char *class)
{
! if (!smiModulePtr) {
return NULL;
}
else
***************
*** 1018,1026 ****
SmiClass *cl;
for(cl = smiGetFirstClass(smiModulePtr);
! cl;
! cl = smiGetNextClass(cl))
! if(!strncmp(cl->name,class,64))return cl;
return NULL;
}
--- 1026,1034 ----
SmiClass *cl;
for(cl = smiGetFirstClass(smiModulePtr);
! cl;
! cl = smiGetNextClass(cl))
! if(!strncmp(cl->name,class,64))return cl;
return NULL;
}
***************
*** 1040,1051 ****
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
return &attributePtr->export;
}
! SmiAttribute *smiGetNextAttribute( SmiAttribute *smiTypePtr)
{
Attribute *attributePtr;
--- 1048,1059 ----
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
return &attributePtr->export;
}
! SmiAttribute *smiGetNextAttribute( SmiAttribute *smiTypePtr)
{
Attribute *attributePtr;
***************
*** 1058,1193 ****
return &attributePtr->export;
}
! SmiAttribute *smiGetAttribute(SmiClass *smiClassPtr, char *attribute)
{
! Attribute *attributePtr;
! if (!smiClassPtr) {
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
!
! for(attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
! attributePtr; attributePtr = attributePtr->nextPtr)
! {
! if(!strncmp(attributePtr->export.name,attribute,64))
! return &attributePtr->export;
! }
!
! //attribute might belong to the parent so check parent if attribute not found
! smiClassPtr = smiGetParentClass(smiClassPtr);
! attributePtr = (Attribute*)smiGetAttribute(smiClassPtr , attribute);
! return &attributePtr->export;
}
! SmiType *smiGetAttributeParentType(SmiAttribute *smiAttributePtr)
{
!
! if (!smiAttributePtr) {
return NULL;
}
!
! Type *parentTypePtr = ((Attribute*)smiAttributePtr)->parentTypePtr;
!
! if(parentTypePtr)
! return &parentTypePtr->export;
! else
! return NULL;
}
SmiClass *smiGetAttributeParentClass( SmiAttribute *smiAttributePtr)
{
! if (!smiAttributePtr) {
return NULL;
}
! Class *parentClassPtr=((Attribute*)smiAttributePtr)->parentClassPtr;
!
! if(parentClassPtr)
! return &parentClassPtr->export;
! else
! return NULL;
}
! SmiAttribute *smiGetFirstUniqueAttribute(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if(!smiClassPtr)
! return NULL;
! classPtr = (Class*)smiClassPtr;
! if(classPtr->uniqueList)
! {
! if(classPtr->uniqueList->ptr == classPtr)
! {
! return NULL; //scalar class
! }
! else
! {
! return ( SmiAttribute*)(classPtr->uniqueList->ptr);
! }
! }
! else
! return NULL;
}
! SmiAttribute *smiGetNextUniqueAttribute( SmiAttribute *smiTypePtr)
{
! Class *classPtr;
! List *listPtr;
!
! if(!smiTypePtr)
! return NULL;
!
! classPtr = ((Attribute*)smiTypePtr)->classPtr;
! if(classPtr && classPtr->uniqueList)
! {
! for(listPtr=classPtr->uniqueList;listPtr;
! listPtr=listPtr->nextPtr)
! {
! if(&((Attribute*)(listPtr->ptr))->export == smiTypePtr)
! {
! if(listPtr->nextPtr)
! return &((Attribute*)(listPtr->nextPtr->ptr))->export;
! }
}
}
! return NULL;
}
int smiGetAttributeLine(SmiAttribute *smiAttributePtr)
{
return ((Attribute *)smiAttributePtr)->line;
}
int smiIsClassScalar(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if(!smiClassPtr)
! return 0;
!
! classPtr = (Class*)smiClassPtr;
! if(classPtr->uniqueList)
! {
! if(classPtr->uniqueList->ptr == classPtr)
! {
! return 1; //scalar class
! }
! else
! {
! return 0;
! }
! }
! else
! return 0;
}
--- 1066,1194 ----
return &attributePtr->export;
}
! SmiAttribute *smiGetAttribute(SmiClass *smiClassPtr, char *attribute)
{
! Attribute *attributePtr;
! if (! smiClassPtr) {
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
!
! for (attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
! attributePtr; attributePtr = attributePtr->nextPtr)
! {
! if (!strncmp(attributePtr->export.name, attribute,64)) {
! return &attributePtr->export;
! }
! }
!
! /*
! * attribute might belong to the parent so check parent if
! * attribute not found
! */
!
! smiClassPtr = smiGetParentClass(smiClassPtr);
! attributePtr = (Attribute*)smiGetAttribute(smiClassPtr , attribute);
! return &attributePtr->export;
}
! SmiType *smiGetAttributeParentType(SmiAttribute *smiAttributePtr)
{
+ Type *parentTypePtr;
! if (! smiAttributePtr) {
return NULL;
}
!
! parentTypePtr = ((Attribute*)smiAttributePtr)->parentTypePtr;
!
! return (parentTypePtr) ? &parentTypePtr->export : NULL;
}
SmiClass *smiGetAttributeParentClass( SmiAttribute *smiAttributePtr)
{
! Class *parentClassPtr;
!
! if (! smiAttributePtr) {
return NULL;
}
+
+ parentClassPtr = ((Attribute*)smiAttributePtr)->parentClassPtr;
! return parentClassPtr ? &parentClassPtr->export : NULL;
}
! SmiAttribute *smiGetFirstUniqueAttribute(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if (! smiClassPtr) {
! return NULL;
! }
! classPtr = (Class*)smiClassPtr;
! if (! classPtr->uniqueList) {
! return NULL;
! }
!
! if (classPtr->uniqueList->ptr == classPtr) {
! return NULL; /* scalar class */
! }
!
! return (SmiAttribute*)(classPtr->uniqueList->ptr);
}
! SmiAttribute *smiGetNextUniqueAttribute( SmiAttribute *smiTypePtr)
{
! Class *classPtr;
! List *listPtr;
!
! if (! smiTypePtr) {
! return NULL;
! }
! classPtr = ((Attribute*)smiTypePtr)->classPtr;
!
! if (classPtr && classPtr->uniqueList) {
! for (listPtr=classPtr->uniqueList;listPtr; listPtr=listPtr->nextPtr) {
! if (&((Attribute*)(listPtr->ptr))->export == smiTypePtr) {
! if (listPtr->nextPtr) {
! return &((Attribute*)(listPtr->nextPtr->ptr))->export;
}
+ }
}
! }
! return NULL;
}
+
+
int smiGetAttributeLine(SmiAttribute *smiAttributePtr)
{
return ((Attribute *)smiAttributePtr)->line;
}
+
+
int smiIsClassScalar(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if (! smiClassPtr) {
! return 0;
! }
! classPtr = (Class*)smiClassPtr;
!
! if (! classPtr->uniqueList) {
! return 0;
! }
!
! return (classPtr->uniqueList->ptr == classPtr);
}
***************
*** 1196,1223 ****
{
Event *eventPtr;
! if (!smiClassPtr) {
return NULL;
}
! eventPtr = ((Class *)smiClassPtr)->firstEventPtr;
!
return &(eventPtr->export);
}
SmiEvent *smiGetNextEvent(SmiEvent *smiEventPtr)
{
Event *eventPtr;
! if (!smiEventPtr) {
return NULL;
}
eventPtr = ((Event *)smiEventPtr)->nextPtr;
-
return &eventPtr->export;
}
int smiGetEventLine(SmiEvent *smiEventPtr)
{
return ((Event *)smiEventPtr)->line;
--- 1197,1226 ----
{
Event *eventPtr;
! if (! smiClassPtr) {
return NULL;
}
! eventPtr = ((Class *)smiClassPtr)->firstEventPtr;
return &(eventPtr->export);
}
+
+
SmiEvent *smiGetNextEvent(SmiEvent *smiEventPtr)
{
Event *eventPtr;
! if (! smiEventPtr) {
return NULL;
}
eventPtr = ((Event *)smiEventPtr)->nextPtr;
return &eventPtr->export;
}
+
+
int smiGetEventLine(SmiEvent *smiEventPtr)
{
return ((Event *)smiEventPtr)->line;
***************
*** 1293,1298 ****
--- 1296,1477 ----
return ((Macro *)smiMacroPtr)->line;
}
+ SmiYangNode *smiGetFirstRootNode(SmiModule *module)
+ {
+ YangNode *node = NULL;
+
+ if(module)
+ {
+ node = ((Module*)module)->firstYangNodePtr;
+ }
+
+ return &(node->export);
+ }
+
+ SmiYangNode *smiGetNextRootNode(SmiYangNode *node)
+ {
+ YangNode *tmp;
+
+ if(!node) return NULL;
+
+ tmp = ((YangNode*)node)->nextSiblingPtr;
+
+ return &(tmp->export);
+ }
+
+ SmiYangNode *smiGetFirstChildYangNode(SmiYangNode *node)
+ {
+ YangNode *tmp;
+
+ if(!node) return NULL;
+
+ tmp = ((YangNode*)node)->firstChildPtr;
+
+ return &(tmp->export);
+ }
+
+ SmiYangNode *smiGetNextChildYangNode(SmiYangNode *node)
+ {
+ YangNode *tmp;
+
+ if(!node) return NULL;
+ tmp = ((YangNode*)node)->nextSiblingPtr;
+ return &(tmp->export);
+ }
+
+ SmiType *smiGetYangNodeType(SmiYangNode *node)
+ {
+ SmiType *type;
+ if(!node) return NULL;
+ type = &(((YangNode*)node)->type->export);
+ return type;
+ }
+
+ SmiRange *smiGetYangNodeMinMaxElements(SmiYangNode *node)
+ {
+ SmiRange *range;
+ if(!node) return NULL;
+ range = &(((YangNode*)node)->minMaxElements->export);
+ return range;
+ }
+
+ SmiYangNode *smiGetFirstUniqueYangNode(SmiYangNode *node)
+ {
+ SmiYangNode *result;
+ YangNode *yn;
+
+ if(!node)return NULL;
+ if(node->nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ yn = (YangNode*)node;
+ if(!yn->uniqueList) return NULL;
+ result = &(yn->uniqueList->yangNode->export);
+ return result;
+ }
+
+ SmiYangNode *smiGetNextUniqueYangNode(SmiYangNode *node)
+ {
+ YangNode *parent;
+ YangNodeList *tmp;
+
+ if(!node) return NULL;
+
+ parent = ((YangNode*)node)->parentPtr;
+
+ if(parent->export.nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ for(tmp = parent->uniqueList; tmp; tmp = tmp->next)
+ {
+ if(&(tmp->yangNode->export) == node) break;
+ }
+
+ if(!tmp)
+ {
+ return NULL;
+ }
+ else if(tmp->next)
+ {
+ SmiYangNode *result = &(tmp->next->yangNode->export);
+ return result;
+ }
+ else return NULL;
+
+ }
+
+ SmiYangNode *smiGetFirstKeyYangNode(SmiYangNode *node)
+ {
+ YangNode *yn;
+ SmiYangNode *result;
+
+ if(!node)return NULL;
+ if(node->nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ yn = (YangNode*)node;
+ if(!yn->keyList) return NULL;
+ result = &(yn->keyList->yangNode->export);
+ return result;
+ }
+
+ SmiYangNode *smiGetNextKeyYangNode(SmiYangNode *node)
+ {
+ YangNode *parent;
+ YangNodeList *tmp;
+
+ if(!node) return NULL;
+
+ parent = ((YangNode*)node)->parentPtr;
+
+ if(parent->export.nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ for(tmp = parent->keyList; tmp; tmp = tmp->next)
+ {
+ if(&(tmp->yangNode->export) == node) break;
+ }
+
+ if(!tmp)
+ {
+ return NULL;
+ }
+ else if(tmp->next)
+ {
+ SmiYangNode *result = &(tmp->next->yangNode->export);
+ return result;
+ }
+ else return NULL;
+
+ }
+
+ SmiMustStatement *smiGetFirstMustStatement(SmiYangNode *node)
+ {
+ Must *must = NULL;
+
+ if(node)
+ {
+ must = ((YangNode*)node)->firstMustPtr;
+ }
+
+ return &(must->export);
+ }
+
+ SmiMustStatement *smiGetNextMustStatement(SmiMustStatement *must)
+ {
+ Must *tmp;
+ if(!must) return NULL;
+ tmp = ((Must*)must)->nextPtr;
+ return &(tmp->export);
+ }
SmiNode *smiGetNode(SmiModule *smiModulePtr, const char *node)
{
***************
*** 1724,1730 ****
}
for (listPtr =
! ((Option *)smiOptionPtr)->compliancePtr->optionlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Option *)(listPtr->ptr) == (Option *)smiOptionPtr) {
--- 1903,1909 ----
}
for (listPtr =
! ((Option *)smiOptionPtr)->compliancePtr->optionlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Option *)(listPtr->ptr) == (Option *)smiOptionPtr) {
***************
*** 1787,1793 ****
}
for (listPtr =
! ((Refinement *)smiRefinementPtr)->compliancePtr->refinementlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Refinement *)(listPtr->ptr) == (Refinement *)smiRefinementPtr) {
--- 1966,1972 ----
}
for (listPtr =
! ((Refinement *)smiRefinementPtr)->compliancePtr->refinementlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Refinement *)(listPtr->ptr) == (Refinement *)smiRefinementPtr) {
***************
*** 1867,1873 ****
char *smiRenderOID(unsigned int oidlen, SmiSubid *oid, int flags)
{
! SmiNode *nodePtr;
SmiModule *modulePtr = NULL;
unsigned int i = 0;
char *ss, *s = NULL;
--- 2046,2052 ----
char *smiRenderOID(unsigned int oidlen, SmiSubid *oid, int flags)
{
! SmiNode *nodePtr = NULL;
SmiModule *modulePtr = NULL;
unsigned int i = 0;
char *ss, *s = NULL;
***************
*** 1882,1889 ****
}
if (flags & (SMI_RENDER_NAME | SMI_RENDER_QUALIFIED)) {
! nodePtr = smiGetNodeByOID(oidlen, oid);
! if (nodePtr) {
i = nodePtr->oidlen;
if (flags & SMI_RENDER_QUALIFIED) {
modulePtr = smiGetNodeModule(nodePtr);
--- 2061,2072 ----
}
if (flags & (SMI_RENDER_NAME | SMI_RENDER_QUALIFIED)) {
! int len;
! for (len = oidlen; len; len--) {
! nodePtr = smiGetNodeByOID(len, oid);
! if (! nodePtr || nodePtr->name) break;
! }
! if (nodePtr && nodePtr->name) {
i = nodePtr->oidlen;
if (flags & SMI_RENDER_QUALIFIED) {
modulePtr = smiGetNodeModule(nodePtr);
***************
*** 1914,1920 ****
char *smiRenderValue(SmiValue *smiValuePtr, SmiType *smiTypePtr, int flags)
{
! int i, j, k, n, pfx, have_pfx;
char *last_fmt, *fmt;
SmiUnsigned64 vv;
int xlen;
--- 2097,2104 ----
char *smiRenderValue(SmiValue *smiValuePtr, SmiType *smiTypePtr, int flags)
{
! unsigned int i, pfx;
! int j, k, n, have_pfx;
char *last_fmt, *fmt;
SmiUnsigned64 vv;
int xlen;
***************
*** 1934,2178 ****
}
switch (smiValuePtr->basetype) {
! case SMI_BASETYPE_UNSIGNED32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*lu.",
! 1 + i,
! smiValuePtr->value.unsigned32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%lu", smiValuePtr->value.unsigned32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! smiAsprintf(&s, "%lx", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'o') {
! smiAsprintf(&s, "%lo", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 32 - 1;
! i > 0 && !(smiValuePtr->value.unsigned32 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", UINT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i,
! smiValuePtr->value.unsigned64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, UINT64_FORMAT, smiValuePtr->value.unsigned64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'o') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 64 - 1;
! i > 0 && !(smiValuePtr->value.unsigned64 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*ld.",
! 1 + i + (smiValuePtr->value.integer32 < 0 ? 1 : 0),
! smiValuePtr->value.integer32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lx", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lx", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lo", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lo", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer32 >= 0) {
! v32 = smiValuePtr->value.integer32;
! j = 0;
! } else {
! v32 = - smiValuePtr->value.integer32;
! j = 1;
! }
! for (i = 32 - 1;
! i > 0 && !(v32 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", INT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i + (smiValuePtr->value.integer64 < 0 ? 1 : 0),
! smiValuePtr->value.integer64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, INT64_FORMAT, smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer64 >= 0) {
! v64 = smiValuePtr->value.integer64;
! j = 0;
! } else {
! v64 = - smiValuePtr->value.integer64;
! j = 1;
! }
! for (i = 64 - 1;
! i > 0 && !(v64 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! s = smiRenderOID(smiValuePtr->len, smiValuePtr->value.oid, flags);
! break;
! case SMI_BASETYPE_OCTETSTRING:
! if (!(flags & SMI_RENDER_FORMAT) ||
! (!smiTypePtr->format &&
! (smiTypePtr->name && strcmp( smiTypePtr->name, "IpAddress")) ) ) {
! for (i = 0; i < smiValuePtr->len; i++) {
! if (!isprint((int)smiValuePtr->value.ptr[i])) break;
! }
! if ((i < smiValuePtr->len) ||
! !(flags & SMI_RENDER_PRINTABLE)) {
! smiAsprintf(&s, "");
! for (i=0; i < smiValuePtr->len; i++) {
! ss = s;
! smiAsprintf(&s, "%s%02x", ss, smiValuePtr->value.ptr[i]);
! smiFree(ss);
! }
! } else {
! smiAsprintf(&s, "%s", smiValuePtr->value.ptr);
! }
! } else {
! i = 0;
! smiAsprintf(&s, "");
! /* SNMPv2-SMI:IpAddress does not have a display hint.
! ==> let's use this one: "1d." if we have an IpAddress here */
! fmt = (smiTypePtr->name &&
! strcmp( smiTypePtr->name, "IpAddress" ) ) ?
! smiTypePtr->format : "1d.";
! while (*fmt && i < smiValuePtr->len) {
! last_fmt = fmt;
! have_pfx = pfx = 0; /* scan prefix: */
! while (*fmt && isdigit((int)*fmt)) {
! pfx = pfx * 10 + *fmt - '0', have_pfx = 1, fmt++;
! }
! if (! have_pfx) {
! pfx = 1;
! }
! switch (*fmt) {
! case 't':
! /* XXX UTF-8 not implemented, fall through to ASCII (a) */
! case 'a':
! n = (pfx < (smiValuePtr->len - i)) ?
! pfx : smiValuePtr->len - i;
for (k = 0; k < n; k++) {
if (! isascii((int) smiValuePtr->value.ptr[i+k])) {
smiFree(s);
--- 2118,2363 ----
}
switch (smiValuePtr->basetype) {
! case SMI_BASETYPE_UNSIGNED32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*lu.",
! 1 + i,
! smiValuePtr->value.unsigned32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%lu", smiValuePtr->value.unsigned32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! smiAsprintf(&s, "%lx", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'o') {
! smiAsprintf(&s, "%lo", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 32 - 1;
! i > 0 && !(smiValuePtr->value.unsigned32 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", UINT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i,
! smiValuePtr->value.unsigned64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, UINT64_FORMAT, smiValuePtr->value.unsigned64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'o') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 64 - 1;
! i > 0 && !(smiValuePtr->value.unsigned64 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*ld.",
! 1 + i + (smiValuePtr->value.integer32 < 0 ? 1 : 0),
! smiValuePtr->value.integer32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lx", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lx", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lo", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lo", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer32 >= 0) {
! v32 = smiValuePtr->value.integer32;
! j = 0;
! } else {
! v32 = - smiValuePtr->value.integer32;
! j = 1;
! }
! for (i = 32 - 1;
! i > 0 && !(v32 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", INT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i + (smiValuePtr->value.integer64 < 0 ? 1 : 0),
! smiValuePtr->value.integer64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, INT64_FORMAT, smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer64 >= 0) {
! v64 = smiValuePtr->value.integer64;
! j = 0;
! } else {
! v64 = - smiValuePtr->value.integer64;
! j = 1;
! }
! for (i = 64 - 1;
! i > 0 && !(v64 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! s = smiRenderOID(smiValuePtr->len, smiValuePtr->value.oid, flags);
! break;
! case SMI_BASETYPE_OCTETSTRING:
! if (!(flags & SMI_RENDER_FORMAT) ||
! (!smiTypePtr->format && !smiTypePtr->name) ||
! (!smiTypePtr->format &&
! (smiTypePtr->name && strcmp( smiTypePtr->name, "IpAddress")) ) ) {
! for (i = 0; i < smiValuePtr->len; i++) {
! if (!isprint((int)smiValuePtr->value.ptr[i])) break;
! }
! if ((i < smiValuePtr->len) ||
! !(flags & SMI_RENDER_PRINTABLE)) {
! smiAsprintf(&s, "");
! for (i=0; i < smiValuePtr->len; i++) {
! ss = s;
! smiAsprintf(&s, "%s%02x", ss, smiValuePtr->value.ptr[i]);
! smiFree(ss);
! }
! } else {
! smiAsprintf(&s, "%s", smiValuePtr->value.ptr);
! }
! } else {
! i = 0;
! smiAsprintf(&s, "");
! /* SNMPv2-SMI:IpAddress does not have a display hint.
! ==> let's use this one: "1d." if we have an IpAddress here */
! fmt = (smiTypePtr->name &&
! strcmp( smiTypePtr->name, "IpAddress" ) ) ?
! smiTypePtr->format : "1d.";
! while (*fmt && i < smiValuePtr->len) {
! last_fmt = fmt;
! have_pfx = pfx = 0; /* scan prefix: */
! while (*fmt && isdigit((int)*fmt)) {
! pfx = pfx * 10 + *fmt - '0', have_pfx = 1, fmt++;
! }
! if (! have_pfx) {
! pfx = 1;
! }
! switch (*fmt) {
! case 't':
! /* XXX UTF-8 not implemented, fall through to ASCII (a) */
! case 'a':
! n = (pfx < (smiValuePtr->len - i)) ?
! pfx : smiValuePtr->len - i;
for (k = 0; k < n; k++) {
if (! isascii((int) smiValuePtr->value.ptr[i+k])) {
smiFree(s);
***************
*** 2189,2332 ****
}
i += n;
break;
! case 'b':
! case 'd':
! case 'o':
! case 'x':
! /* XXX: limited to no more than
! sizeof(SmiUnsigned64) octets */
! vv = 0;
! xlen = pfx * 2;
! while (pfx > 0 && i < smiValuePtr->len) {
! vv = vv * 256 +
! ((unsigned char)smiValuePtr->value.ptr[i]);
! i++;
! pfx--;
! }
! switch (*fmt) {
! case 'd':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'o':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'x':
! ss = s;
! sprintf(f, "%%s%%0%s", UINT64_FORMAT);
! f[4] = '*';
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, ss, xlen, vv);
! smiFree(ss);
! break;
! case 'b':
! k = pfx * 8 - 1;
! if (k > sizeof(SmiUnsigned64) * 8 - 1)
! k = sizeof(SmiUnsigned64) * 8 - 1;
! for (j = 0; k >= 0; k--, j++) {
! ss = s;
! smiAsprintf(&s, "%s%c",
! ss, vv & (1 << k) ? '1' : '0');
! smiFree(ss);
! }
! break;
! }
! break;
! default:
! smiFree(s);
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! return s;
! }
! fmt++;
!
! /*
! * Check for a separator and repeat with last format if
! * data is still available.
! */
! if (*fmt && ! isdigit((int) *fmt) && *fmt != '*') {
! if (i < smiValuePtr->len) {
! ss = s;
! smiAsprintf(&s, "%s%c", ss, fmt[0]);
! smiFree(ss);
! }
! fmt++;
! }
!
! if (! *fmt && (i < smiValuePtr->len)) {
! fmt = last_fmt;
! }
! }
! }
! break;
! case SMI_BASETYPE_ENUM:
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.integer32 == smiValuePtr->value.integer32)
! break;
! }
! if (nn) {
! if (flags & SMI_RENDER_NUMERIC) {
! smiAsprintf(&s, "%s(%ld)",
! nn->name, nn->value.value.integer32);
! } else {
! smiAsprintf(&s, "%s", nn->name);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! break;
! case SMI_BASETYPE_BITS:
! smiAsprintf(&s, "");
! for (i = 0, nn = NULL; i < smiValuePtr->len * 8; i++) {
! if (smiValuePtr->value.ptr[i/8] & (1 << (7-(i%8)))) {
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.unsigned32 == i)
! break;
! }
! }
! ss = s;
! if ((flags & SMI_RENDER_NAME) &&
! (flags & SMI_RENDER_NUMERIC) && nn) {
! smiAsprintf(&s, "%s%s%s(%d)",
! ss, strlen(ss) ? " " : "", nn->name, i);
! } else if (nn) {
! smiAsprintf(&s, "%s%s%s",
! ss, strlen(ss) ? " " : "", nn->name);
! } else {
! smiAsprintf(&s, "%s%s%d",
! ss, strlen(ss) ? " " : "", i);
! }
! smiFree(ss);
! }
! }
! break;
! case SMI_BASETYPE_FLOAT32:
! case SMI_BASETYPE_FLOAT64:
! case SMI_BASETYPE_FLOAT128:
! case SMI_BASETYPE_UNKNOWN:
! default:
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! break;
}
return s;
--- 2374,2517 ----
}
i += n;
break;
! case 'b':
! case 'd':
! case 'o':
! case 'x':
! /* XXX: limited to no more than
! sizeof(SmiUnsigned64) octets */
! vv = 0;
! xlen = pfx * 2;
! while (pfx > 0 && i < smiValuePtr->len) {
! vv = vv * 256 +
! ((unsigned char)smiValuePtr->value.ptr[i]);
! i++;
! pfx--;
! }
! switch (*fmt) {
! case 'd':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'o':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'x':
! ss = s;
! sprintf(f, "%%s%%0%s", UINT64_FORMAT);
! f[4] = '*';
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, ss, xlen, vv);
! smiFree(ss);
! break;
! case 'b':
! k = pfx * 8 - 1;
! if (k > sizeof(SmiUnsigned64) * 8 - 1)
! k = sizeof(SmiUnsigned64) * 8 - 1;
! for (j = 0; k >= 0; k--, j++) {
! ss = s;
! smiAsprintf(&s, "%s%c",
! ss, vv & (1 << k) ? '1' : '0');
! smiFree(ss);
! }
! break;
! }
! break;
! default:
! smiFree(s);
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! return s;
! }
! fmt++;
!
! /*
! * Check for a separator and repeat with last format if
! * data is still available.
! */
! if (*fmt && ! isdigit((int) *fmt) && *fmt != '*') {
! if (i < smiValuePtr->len) {
! ss = s;
! smiAsprintf(&s, "%s%c", ss, fmt[0]);
! smiFree(ss);
! }
! fmt++;
! }
!
! if (! *fmt && (i < smiValuePtr->len)) {
! fmt = last_fmt;
! }
! }
! }
! break;
! case SMI_BASETYPE_ENUM:
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.integer32 == smiValuePtr->value.integer32)
! break;
! }
! if (nn) {
! if (flags & SMI_RENDER_NUMERIC) {
! smiAsprintf(&s, "%s(%ld)",
! nn->name, nn->value.value.integer32);
! } else {
! smiAsprintf(&s, "%s", nn->name);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! break;
! case SMI_BASETYPE_BITS:
! smiAsprintf(&s, "");
! for (i = 0, nn = NULL; i < smiValuePtr->len * 8; i++) {
! if (smiValuePtr->value.ptr[i/8] & (1 << (7-(i%8)))) {
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.unsigned32 == i)
! break;
! }
! }
! ss = s;
! if ((flags & SMI_RENDER_NAME) &&
! (flags & SMI_RENDER_NUMERIC) && nn) {
! smiAsprintf(&s, "%s%s%s(%d)",
! ss, strlen(ss) ? " " : "", nn->name, i);
! } else if (nn) {
! smiAsprintf(&s, "%s%s%s",
! ss, strlen(ss) ? " " : "", nn->name);
! } else {
! smiAsprintf(&s, "%s%s%d",
! ss, strlen(ss) ? " " : "", i);
! }
! smiFree(ss);
! }
! }
! break;
! case SMI_BASETYPE_FLOAT32:
! case SMI_BASETYPE_FLOAT64:
! case SMI_BASETYPE_FLOAT128:
! case SMI_BASETYPE_UNKNOWN:
! default:
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! break;
}
return s;
***************
*** 2391,2404 ****
unsigned int min = 65535, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! return 0;
! case SMI_BASETYPE_OCTETSTRING:
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 0;
! break;
! default:
! return 0;
}
for (smiRange = smiGetFirstRange(smiType);
--- 2576,2589 ----
unsigned int min = 65535, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! return 0;
! case SMI_BASETYPE_OCTETSTRING:
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 0;
! break;
! default:
! return 0;
}
for (smiRange = smiGetFirstRange(smiType);
***************
*** 2432,2446 ****
unsigned int max = 0, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! case SMI_BASETYPE_OCTETSTRING:
! size = 65535;
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 128;
! break;
! default:
! return 0xffffffff;
}
if (smiType->basetype == SMI_BASETYPE_BITS) {
--- 2617,2631 ----
unsigned int max = 0, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! case SMI_BASETYPE_OCTETSTRING:
! size = 65535;
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 128;
! break;
! default:
! return 0xffffffff;
}
if (smiType->basetype == SMI_BASETYPE_BITS) {
***************
*** 2492,2511 ****
}
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! */
! indexNode = NULL;
! break;
! case SMI_INDEX_AUGMENT:
! case SMI_INDEX_SPARSE:
! indexNode = smiGetRelatedNode(row);
! break;
! case SMI_INDEX_UNKNOWN:
! indexNode = NULL;
! break;
}
*valslen = 0;
--- 2677,2696 ----
}
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! */
! indexNode = NULL;
! break;
! case SMI_INDEX_AUGMENT:
! case SMI_INDEX_SPARSE:
! indexNode = smiGetRelatedNode(row);
! break;
! case SMI_INDEX_UNKNOWN:
! indexNode = NULL;
! break;
}
*valslen = 0;
***************
*** 2532,2552 ****
fprintf(stderr, "** %s (%s)\n", iNode->name, iType->name);
(*vals)[i].basetype = iType->basetype;
switch (iType->basetype) {
! case SMI_BASETYPE_ENUM:
! case SMI_BASETYPE_INTEGER32:
! (*vals)[i].value.integer32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! (*vals)[i].value.unsigned32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_OCTETSTRING:
! /* need to know whether implied/fixed length or not */
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! /* need to know whether implied/fixed length or not */
! break;
! default:
! return 0;
}
}
--- 2717,2737 ----
fprintf(stderr, "** %s (%s)\n", iNode->name, iType->name);
(*vals)[i].basetype = iType->basetype;
switch (iType->basetype) {
! case SMI_BASETYPE_ENUM:
! case SMI_BASETYPE_INTEGER32:
! (*vals)[i].value.integer32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! (*vals)[i].value.unsigned32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_OCTETSTRING:
! /* need to know whether implied/fixed length or not */
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! /* need to know whether implied/fixed length or not */
! break;
! default:
! return 0;
}
}
***************
*** 2600,2665 ****
min->basetype = max->basetype = basetype;
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! min->value.integer32 = SMI_BASETYPE_INTEGER32_MAX;
! max->value.integer32 = SMI_BASETYPE_INTEGER32_MIN;
! break;
! case SMI_BASETYPE_INTEGER64:
! min->value.integer64 = SMI_BASETYPE_INTEGER64_MAX;
! max->value.integer64 = SMI_BASETYPE_INTEGER64_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! min->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MAX;
! max->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED64:
! min->value.unsigned64 = SMI_BASETYPE_UNSIGNED64_MAX;
! max->value.unsigned64 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
for (range = smiGetFirstRange(smiType);
range;
range = smiGetNextRange(range)) {
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! if (range->minValue.value.integer32 < min->value.integer32) {
! min->value.integer32 = range->minValue.value.integer32;
! }
! if (range->maxValue.value.integer32 > max->value.integer32) {
! max->value.integer32 = range->maxValue.value.integer32;
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (range->minValue.value.integer64 < min->value.integer64) {
! min->value.integer64 = range->minValue.value.integer64;
! }
! if (range->maxValue.value.integer64 > max->value.integer64) {
! max->value.integer64 = range->maxValue.value.integer64;
! }
! break;
! case SMI_BASETYPE_UNSIGNED32:
! if (range->minValue.value.unsigned32 < min->value.unsigned32) {
! min->value.unsigned32 = range->minValue.value.unsigned32;
! }
! if (range->maxValue.value.unsigned32 > max->value.unsigned32) {
! max->value.unsigned32 = range->maxValue.value.unsigned32;
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (range->minValue.value.unsigned64 < min->value.unsigned64) {
! min->value.unsigned64 = range->minValue.value.unsigned64;
! }
! if (range->maxValue.value.unsigned64 > max->value.unsigned64) {
! max->value.unsigned64 = range->maxValue.value.unsigned64;
! }
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
}
--- 2785,2850 ----
min->basetype = max->basetype = basetype;
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! min->value.integer32 = SMI_BASETYPE_INTEGER32_MAX;
! max->value.integer32 = SMI_BASETYPE_INTEGER32_MIN;
! break;
! case SMI_BASETYPE_INTEGER64:
! min->value.integer64 = SMI_BASETYPE_INTEGER64_MAX;
! max->value.integer64 = SMI_BASETYPE_INTEGER64_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! min->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MAX;
! max->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED64:
! min->value.unsigned64 = SMI_BASETYPE_UNSIGNED64_MAX;
! max->value.unsigned64 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
for (range = smiGetFirstRange(smiType);
range;
range = smiGetNextRange(range)) {
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! if (range->minValue.value.integer32 < min->value.integer32) {
! min->value.integer32 = range->minValue.value.integer32;
! }
! if (range->maxValue.value.integer32 > max->value.integer32) {
! max->value.integer32 = range->maxValue.value.integer32;
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (range->minValue.value.integer64 < min->value.integer64) {
! min->value.integer64 = range->minValue.value.integer64;
! }
! if (range->maxValue.value.integer64 > max->value.integer64) {
! max->value.integer64 = range->maxValue.value.integer64;
! }
! break;
! case SMI_BASETYPE_UNSIGNED32:
! if (range->minValue.value.unsigned32 < min->value.unsigned32) {
! min->value.unsigned32 = range->minValue.value.unsigned32;
! }
! if (range->maxValue.value.unsigned32 > max->value.unsigned32) {
! max->value.unsigned32 = range->maxValue.value.unsigned32;
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (range->minValue.value.unsigned64 < min->value.unsigned64) {
! min->value.unsigned64 = range->minValue.value.unsigned64;
! }
! if (range->maxValue.value.unsigned64 > max->value.unsigned64) {
! max->value.unsigned64 = range->maxValue.value.unsigned64;
! }
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
}
Diff finished. Tue Nov 04 21:36:07 2008
....................
2
2
Juergen,
Thank you for fixing smi.c for MS cl/v6.0. I updated my subversion
tree and compiled smi.c ok (using MS cl v6.0).
The warning below "conversion from 'unsigned __int64 ' to 'int" in
parser-sming.c may be problematic.
There are several other "known" warnings that seem ok to live with. I
can email if you like.
Thank you,
--
- Yigal
....................
cl -Z7 -Od -c -W3 -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -D_X86_=1 -D_WINNT -D_WIN32_WINNT=0x0400 -D_WIN32_IE=0x0300 -DWINVER=0x0400 -DWIN32 -DNULL=0 -D_MT -D_DLL /MD -I.\..\lib -I.\..\win -IC:\PROGRA~1\MICROS~2\VC98\include -DYYMALLOC=malloc -DYYFREE=free -D_CRT_SECURE_NO_DEPRECATE=1 -Fo.\ .\..\lib\parser-sming.c
parser-sming.c
parser-sming.y(320) : warning C4244: '=' : conversion from 'unsigned __int64 ' to 'int ', possible loss of data
parser-sming.y(2167) : warning C4047: 'function' : 'struct List *' differs in levels of indirection from 'int '
parser-sming.y(2167) : warning C4024: 'setAttributeList' : different types for formal and actual parameter 2
parser-sming.y(2168) : warning C4047: '=' : 'struct List *' differs in levels of indirection from 'int '
....................
1
0