Ok, after being away for a couple of weeks (I had to unsubscribe to the mailing list) I'm back to looking at this but sadly no replies in the archive to date... any ideas/suggestions/pointers at all?
Thanks, Mike -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, February 22, 2007 6:06 PM To: [email protected] Subject: RE: Table split over subagents - register_int_index always returns -1 Ok, I took a look at what was happening with ddd/gdb and it appears that "main_session" is NULL on entry into the register_int_index function, which passes it on to the register_index function and then on to the agentx_register_index at which point it exits and returns NULL because it carries out a NULL check on the value being passed in. Allowing the code to continue I see that "main_session" does get set when init_snmp calls read_configs - the debugger loses itself on attempting to trace into that unfortunately so I'd need to manually trace the code (will have a look tomorrow). So, looking at the various code examples of the call to register_int_index I'm using it at the right point but without "main_session" being set it'll always fail. Any ideas? Have I got the order of function calls wrong? Thanks, Mike -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, 21 February 2007 16:58 To: [email protected] Subject: Table split over subagents - register_int_index always returns -1 Hi all, I'm a newbie to the whole snmp/mib thing so hope not to tread on any toes whilst making this first (rather long) post... My requirement is to have several applications running on a single piece of hardware with each application needing to be able to respond to "gets". I've had a look through the mail archive and have found several posts that lead me to believe that the agentx master/slave set-up is exactly what I'm after. >From reading the posts it seems that a table holding information common to each application would be a good place to start; each application will supply a "row" of information for the table. Just to get development start I've got net-snmp 5.4 built and installed on a PC running RedHat 9. As far as I can see it's all gone ok, I can run up snmpd as master and build and run some of the examples as subagents. In order to achieve what I'm after the various posts have talked about using the 'register_int_index' function with 'ANY_INTEGER_INDEX' in order to get the next available index and then using that to add a row to the table. Unfortunately that's where my first stumbling block occurs; the function always returns -1 i.e. it fails So, what am I doing wrong or have I completely got the wrong end of the stick? I've added the following to the NET-SNMP-EXAMPLES-MIB just to get me going: netSnmpITSAppTable OBJECT-TYPE SYNTAX SEQUENCE OF NetSnmpITSAppEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "An ITS application table" ::= { netSnmpExampleTables 3 } netSnmpITSAppEntry OBJECT-TYPE SYNTAX NetSnmpITSAppEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "An ITS application" INDEX { netSnmpITSAppIndex } ::= { netSnmpITSAppTable 1 } NetSnmpITSAppEntry ::= SEQUENCE { netSnmpITSAppIndex INTEGER, netSnmpITSAppName OCTET STRING, netSnmpITSAppId OCTET STRING } netSnmpITSAppIndex OBJECT-TYPE SYNTAX INTEGER MAX-ACCESS read-create STATUS current DESCRIPTION "An ITS application index." ::= { netSnmpITSAppEntry 1 } netSnmpITSAppName OBJECT-TYPE SYNTAX OCTET STRING MAX-ACCESS read-create STATUS current DESCRIPTION "An ITS application name." ::= { netSnmpITSAppEntry 2 } netSnmpITSAppId OBJECT-TYPE SYNTAX OCTET STRING MAX-ACCESS read-create STATUS current DESCRIPTION "An ITS application id." ::= { netSnmpITSAppEntry 3 } And I've used mib2c (using mib2c -c mib2c.create-dataset.conf netSnmpITSAppTable) to generate some code. I've added to this to get the following: /* * Note: this file originally auto-generated by mib2c using * : mib2c.create-dataset.conf,v 5.4 2004/02/02 19:06:53 rstory Exp $ */ #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> #include <net-snmp/agent/agent_index.h> #include "netSnmpITSAppTable.h" /** Initialize the netSnmpITSAppTable table by defining its contents and how it's structured */ void initialize_table_netSnmpITSAppTable(void) { static oid netSnmpITSAppTable_oid[] = { 1, 3, 6, 1, 4, 1, 8072, 2, 2, 3 }; size_t netSnmpITSAppTable_oid_len = OID_LENGTH(netSnmpITSAppTable_oid); netsnmp_table_data_set *table_set; //** int allocatedIndex = register_int_index(netSnmpITSAppTable_oid, netSnmpITSAppTable_oid_len, ANY_INTEGER_INDEX); DEBUGMSGTL(("initialize_table_netSnmpITSAppTable", "allocated index: %d\n", allocatedIndex)); //** /* * create the table structure itself */ table_set = netsnmp_create_table_data_set("netSnmpITSAppTable"); /* * comment this out or delete if you don't support creation of new rows */ table_set->allow_creation = 1; /*************************************************** * Adding indexes */ DEBUGMSGTL(("initialize_table_netSnmpITSAppTable", "adding indexes to table netSnmpITSAppTable\n")); netsnmp_table_set_add_indexes(table_set, ASN_INTEGER, /* index: netSnmpITSAppIndex */ 0); DEBUGMSGTL(("initialize_table_netSnmpITSAppTable", "adding column types to table netSnmpITSAppTable\n")); netsnmp_table_set_multi_add_default_row(table_set, COLUMN_NETSNMPITSAPPINDEX, ASN_INTEGER, 1, NULL, 0, COLUMN_NETSNMPITSAPPNAME, ASN_OCTET_STR, 1, NULL, 0, COLUMN_NETSNMPITSAPPID, ASN_OCTET_STR, 1, NULL, 0, 0); /* * registering the table with the master agent */ /* * note: if you don't need a subhandler to deal with any aspects * of the request, change netSnmpITSAppTable_handler to "NULL" */ netsnmp_register_table_data_set(netsnmp_create_handler_registration ("netSnmpITSAppTable", netSnmpITSAppTable_handler, netSnmpITSAppTable_oid, netSnmpITSAppTable_oid_len, HANDLER_CAN_RWRITE), table_set, NULL); //** /* * create the a row for the table, and add the data */ netsnmp_table_row *row = netsnmp_create_table_data_row(); netsnmp_table_row_add_index(row, ASN_INTEGER, &allocatedIndex, sizeof(allocatedIndex)); netsnmp_set_row_column(row, COLUMN_NETSNMPITSAPPNAME, ASN_OCTET_STR, "App ABC", strlen("App ABC")); netsnmp_set_row_column(row, COLUMN_NETSNMPITSAPPID, ASN_OCTET_STR, "1.2.3", strlen("1.2.3")); /* * add the row to the table */ netsnmp_table_dataset_add_row(table_set, row); //** } /** Initializes the netSnmpITSAppTable module */ void init_netSnmpITSAppTable(void) { /* * here we initialize all the tables we're planning on supporting */ initialize_table_netSnmpITSAppTable(); } /** handles requests for the netSnmpITSAppTable table, if anything else needs to be done */ int netSnmpITSAppTable_handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { /* * perform anything here that you need to do. The requests have * already been processed by the master table_dataset handler, but * this gives you chance to act on the request in some other way * if need be. */ return SNMP_ERR_NOERROR; } I've used mib2c to create the makefile (mib2c -c mfd-makefile.m2m netSnmpITSAppTable) which I've altered to just compile the files I need and main subagent code (mib2c -c subagent.m2c netSnmpITSAppTable). Let me know if anything further is required. Mike ------------------------------------------------------------------------ - 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=DEVDE V _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users ------------------------------------------------------------------------ - 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=DEVDE V _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users ------------------------------------------------------------------------- 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-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
