netsnmp_tdata * table_data structure - SNMP
This is a discussion on netsnmp_tdata * table_data structure - SNMP ; Hi,
Used the mib2c.table_data.conf mib2c config to convert my mib to a
table code which works fine, I can add information etc via SNMP
operations, but have one query left on how to pre-populate the table
on startup:
I can ...
-
netsnmp_tdata * table_data structure
Hi,
Used the mib2c.table_data.conf mib2c config to convert my mib to a
table code which works fine, I can add information etc via SNMP
operations, but have one query left on how to pre-populate the table
on startup:
I can add rows containing just the index using:-
gdukHornetRadioTable_createEntry(table_data,0) for instance will
create a row with index 0.
What I can't find documented inside net-snmp either online or in code
is how to populate the table_data part of the call with the
information I wish to add prior to calling *_createEntry.
For instance my table is made up as follows (for the sake of brevity
I've trimmed the common prefix):-
tableIndex -- Integer with a range of 0 to 255
name -- String - 0 to 255 characters long
ifName -- String - 0 to 255 characters long
state -- integer - range of 0 to 3.
I'd like to pre-populate a few rows of the table on startup with some
default names etc...
--
Richard Horton
Users are like a virus: Each causing a thousand tiny crises until the
host finally dies.
http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest Cats
http://www.pbase.com/arimus - My online photogallery
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Re: netsnmp_tdata * table_data structure
2008/7/17 Richard Horton :
> What I can't find documented inside net-snmp either online or in code
> is how to populate the table_data part of the call with the
> information I wish to add prior to calling *_createEntry.
You don't.
The 'table_data' structure is a black-box, containing the overall
table. You shouldn't meddle with it.
> For instance my table is made up as follows (for the sake of brevity
> I've trimmed the common prefix):-
>
> tableIndex -- Integer with a range of 0 to 255
> name -- String - 0 to 255 characters long
> ifName -- String - 0 to 255 characters long
> state -- integer - range of 0 to 3.
>
> I'd like to pre-populate a few rows of the table on startup with some
> default names etc...
Having created and registered the table, you can then invoke
the 'createEntry' routine as many times as is required, giving
the index of each of the initial rows.
This call will pass back an empty row structure, which you
can then populate with the name/ifName/state/etc
I.e.
netsnmp_tdata_row *row;
struct myTable_row *entry;
row = myTable_createEntry( table_data, 1 );
entry = (struct myTable_row *)row->data;
entry->name = "row 1"
entry->ifName = "eth0";
entry->status = UNKNOWN;
row = myTable_createEntry( table_data, 2 );
entry = (struct myTable_row *)row->data;
entry->name = "row 2"
entry->ifName = "eth1";
entry->status = IMAGINARY;
etc
Dave
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Re: netsnmp_tdata * table_data structure
[ First - *please* don't mail me privately, without copying
any responses to the mailing list. I don't have the time
or inclination to offer private, unpaid, SNMP consultancy.
Particularly at the moment, as I'm cutting down on the
time I spend on Net-SNMP support. Keep discussions
to the list, where others can both learn and offer advice.
Thanks. ]
2008/7/17 Richard Horton :
> Still having an issue though, my test code is as follows (well the
> init bit for rows)
> for(i =0; i
> row = gdukHornetRadioTable_createEntry(table_data,i);
> entry = row->data;
> DEBUGMSGTL(("GDUK-HORNET-MIB","\tModifying row
> %d/%d\n",entry->gdukHornetRadioIndex,i));
> entry->gdukHornetRadioState = 1;
> strcpy(entry->gdukHornetRadioName,"test");
> }
>
> After running the code the state field correctly is returning 1 in
> response to a get on any given row (typically 32 of them), where as
> the name is returning a null string...
Do you set the length of the string values anywhere?
(i.e. entry->gdukHornetRadioName_len)
Remember that by default, the code for returning values looks
like:
snmp_set_var_typed_value( request->requestvb, TYPE,
entry->string_field, entry->string_field_len);
so that it can handle binary string values.
If you know that all strings will definitely be printable
(and no embedded null characters), then you can tweak
this to use 'strlen(entry->string_field)' instead,
and drop the 'string_field_len' completely.
But if you're using the default code, then you need to
set the length as well as the string value. Otherwise
this length will remain at 0, any extra characters
(i.e. all of them!) will be ignored
Dave
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Fwd: netsnmp_tdata * table_data structure
Sending this back to the list as it got lost due to a bad click on reply 
---------- Forwarded message ----------
From: Richard Horton
Date: 2008/7/17
Subject: Re: netsnmp_tdata * table_data structure
To: Dave Shield
2008/7/17 Dave Shield :
> Having created and registered the table, you can then invoke
> the 'createEntry' routine as many times as is required, giving
> the index of each of the initial rows.
>
> This call will pass back an empty row structure, which you
> can then populate with the name/ifName/state/etc
>
> I.e.
>
> netsnmp_tdata_row *row;
> struct myTable_row *entry;
>
> row = myTable_createEntry( table_data, 1 );
> entry = (struct myTable_row *)row->data;
> entry->name = "row 1"
> entry->ifName = "eth0";
> entry->status = UNKNOWN;
>
> row = myTable_createEntry( table_data, 2 );
> entry = (struct myTable_row *)row->data;
> entry->name = "row 2"
> entry->ifName = "eth1";
> entry->status = IMAGINARY;
Thanks Dave,
Still having an issue though, my test code is as follows (well the
init bit for rows)
for(i =0; i
row = gdukHornetRadioTable_createEntry(table_data,i);
entry = row->data;
DEBUGMSGTL(("GDUK-HORNET-MIB","\tModifying row
%d/%d\n",entry->gdukHornetRadioIndex,i));
entry->gdukHornetRadioState = 1;
strcpy(entry->gdukHornetRadioName,"test");
}
After running the code the state field correctly is returning 1 in
response to a get on any given row (typically 32 of them), where as
the name is returning a null string...
--
Richard Horton
Users are like a virus: Each causing a thousand tiny crises until the
host finally dies.
http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest Cats
http://www.pbase.com/arimus - My online photogallery
--
Richard Horton
Users are like a virus: Each causing a thousand tiny crises until the
host finally dies.
http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest Cats
http://www.pbase.com/arimus - My online photogallery
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
un-subscribe.
-----Original Message-----
From: net-snmp-users-bounces@lists.sourceforge.net
[mailto:net-snmp-users-bounces@lists.sourceforge.net] On Behalf Of Richard
Horton
Sent: Thursday, July 17, 2008 2:27 PM
To: net-snmp-users@lists.sourceforge.net
Subject: Fwd: netsnmp_tdata * table_data structure
Sending this back to the list as it got lost due to a bad click on reply 
---------- Forwarded message ----------
From: Richard Horton
Date: 2008/7/17
Subject: Re: netsnmp_tdata * table_data structure
To: Dave Shield
2008/7/17 Dave Shield :
> Having created and registered the table, you can then invoke
> the 'createEntry' routine as many times as is required, giving
> the index of each of the initial rows.
>
> This call will pass back an empty row structure, which you
> can then populate with the name/ifName/state/etc
>
> I.e.
>
> netsnmp_tdata_row *row;
> struct myTable_row *entry;
>
> row = myTable_createEntry( table_data, 1 );
> entry = (struct myTable_row *)row->data;
> entry->name = "row 1"
> entry->ifName = "eth0";
> entry->status = UNKNOWN;
>
> row = myTable_createEntry( table_data, 2 );
> entry = (struct myTable_row *)row->data;
> entry->name = "row 2"
> entry->ifName = "eth1";
> entry->status = IMAGINARY;
Thanks Dave,
Still having an issue though, my test code is as follows (well the
init bit for rows)
for(i =0; i
row = gdukHornetRadioTable_createEntry(table_data,i);
entry = row->data;
DEBUGMSGTL(("GDUK-HORNET-MIB","\tModifying row
%d/%d\n",entry->gdukHornetRadioIndex,i));
entry->gdukHornetRadioState = 1;
strcpy(entry->gdukHornetRadioName,"test");
}
After running the code the state field correctly is returning 1 in
response to a get on any given row (typically 32 of them), where as
the name is returning a null string...
--
Richard Horton
Users are like a virus: Each causing a thousand tiny crises until the
host finally dies.
http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest
Cats
http://www.pbase.com/arimus - My online photogallery
--
Richard Horton
Users are like a virus: Each causing a thousand tiny crises until the
host finally dies.
http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest
Cats
http://www.pbase.com/arimus - My online photogallery
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Re: netsnmp_tdata * table_data structure
2008/7/17 Dave Shield :
> Do you set the length of the string values anywhere?
> (i.e. entry->gdukHornetRadioName_len)
>
>
> Remember that by default, the code for returning values looks
> like:
> snmp_set_var_typed_value( request->requestvb, TYPE,
> entry->string_field, entry->string_field_len);
>
> so that it can handle binary string values.
> If you know that all strings will definitely be printable
> (and no embedded null characters), then you can tweak
> this to use 'strlen(entry->string_field)' instead,
> and drop the 'string_field_len' completely.
>
>
> But if you're using the default code, then you need to
> set the length as well as the string value. Otherwise
> this length will remain at 0, any extra characters
> (i.e. all of them!) will be ignored
>
> Dave
>
That's the problem (well hope it is - just going to recompile now) 
Thanks,
Richard.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users