effect of vacm_vars

2014-08-19 Thread santosh
Hi,

NET-SNMP version 5.7.2

I start the snmpd as:

/usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a -I
versioninfo interface snmpEngine pass system_mib snmpTargetAddrEntry
snmpTargetParamsEntry target_counters target snmpCommunityTable
sysORTable setSerialNo snmp_mib snmpNotifyFilterProfileTable
snmpNotifyTable usmUser vacm_conf

I see two problems
1. It ignores community string and responds to get/set with any
community string.
2. I see lots of Warning: Unknown token in logs.

When I add vacm_vars problem 2 goes away but now it do not respond to
any get/set requests, I see the requests reaching the agent in logs
but no response given out.

Thanks,
S

--
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Keeping session open to receive broadcast responses

2014-08-19 Thread David Durham
Hello,
I have been studying the code following function wrapper after function wrapper 
down the snmp_send trail, trying to work out how the netsnmp_request_list is 
involved to stop the listening for responses. I am trying to keep the session 
open and listening for responses until a timeout period so it will receive 
responses from any IP address. Any help is very much appreciated. Thank you.
--
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


A problem about develop new oid

2014-08-19 Thread L'oiseau de mer
Hi, everyone
I am a snmp newbie developer, and want to write some new OIDs.
And generate sample code from mib2c MY-DEFINE-MIB file.
But when i develop this part, i meet a big problem:
when set string, requests-requestvb-val.string always remain some old
data, i don't know how to empty it.

Ex:
snmpset -v 1 -c XXX localhost [A OID] s ABCDEFGHIJ
snmpset -v 1 -c XXX localhost [B OID] s 1234567

snmpget -v 1 -c XXX localhost [B OID]
== 1234567HIJ

So i want to ask how to solve this problem?
Thanks.

This is my code:
==
...
static  char   A[100];
static  char   B[30];
...

void
init_XXX(void)
{
const oid   A_oid[] = { ... };
const oid   B_oid[] = { ... };
...
}

int
handle_AOID(netsnmp_mib_handler *handler,
   netsnmp_handler_registration *reginfo,
   netsnmp_agent_request_info *reqinfo,
   netsnmp_request_info *requests)
{
...

switch (reqinfo-mode) {

case MODE_GET:
snmp_set_var_typed_value(requests-requestvb,
 ASN_OCTET_STR, A, sizeof(A));
break;
...
case MODE_SET_ACTION:
strncpy(A, requests-requestvb-val.string,
sizeof(A));
A[sizeof(A)-1]='\0';
break;
...
}
...
}


int
handle_BOID(netsnmp_mib_handler *handler,
   netsnmp_handler_registration *reginfo,
   netsnmp_agent_request_info *reqinfo,
   netsnmp_request_info *requests)
{
...

switch (reqinfo-mode) {

case MODE_GET:
snmp_set_var_typed_value(requests-requestvb,
 ASN_OCTET_STR, B, sizeof(B));
break;
...
case MODE_SET_ACTION:
strncpy(B, requests-requestvb-val.string,
sizeof(B));
B[sizeof(B)-1]='\0';
break;
...
}
...
}
===
And other part codes, i almost not modified them, continue to use from
mib2c auto-generate.
--
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: A problem about develop new oid

2014-08-19 Thread Niels Baggesen
Den 20-08-2014 kl. 02:57 skrev L'oiseau de mer:
  case MODE_SET_ACTION:
  strncpy(A, requests-requestvb-val.string,
  sizeof(A));
  A[sizeof(A)-1]='\0';

A SNMP string is not a 0-terminated C string. You must respect (and 
save) the length of the string passed in the request (requestvb-val_len).

/Niels

-- 
Niels Baggesen - @home - Ã…rhus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming

--
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders