mibble-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mibble-users] Reverse usage of mibble


From: Louis GOUNOT
Subject: Re: [Mibble-users] Reverse usage of mibble
Date: Mon, 15 Mar 2004 10:44:32 +0100

Hi,

> Yes, tables are problematic. As far as I have seen, most of the
> tableEntry symbols in the MIBs are declared to have an oid ending
> with .1 (not .0) so that might help in some cases.
In my point of view, as I've read about in different RFCs, tableEntry
symbols are compound of :
          the tableEntry OID,
          a dot character,
          the row index in the table.
But it seems to be different in some other cases (I don't remember them, but
somteimes you have a concatenation of an OID and of an IP address)

> In the general case, however, Mibble does not provide any real
> intelligence for reverse lookup (oid -> symbol). It might be
> possible to implement with something like this:
>
>   MibValueSymbol findSymbolByOid(Mib mib, String oid) {
>        MibValueSymbol  sym;
>        int             pos;
>        int             value;
>
>        sym = mib.getSymbolByValue(oid);
>        if (sym == null) {
>            pos = oid.lastIndexOf(".");
>            if (pos > 0) {
>                sym = findSymbolByOid(mib, oid.substring(0, pos));
>            }
>            if (sym != null) {
>                value = Integer.parseInt(oid.substring(pos + 1));
>                sym = findSymbolChild(sym, value);
>            }
>        }
>        return sym;
>   }
>
>   MibValueSymbol findSymbolChild(MibValueSymbol sym, int value) {
>       ObjectIdentifierValue  oid;
>
>       if (!(sym.getValue() instanceof ObjectIdentifierValue)) {
>           return null;
>       }
>       oid = (ObjectIdentifierValue) sym.getValue();
>       for (int i = 0; i < oid.getChildCount(); i++) {
>           if (oid.getChild(i).getValue() == value) {
>               return oid.getChild(i).getSymbol();
>           }
>       }
>       if (oid.getChildCount() == 1) {
>           return oid.getChild(0).getSymbol();
>       }
>       return null;
>   }
>
> I haven't had time to test the code above, so it might still
> contain compilation errors (and other errors as well). Please
> test and write back and tell me if it worked or not. If it
> works I might include it somewhere in the next release.
>

I haven't got the time to test the code yet, thanks a lot anyway.

Cheers,

Louis
_______________________________________________
> Mibble-users mailing list
> address@hidden
> http://mail.nongnu.org/mailman/listinfo/mibble-users
>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]