On Wed, 17 Jan 2007 22:12:44 -0600 (CST) [EMAIL PROTECTED] wrote:
MIC> xxxTable_container_load()

What release did you use to generate the code?

MIC> The test used befor populating a column defined as:
MIC>   wpiPath   DisplayString
MIC> 
MIC>      /* Code taht I have problem with */
MIC> 
MIC>      if ((NULL == rowreq_ctx->data.wpiPath) ||
MIC>          (rowreq_ctx->data.wpiPath_len <
MIC>          (wpiPath_len * sizeof(wpiPath[0])))) {
MIC>        snmp_log(LOG_ERR, "not enoughhhhh space for value %s %d\n",wpiPath, 
MIC> wpiPath_len);
MIC>        return MFD_ERROR;
MIC>      }
[...]
MIC>   "if" above will always fail because the generated data structor for 
MIC> wpiPath by mib2c is:
[...]
MIC>          char            wpiPath[255];
MIC>          size_t          wpiPath_len;    /* # of char elements, not bytes 
*/
MIC> 
MIC> Would it not always fail? because rowreq_ctx->data.wpiPath_len has not 
MIC> been populated

If the structure has not been populated, yes. Given the multitude of
configuration options in mfd that affect code generation, it is possible that
there is a case where either a comment or initialization is missing. It's hard
to tell, given just the snippets you sent. Can you send me the whole set of
source files (off-list)?

MIC>, and also what does "of char elements, not  bytes" means in 
MIC> above aomments. wouldn't wpiPath_len * sizeof(wpiPath[0]))  still be 
MIC> strlen(wpiPath).

1) the same template code is used for other types. For example, an OID. OIDs
are 4 bytes, so the point is that the len would be the number of OIDs, not
number of bytes (which would be 4 times to big).

2) snmp string do not need to be NULL terminated, so you should never user
strlen on them.

MIC> The MFD tutorial is using hardcoded values like 6 for ifPhysAddress_len, 
MIC> how would I calculate the length (wpi_len)?.
MIC> 
MIC> Would I be doing semething wrong by using:
MIC>    if((wpiPath_len * sizeof(wpiPath[0])) > 255){
MIC>     Or in this case just
MIC>        if(wpiPath_len > 255){

Actually, the simplest and safest case, assuming char, would be

    if(wpiPath_len > (sizeof(rowreq_ctx->data.wpiPath)) {

MIC> 2) Is there any performance loss using MFD compared to older ways of 
MIC> implementing the MIB.

Of course. An experienced code could always handcraft something that would be
more efficient. Some of the other mib2c templates would be more efficient,
some would be less efficient. But none of them automatically handle as many of
the tricky details of implementing a mib module. The mfd template is like
paint-by-numbers. What you get might not be a beautiful work of art, but it
should be functional and just about anyone can do it. (I hope!)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to