I replaced strcpy by strncpy and it is working for me. It is working fine if I SET "test123" first and then again SET "try0" ie., the result of snmpget is giving me the correct value what I SET.
But the problem is, I have allocated memory for "rcommunity" by using array char rcommunity[10]; Since this is the case, if I SET private1233, the size of which is greater than 10 or even if it is equal to 10, then some junk values are appended at the end. The problem is not happening till if the size is 9 (if the array size is 10). So to solve this problem what I did is, I increased the array size so that any point of time I cannot touch that level of size. I am having a doubt regarding the permission set for an OID in the MIB. Actually I am having a scalar oid, the permission of which is READ-ONLY in the MIB. I executed mib2c to compile that MIB and since this oid is READ-ONLY, case MODE_GET alone is created for this particular oid in its handler function. But in our application database, we have set the access permission for this oid as "Read-Write". Now, when our simualted device is discovered and when save operation is done using our application , it will send some set of "snmpset" to the agent. At this time, the control is entering into the default case which will happen in worst case scenario. Information shown in the snmp agent. 2005-06-23 11:52:21 unknown mode (0) in handle_IPMaskCurrent 2005-06-23 11:52:21 unknown mode (4) in handle_IPMaskCurrent Above condition as I stated, will these conflicts in permission will make the control flow to look for SNMP_SET_ACTION for an oid which is read-only. To solve this shall I insert all the cases into the switch eventhough the access permission is read-only? Thanks On 6/22/05, Dave Shield <[EMAIL PROTECTED]> wrote: > On Wed, 2005-06-22 at 10:13, aakansha rajvi wrote: > > Since requests->requestvb->val.string holds the value what we setting > > ,I am copying this value into the string rcommunity > > > > strcpy(struct_obj.rcommunity,(void *)(requests->requestvb->val.string)); > > You need to take account of the 'requests->requestvb->val_len' field, > which specifies how much valid data is present. > Try > strncpy( struct_obj.rcommunity, > (void *)(requests->requestvb->val.string), > requests->requestvb->val_len); > > > Dave > > ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
