[BACK]Return to snmpc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / snmp

Diff for /src/usr.bin/snmp/snmpc.c between version 1.1 and 1.2

version 1.1, 2019/08/09 06:17:59 version 1.2, 2019/08/11 14:41:20
Line 55 
Line 55 
         const int usecommonopt;          const int usecommonopt;
         const char *optstring;          const char *optstring;
         const char *usage;          const char *usage;
         int (*exec)(int, char *[]);          int (*exec)(int, char *[]);
 };  };
   
 struct snmp_app snmp_apps[] = {  struct snmp_app snmp_apps[] = {
         {"get", 1, NULL, "agent oid ...", snmpc_get},          { "get", 1, NULL, "agent oid ...", snmpc_get },
         {"getnext", 1, NULL, "agent oid ...", snmpc_get},          { "getnext", 1, NULL, "agent oid ...", snmpc_get },
         {"walk", 1, "C:", "[-C cIipt] [-C E OID] agent [oid]", snmpc_walk},          { "walk", 1, "C:", "[-C cIipt] [-C E OID] agent [oid]", snmpc_walk },
         {"bulkget", 1, "C:", "[-C n<nonrep>r<maxrep>] agent oid ...", snmpc_get},          { "bulkget", 1, "C:", "[-C n<nonrep>r<maxrep>] agent oid ...", snmpc_get },
         {"bulkwalk", 1, "C:", "[-C cipn<nonrep>r<maxrep>] agent [oid]", snmpc_walk},          { "bulkwalk", 1, "C:", "[-C cipn<nonrep>r<maxrep>] agent [oid]", snmpc_walk },
         { "trap", 1, NULL, "agent uptime oid [oid type value] ...", snmpc_trap},          { "trap", 1, NULL, "agent uptime oid [oid type value] ...", snmpc_trap },
         {"mibtree", 0, "O:", "[-O fnS]", snmpc_mibtree}          { "mibtree", 0, "O:", "[-O fnS]", snmpc_mibtree }
 };  };
 struct snmp_app *snmp_app = NULL;  struct snmp_app *snmp_app = NULL;
   
Line 99 
Line 99 
   
         if (pledge("stdio inet dns", NULL) == -1)          if (pledge("stdio inet dns", NULL) == -1)
                 err(1, "pledge");                  err(1, "pledge");
   
         if (argc <= 1)          if (argc <= 1)
                 usage();                  usage();
   
Line 266 
Line 266 
                                         smi_print_hint = 0;                                          smi_print_hint = 0;
                                         break;                                          break;
                                 case 'v':                                  case 'v':
                                         print_varbind_only = 1;                                          print_varbind_only = 1;
                                         break;                                          break;
                                 case 'x':                                  case 'x':
                                         output_string = smi_os_hex;                                          output_string = smi_os_hex;
Line 418 
Line 418 
                         snmpc_printerror((enum snmp_error) errorstatus, oidstr);                          snmpc_printerror((enum snmp_error) errorstatus, oidstr);
                 }                  }
   
                 for (;varbind != NULL; varbind = varbind->be_next) {                  for (; varbind != NULL; varbind = varbind->be_next) {
                         (void) ber_scanf_elements(varbind, "{oe}", &noid,                          (void) ber_scanf_elements(varbind, "{oe}", &noid,
                             &value);                              &value);
                         if (value->be_class == BER_CLASS_CONTEXT &&                          if (value->be_class == BER_CLASS_CONTEXT &&
Line 719 
Line 719 
                 printf("%s %s\n", oids, value);                  printf("%s %s\n", oids, value);
         }          }
         free(value);          free(value);
   
         return 1;          return 1;
 }  }
   
 __dead void  __dead void
 snmpc_printerror(enum snmp_error error, char *oid)  snmpc_printerror(enum snmp_error error, char *oid)
 {  {
         switch (error)          switch (error) {
         {  
         case SNMP_ERROR_NONE:          case SNMP_ERROR_NONE:
                 errx(1, "No error, how did I get here?");                  errx(1, "No error, how did I get here?");
         case SNMP_ERROR_TOOBIG:          case SNMP_ERROR_TOOBIG:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2