Please stop sending these messages to this mailing list. This is _not_ an SNMP mailing list. If you need programming help, go to trainings or other sites, like Stack Overflow.
On Mon, Dec 8, 2014 at 5:57 AM, Akhilesh kumar <[email protected]> wrote: > Hi all > > i am writing my own implementation code for snmpset command. I have written > the below code but it gives error. I cant figure out how to correct "Bad > variable type" error. > > > > #include <stdio.h> > #include <net-snmp/net-snmp-config.h> > #include <net-snmp/net-snmp-includes.h> > #include <string.h> > #include <net-snmp/varbind_api.h> > > int main(int argc, char ** argv) > { > > struct snmp_session session; > struct snmp_session *sess_handle; > struct snmp_pdu *pdu; > struct snmp_pdu *response; > struct variable_list *vars; > oid id_oid[MAX_OID_LEN]; > size_t id_len = MAX_OID_LEN; > size_t name_length; > int status; > char set_var_cval[30],set_var[50]; > int choose_option=0; > char *p=NULL, get_var[51]; > int set_var_ival=0,failures=0,count; > char *names[SNMP_MAX_CMDLINE_OIDS]; > char types[SNMP_MAX_CMDLINE_OIDS]; > unsigned int *values[SNMP_MAX_CMDLINE_OIDS]; > oid name[MAX_OID_LEN]; > char type='i'; > const char > *dirname="/usr/local/share/snmp/mibs/",*filename="DDS-ENGINE-MIB.mib"; > unsigned int value_ptr; > > > > add_mibdir("/usr/local/share/snmp/mibs/"); > read_mib("DDS-ENGINE-MIB.mib"); > printf("Enter the OID to set value\n"); > scanf("%s",&set_var); > printf("The OID to be set is %s\n",set_var); > > init_snmp("snmpdemoapp"); > snmp_sess_init( &session ); > session.version = SNMP_VERSION_1; > session.community = "public"; > session.community_len = strlen(session.community); > session.peername = argv[1]; > sess_handle = snmp_open(&session); > pdu = snmp_pdu_create(SNMP_MSG_SET); > > > count=0; > names[0]=set_var; > printf("Enter the value to be set with\n"); > scanf("%d",&value_ptr); > values[0]=&value_ptr; > types[0]="i"; > name_length=strlen(names[0]); > > if (snmp_add_var(pdu, name, name_length, types[count], > values[count])) > { snmp_perror(names[count]); failures++; } > > > > status = snmp_synch_response(sess_handle, pdu, &response); > > > > > > > snmp_free_pdu(response); > snmp_close(sess_handle); > exit(1); > > } > > > _______________________________________________ > busybox mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
