📄 smoid.c
字号:
yyerror(
"\"%s\" and \"%s\" from \"%s\" have same registration value",
pOid->pszName, pT->pszName,
(pT->pMod)->pszName);
}
#ifdef OLD
yyterm();
return(NULL);
#endif
break; /* insert */
}
}
if (pOT == NULL) {
/* insert as first child */
pPar->ut.oid.pChild = pOid;
} else {
/* insert in list */
pOT->ut.oid.pSib = pOid;
}
pOid->ut.oid.pSib = pT;
return(pOid);
} /* addOIDname */
/** hexVal - convert hex char to value
*
* call with:
* ch - char
*
* returns:
* value
*/
USHORT
#ifdef __STDC__
hexVal(CHAR ch)
#else
hexVal(ch)
CHAR ch;
#endif
{
register USHORT us;
if ((ch >= '0') && (ch <= '9')) {
us = ch - '0';
} else if ((ch >= 'A') && (ch <= 'F')) {
us = ch - 'A' + 10;
} else {
us = ch - 'a' + 10;
}
return(us);
} /* hexVal */
#define CTABLE 5
#define PSZTABLE "Table"
#define CENTRY 5
#define PSZENTRY "Entry"
/** checkOIDs - that that all OIDs for a module are defined
* (ie no forward references)
* call with:
* pMod - module to check
*/
VOID
#ifdef __STDC__
checkOIDs(MIBSYM *pMod)
#else
checkOIDs(pMod)
MIBSYM *pMod;
#endif /* __STDC__ */
{
MIBSYM *pT;
MIBSYM *pSym;
USHORT usSyntax;
MIBSYM *pO;
MIBINDX *pIndx;
MIBSEQI *pSi;
MIBSYM *pSeq;
MIBSYM *pSeqPar;
USHORT cNa;
USHORT cNaPre;
MIBENUM *pE;
USHORT usSizeRange;
BOOL fNoSR;
STRTAB *pNa;
USHORT i;
PSZ psz;
for (pT = pOidGHL; pT != NULL; pT = pT->pNext) {
if (pT->pMod != pMod)
continue;
if (!islower(*(pT->pszName))) {
yywarning("Name of OID object \"%s\" must start with lowercase letter",
pT->pszName);
}
if (pT->usType & MIBSYMFR) {
yyerror("\"%s\" referenced but not defined",
pT->pszName);
}
pO = pT->ut.oid.pPar; /* get parent */
/* check that there is no sibling with the same name,
* but ignore duplicate definitions */
if (pO != NULL) {
for (pSym = pT->pSym; pSym != NULL; pSym = pSym->pSym) {
if ((pSym->usType & MIBSYMmask) != MIBSYMoid)
continue; /* skip non-OID items */
if ((pSym->ut.oid.ulVal != pT->ut.oid.ulVal) &&
(pSym->ut.oid.pPar == pO)) {
yyerror("Item \"%s\" has sibling in OID tree from module \"%s\" with the same name",
pT->pszName, (pSym->pMod)->pszName);
break;
}
}
}
/* check semantics based on type */
switch(pT->ut.oid.usOType) {
case MIBOToid:
/* pure OID */
/* check that parent is OID */
if ((pO != NULL) && (pO->ut.oid.usOType != MIBOToid)) {
yyerror("Object identifier \"%s\" should be registered under an object identifier",
pT->pszName);
}
break;
case MIBOTtab:
/* SNMP table */
/* check that parent is an OID */
if ((pO != NULL) && (pO->ut.oid.usOType != MIBOToid)) {
yyerror("Table \"%s\" should be registered under an object identifier",
pT->pszName);
}
/* check that suffix of name is "Table" */
cNa = strlen(pT->pszName);
if ((cNa < CTABLE) ||
(strcmp((pT->pszName)+(cNa-CTABLE), PSZTABLE) != 0)) {
if (!fNoCheckTab)
yywarning("Name of table \"%s\" should end with Table",
pT->pszName);
}
/* syntax is seq of */
if (pT->ut.oid.syn.usSyntax != MIBSYNseqOf) {
yyerror("\"%s\" has invalid syntax for a table",
pT->pszName);
}
/* must have row defined */
pO = pT->ut.oid.pChild;
if ((pO == NULL) || (pO->ut.oid.usOType != MIBOTrow)) {
yyerror("Table \"%s\" does not have a row defined",
pT->pszName);
}
/* access is not-accessible */
if (!fAllowAccess && (pT->ut.oid.usAccess != MIBACCna) &&
(pT->ut.oid.usAccess != MIBACCbad)) {
yyerror("Table \"%s\" must have access of \"not-accessible\"",
pT->pszName);
}
/* status is mandatory, deprecated, or obsolete */
if ((pT->usStatus != MIBSTAma) &&
(pT->usStatus != MIBSTAde) &&
(pT->usStatus != MIBSTAob) &&
(pT->usStatus != MIBSTAbad) &&
!fAllowOpt) {
yyerror("Table \"%s\" must have status of \"mandatory\", \"deprecated\", or \"obsolete\"",
pT->pszName);
}
/* no index */
if (pT->ut.oid.cIndx != 0) {
yyerror("Table \"%s\" can have not INDEX items specified",
pT->pszName);
}
/* no defval */
if (pT->ut.oid.usDefVal != MIBDFVno) {
yyerror("Table \"%s\" can have not a DEFAULT value specified",
pT->pszName);
}
break;
case MIBOTrow:
/* SNMP row */
/* check that suffix of name is Entry */
cNa = strlen(pT->pszName);
cNaPre = cNa - CENTRY;
if ((cNa < CENTRY) ||
(strcmp((pT->pszName)+(cNa-CENTRY), PSZENTRY) != 0)) {
if (!fNoCheckTab)
yywarning("Name of row \"%s\" should end with Entry",
pT->pszName);
cNaPre = 0;
}
/* syntax is seq */
if (pT->ut.oid.syn.usSyntax != MIBSYNseq) {
yyerror("\"%s\" has invalid syntax for a row",
pT->pszName);
pSeq = NULL;
} else {
/* get sequence */
pSeq = pT->ut.oid.syn.usi.pSeq;
}
/* must have table defined */
if ((pO == NULL) || (pO->ut.oid.usOType != MIBOTtab)) {
yyerror("Row \"%s\" does not have a containing table defined",
pT->pszName);
} else {
/* parent exists and is a table */
if (cNaPre != 0) {
/* check that parent has same prefix */
cNa = strlen(pO->pszName);
if ((cNa > CTABLE) &&
(strncmp(pT->pszName, pO->pszName,
cNaPre) != 0)) {
if (!fNoCheckTab)
yywarning("Table \"%s\" and Row \"%s\" should have same name prefix",
pO->pszName, pT->pszName);
}
/* check that seq name matches except for first char */
if ((pSeq != NULL) &&
(((INT)(*(pSeq->pszName)) !=
toupper(*(pT->pszName))) ||
(strcmp(pSeq->pszName+1, pT->pszName+1) != 0))) {
if (!fNoCheckTab)
yywarning("Sequence \"%s\" and Row \"%s\" should have related names",
pSeq->pszName, pT->pszName);
}
}
/* check that parent has same sequence */
if (pO->ut.oid.syn.usSyntax != MIBSYNseqOf) {
pSeqPar = NULL;
} else {
/* get parents's sequence */
pSeqPar = pO->ut.oid.syn.usi.pSeq;
}
if ((pSeq != NULL) && (pSeqPar != NULL) &&
(pSeq != pSeqPar)) {
yyerror("Row \"%s\" and Table \"%s\" must use the same sequence",
pT->pszName, pO->pszName);
}
}
/* access is not-accessible */
if (!fAllowAccess && (pT->ut.oid.usAccess != MIBACCna) &&
(pT->ut.oid.usAccess != MIBACCbad)) {
yyerror("Row \"%s\" must have access of \"not-accessible\"",
pT->pszName);
}
/* status is mandatory, deprecated, or obsolete */
if ((pT->usStatus != MIBSTAma) &&
(pT->usStatus != MIBSTAde) &&
(pT->usStatus != MIBSTAob) &&
(pT->usStatus != MIBSTAbad) &&
!fAllowOpt) {
yyerror("Row \"%s\" must have status of \"mandatory\", \"deprecated\", or \"obsolete\"",
pT->pszName);
}
/* must have index */
if (pT->ut.oid.cIndx == 0) {
yyerror("Row \"%s\" must have INDEX items specified",
pT->pszName);
}
if (pSeq != NULL) {
/* check for these normal case items, but with
flags to turn off error messages */
/* indices must be objects (or limited syntax items) */
/* indices must be in sequence */
/* indices must be read-only */
/* indices must have no defval */
/* indices that are octet string must size specified */
/* indices that are integer must have non-negative range */
/*?? syntax type check for indices */
for (pIndx = pT->ut.oid.pIndxL; pIndx != NULL;
pIndx = pIndx->pNext) {
if (pIndx->usItype == MIBITnloct) {
/* index is no length OCTET STRING */
/* check that no items follow */
if (pIndx->pNext != NULL) {
yyerror("Row \"%s\" has index item NOLENGTH OCTET STRING which is not the last item",
pT->pszName);
continue;
}
} else if (pIndx->usItype == MIBITnloid) {
/* index is no length OBJECT IDENTIFIER */
/* check that no items follow */
if (pIndx->pNext != NULL) {
yyerror("Row \"%s\" has index item NOLENGTH OBJECT IDENTIFIER which is not the last item",
pT->pszName);
continue;
}
} else if ((pIndx->usItype == MIBITobj) ||
(pIndx->usItype == MIBITnlobj)) {
pO = pIndx->pOid;
if (pO->ut.oid.usOType != MIBOTobj) {
yyerror("Row \"%s\" has index item \"%s\" not defined as an object",
pT->pszName, pO->pszName);
continue;
}
for (pSi = pSeq->ut.seq.pSeqIL; pSi != NULL;
pSi = pSi->pNext) {
/* check for match in sequence with index */
if (pSi->pOid == pO)
break;
}
if (fCheckIndxSeq && (pSi == NULL)) {
/* index item not in sequence */
yyerror("Row \"%s\" has index item \"%s\" which is not defined in sequence",
pT->pszName, pO->pszName);
}
if (fCheckRoIndx && (pO->ut.oid.usAccess != MIBACCro)) {
yyerror("Row \"%s\" has index item \"%s\" whose access must be \"read-only\"",
pT->pszName, pO->pszName);
}
if (pO->ut.oid.usDefVal != MIBDFVno) {
yyerror("Row \"%s\" has index item \"%s\" which must not have a DEFAULT value",
pT->pszName, pO->pszName);
}
usSyntax = pO->ut.oid.rsyn.usSyntax;
usSizeRange = pO->ut.oid.rsyn.usSizeRange;
/* check integers to make sure that range is non-negative*/
if (usSyntax == MIBSYNint) {
if (fCheckISR && (usSizeRange != MIBSRpp)) {
yyerror("Row \"%s\" has index item \"%s\" which must have a non-negative range specified",
pT->pszName, pO->pszName);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -