@@ -156,6 +156,7 @@ struct tc { /* textual conventions */
156156 struct enum_list * enums ;
157157 struct range_list * ranges ;
158158 char * description ;
159+ int lineno ;
159160} * tclist ;
160161int tc_alloc ;
161162
@@ -1842,15 +1843,11 @@ do_linkup(struct module *mp, struct node *np)
18421843 nbuckets [i ] = NULL ;
18431844 while (onp ) {
18441845 snmp_log (LOG_WARNING ,
1845- "Unlinked OID in %s: %s ::= { %s %ld }\n" ,
1846+ "Cannot resolve OID in %s: %s ::= { %s %ld } at line %d in %s \n" ,
18461847 (mp -> name ? mp -> name : "<no module>" ),
18471848 (onp -> label ? onp -> label : "<no label>" ),
18481849 (onp -> parent ? onp -> parent : "<no parent>" ),
1849- onp -> subid );
1850- snmp_log (LOG_WARNING ,
1851- "Undefined identifier: %s near line %d of %s\n" ,
1852- (onp -> parent ? onp -> parent : "<no parent>" ),
1853- onp -> lineno , onp -> filename );
1850+ onp -> subid , onp -> lineno , onp -> filename );
18541851 np = onp ;
18551852 onp = onp -> next ;
18561853 }
@@ -2212,11 +2209,32 @@ parse_enumlist(FILE * fp, struct enum_list **retp)
22122209 return NULL ;
22132210 }
22142211 (* epp )-> value = strtol (token , NULL , 10 );
2212+ (* epp )-> lineno = mibLine ;
22152213 type = get_token (fp , token , MAXTOKEN );
22162214 if (type != RIGHTPAREN ) {
22172215 print_error ("Expected \")\"" , token , type );
22182216 return NULL ;
22192217 }
2218+ else {
2219+ struct enum_list * op = ep ;
2220+ while (op != * epp ) {
2221+ if (strcmp ((* epp )-> label , op -> label ) == 0 ) {
2222+ snmp_log (LOG_ERR ,
2223+ "Duplicate enum label '%s' at line %d in %s. First at line %d\n" ,
2224+ (* epp )-> label , mibLine , File , op -> lineno );
2225+ erroneousMibs ++ ;
2226+ break ;
2227+ }
2228+ else if ((* epp )-> value == op -> value ) {
2229+ snmp_log (LOG_ERR ,
2230+ "Duplicate enum value '%d' at line %d in %s. First at line %d\n" ,
2231+ (* epp )-> value , mibLine , File , op -> lineno );
2232+ erroneousMibs ++ ;
2233+ break ;
2234+ }
2235+ op = op -> next ;
2236+ }
2237+ }
22202238 epp = & (* epp )-> next ;
22212239 }
22222240 }
@@ -2436,26 +2454,37 @@ parse_asntype(FILE * fp, char *name, int *ntype, char *ntoken)
24362454 /*
24372455 * textual convention
24382456 */
2457+ tcp = NULL ;
24392458 for (i = 0 ; i < tc_alloc ; i ++ ) {
2440- if (tclist [i ].type == 0 )
2441- break ;
2459+ if (tclist [i ].type == 0 ) {
2460+ if (tcp == NULL ) tcp = & tclist [i ];
2461+ }
2462+ else
2463+ if (strcmp (name , tclist [i ].descriptor ) == 0 &&
2464+ tclist [i ].modid == current_module ) {
2465+ snmp_log (LOG_ERR ,
2466+ "Duplicate TEXTUAL-CONVENTION '%s' at line %d in %s. First at line %d\n" ,
2467+ name , mibLine , File , tclist [i ].lineno );
2468+ erroneousMibs ++ ;
2469+ }
24422470 }
24432471
2444- if (i == tc_alloc ) {
2472+ if (tcp == NULL ) {
24452473 tclist = realloc (tclist , (tc_alloc + TC_INCR )* sizeof (struct tc ));
24462474 memset (tclist + tc_alloc , 0 , TC_INCR * sizeof (struct tc ));
2475+ tcp = tclist + tc_alloc ;
24472476 tc_alloc += TC_INCR ;
24482477 }
24492478 if (!(type & SYNTAX_MASK )) {
24502479 print_error ("Textual convention doesn't map to real type" ,
24512480 token , type );
24522481 goto err ;
24532482 }
2454- tcp = & tclist [i ];
24552483 tcp -> modid = current_module ;
24562484 tcp -> descriptor = strdup (name );
24572485 tcp -> hint = hint ;
24582486 tcp -> description = descr ;
2487+ tcp -> lineno = mibLine ;
24592488 tcp -> type = type ;
24602489 * ntype = get_token (fp , ntoken , MAXTOKEN );
24612490 if (* ntype == LEFTPAREN ) {
@@ -4027,12 +4056,11 @@ adopt_orphans(void)
40274056 while (onp ) {
40284057 char modbuf [256 ];
40294058 snmp_log (LOG_WARNING ,
4030- "Cannot adopt OID in %s: %s ::= { %s %ld }\n" ,
4059+ "Cannot resolve OID in %s: %s ::= { %s %ld } at line %d in %s \n" ,
40314060 module_name (onp -> modid , modbuf ),
40324061 (onp -> label ? onp -> label : "<no label>" ),
40334062 (onp -> parent ? onp -> parent : "<no parent>" ),
4034- onp -> subid );
4035-
4063+ onp -> subid , onp -> lineno , onp -> filename );
40364064 np = onp ;
40374065 onp = onp -> next ;
40384066 }
@@ -4622,6 +4650,7 @@ parse(FILE * fp)
46224650 goto free_mib ;
46234651 }
46244652 if (nnp ) {
4653+ struct node * op ;
46254654 if (np )
46264655 np -> next = nnp ;
46274656 else
@@ -4630,6 +4659,16 @@ parse(FILE * fp)
46304659 np = np -> next ;
46314660 if (np -> type == TYPE_OTHER )
46324661 np -> type = type ;
4662+ op = root ;
4663+ while (op != nnp ) {
4664+ if (strcmp (nnp -> label , op -> label ) == 0 && nnp -> subid != op -> subid ) {
4665+ snmp_log (LOG_ERR ,
4666+ "Duplicate Object '%s' at line %d in %s. First at line %d\n" ,
4667+ op -> label , mibLine , File , op -> lineno );
4668+ erroneousMibs ++ ;
4669+ }
4670+ op = op -> next ;
4671+ }
46334672 }
46344673 }
46354674 DEBUGMSGTL (("parse-file" , "End of file (%s)\n" , File ));
0 commit comments