0

I am trying to upgrade an old .config file that is used as a template by mib2c function to generate C-codes. The most of variable's attributes are described here, but I can not find anything about .needlength one. Any ideas what it means? Can it be substituted with another attribute that is documented?

@if $var.needlength@
Nazar
  • 820
  • 5
  • 13
  • 36

1 Answers1

1

Looking at the source code in /usr/bin/mib2c, I believe the only place needlength appears is this line:

$it =~ s/\$(\w+)\.(needlength)/$perltolen{$SNMP::MIB{$vars{$1}}{type}}/g;

and we have:

%perltolen = ("OCTETSTR",  "1",
           "INTEGER",  "0",
           "INTEGER32",  "0",
           "UNSIGNED32", "0",
           "UINTEGER", "0",
           "OBJECTID", "1",
           "COUNTER64", "0",
           "COUNTER", "0",
           "IPADDR", "0",
           "BITS", "1",
           "TICKS", "0",
           "GAUGE", "0",
           "OPAQUE", "1");

So, it looks like @if $var.needlength@ distinguishes between types whose length need to be specified from those that do not need it.

And, no, I do not think it can be replaced with another attribute.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
  • Does it mean that only variables whose type is "OCTETSTR", "OBJECTID", "BITS" and "OPAQUE" would return 1 on .needlength? Also, what does it mean "to specify variable length" in this specific context? – Nazar Jun 16 '17 at 17:51
  • 1
    @Naz If you have a table with an OCTETSTR as index, then the index's length varies because it is coded as `length.char(0).char(1)...char(n)` (e.g. `$base.3.65.66.67` for the index `"ABC"`). Compare to INTEGER with a fixed size. I think that is what is meant here. – PerlDuck Jun 16 '17 at 18:05