I have a private table whose indexes are mac address and  rule index . I use mib2c to generate the basic codes for me and it recognize the mac address index's type as ASN_OCTET_STR.  Thus I define the following variables:
  char *mac_addr[6];
  int    rule_index;
and then write the following codes to set indexes of the table in the function get_next_data_point:
snmp_set_var_value(vptr,  (u_char *)(entry->mac_addr), strlen(entry->mac_addr));
 vptr = vptr->next_variable;
 snmp_set_var_value(vptr,  (u_char *)&(entry->rule_index), sizeof(entry->rule_index));                    
 vptr = vptr->next_variable;
 *my_data_context =(void*)entry;
 *my_loop_context =(void*)entry->next;
 
In order to test this codes, I construct the following datas manually in function get_first_data_pointer:
  entry->mac_addr[0] = 'a';
  entry->mac_addr[0] = 'b';
  entry->mac_addr[0] = 'c';
  entry->mac_addr[0] = 'd';
  entry->mac_addr[0] = 'e';
  entry->mac_addr[0] = 'f';     
   entry->rule_index = 2;
Then I run the command of snmpwalk, but it returns the different indexes:
table.'abcde'.102.2.variable = xxxx;
Thus value of 'f ' is missing and '102' is added strangely.
 
In fact I want to get and set the mac address as the following format: table.a:b:c:d:e:f. 2. variable=xxx;
Could anyone give me some advice on how to process such indexes? Thank you very much!
II am looking forward to your reply! Anyway thanks again!
 
Best Regards!
Liva

Reply via email to