FAQ:Coding 17
How can I support a large table, with more than 256 column objects?
This is a problem (at least apparently) with the v4 UCD module API, which uses a "magic number" to distinguish between the various column objects implemented by a common variable handling routine. Since this field is defined as an unsigned character, it can only take values 0-255. So at first sight, it would appear that the agent cannot support tables (or scalar groups) with more than 256 objects, since this would start to duplicate these magic numbers.
However, the agent doesn't actually care which routine implements a given object, and magic numbers only need to be unique within a single variable handling routine. So it is actually perfectly possible to implement a larger table by splitting it between two (or more) variable handling routines. These can then re-use the magic numbers quite safely:
struct variable1 [] = { {MAGIC1, ASN_INTEGER, RWRITE, var_myfirst, 1, { 1}}, {MAGIC2, ASN_INTEGER, RWRITE, var_myfirst, 1, { 2}}, : {MAGIC255, ASN_INTEGER, RWRITE, var_myfirst, 1, {255}}, {MAGIC1, ASN_INTEGER, RWRITE, var_mysecond, 1, {256}}, {MAGIC2, ASN_INTEGER, RWRITE, var_mysecond, 1, {257}}, : {MAGIC255, ASN_INTEGER, RWRITE, var_mysecond, 1, {510}} };
All that matters is that a given magic number isn't re-used within the same variable handling routine. The v5 table handlers typically use an integer variable for holding column information, so aren't subject to the same limitations.
Though I'd have to question whether having such a wide table is necessarily a particularly good design strategy!
FAQ:Coding
- How do I write C code to integrate with the agent?
- How does the agent fetch the value of a MIB variable from the system?
- Mib2c complains about a missing "mib reference" - what does this mean?
- Mib2c complains about not having a "valid OID" - what does this mean?
- Why doesn't mib2c like the MIB file I'm giving it?
- Mib2c ignores my MIB and generates a pair of 'mib-2' code files. Why?
- What's the difference between the various mib2c configuration files?
- Which mib2c configuration file should I use?
- How can I have mib2c generate code for both scalars and tables?
- Are there any examples, or documentation for generating MIB modules?
- Where should I put the files produced by 'mib2c'?
- Why doesn't my new MIB module report anything?
- Why does the iterator call my get_{first,next} routines so often?
- How can I get the agent to generate a trap (or inform)?
- How can I get an AgentX sub-agent to generate a trap (or inform)?
- How can I get the agent to send an SNMPv1 (or SNMPv2c) trap?
- How can I get the agent to include varbinds with an SNMPv1 trap?
- How can I get the agent to send an SNMPv1 enterprise-specific trap?
- How can I get the agent to send an SNMPv3 trap (or inform)?
- Why does calling 'send_v2trap' generate an SNMPv1 trap (or vice versa)?
- How can I register a MIB module in a different (SNMPv3) context?