[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.15 and 1.15.2.1

version 1.15, 2019/10/08 08:41:31 version 1.15.2.1, 2019/10/27 20:05:12
Line 520 
Line 520 
                         err(1, "get");                          err(1, "get");
         }          }
   
         (void) ber_scanf_elements(pdu, "t{Sdd{e", &class, &type, &errorstatus,          (void) ober_scanf_elements(pdu, "t{Sdd{e", &class, &type, &errorstatus,
             &errorindex, &varbind);              &errorindex, &varbind);
         if (errorstatus != 0) {          if (errorstatus != 0) {
                 if (errorindex >= 1 && errorindex <= argc)                  if (errorindex >= 1 && errorindex <= argc)
Line 535 
Line 535 
                 if (!snmpc_print(varbind))                  if (!snmpc_print(varbind))
                         err(1, "Can't print response");                          err(1, "Can't print response");
         }          }
         ber_free_elements(pdu);          ober_free_elements(pdu);
         snmp_free_agent(agent);          snmp_free_agent(agent);
         return 0;          return 0;
 }  }
Line 576 
Line 576 
                 if ((pdu = snmp_get(agent, &oid, 1)) == NULL)                  if ((pdu = snmp_get(agent, &oid, 1)) == NULL)
                         err(1, "%s", snmp_app->name);                          err(1, "%s", snmp_app->name);
   
                 (void) ber_scanf_elements(pdu, "t{Sdd{e", &class, &type,                  (void) ober_scanf_elements(pdu, "t{Sdd{e", &class, &type,
                     &errorstatus, &errorindex, &varbind);                      &errorstatus, &errorindex, &varbind);
                 if (errorstatus != 0)                  if (errorstatus != 0)
                         snmpc_printerror((enum snmp_error) errorstatus, varbind,                          snmpc_printerror((enum snmp_error) errorstatus, varbind,
Line 586 
Line 586 
                         printf("Received report:\n");                          printf("Received report:\n");
                 if (!snmpc_print(varbind))                  if (!snmpc_print(varbind))
                         err(1, "Can't print response");                          err(1, "Can't print response");
                 ber_free_element(pdu);                  ober_free_element(pdu);
                 if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)                  if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)
                         return 1;                          return 1;
                 n++;                  n++;
Line 602 
Line 602 
                                 err(1, "walk");                                  err(1, "walk");
                 }                  }
   
                 (void) ber_scanf_elements(pdu, "t{Sdd{e", &class, &type,                  (void) ober_scanf_elements(pdu, "t{Sdd{e", &class, &type,
                     &errorstatus, &errorindex, &varbind);                      &errorstatus, &errorindex, &varbind);
                 if (errorstatus != 0) {                  if (errorstatus != 0) {
                         snmpc_printerror((enum snmp_error) errorstatus, varbind,                          snmpc_printerror((enum snmp_error) errorstatus, varbind,
Line 612 
Line 612 
                 if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)                  if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)
                         printf("Received report:\n");                          printf("Received report:\n");
                 for (; varbind != NULL; varbind = varbind->be_next) {                  for (; varbind != NULL; varbind = varbind->be_next) {
                         (void) ber_scanf_elements(varbind, "{oe}", &noid,                          (void) ober_scanf_elements(varbind, "{oe}", &noid,
                             &value);                              &value);
                         if (value->be_class == BER_CLASS_CONTEXT &&                          if (value->be_class == BER_CLASS_CONTEXT &&
                             value->be_type == BER_TYPE_EOC)                              value->be_type == BER_TYPE_EOC)
                                 break;                                  break;
                         prev_cmp = ber_oid_cmp(&loid, &noid);                          prev_cmp = ober_oid_cmp(&loid, &noid);
                         if (walk_check_increase && prev_cmp == -1)                          if (walk_check_increase && prev_cmp == -1)
                                 errx(1, "OID not increasing");                                  errx(1, "OID not increasing");
                         if (prev_cmp == 0 || ber_oid_cmp(&oid, &noid) != 2)                          if (prev_cmp == 0 || ober_oid_cmp(&oid, &noid) != 2)
                                 break;                                  break;
                         if (walk_end.bo_n != 0 &&                          if (walk_end.bo_n != 0 &&
                             ber_oid_cmp(&walk_end, &noid) != -1)                              ober_oid_cmp(&walk_end, &noid) != -1)
                                 break;                                  break;
   
                         if (!snmpc_print(varbind))                          if (!snmpc_print(varbind))
                                 err(1, "Can't print response");                                  err(1, "Can't print response");
                         n++;                          n++;
                 }                  }
                 ber_free_elements(pdu);                  ober_free_elements(pdu);
                 if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)                  if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)
                         return 1;                          return 1;
                 if (varbind != NULL)                  if (varbind != NULL)
Line 640 
Line 640 
                 if ((pdu = snmp_get(agent, &oid, 1)) == NULL)                  if ((pdu = snmp_get(agent, &oid, 1)) == NULL)
                         err(1, "%s", snmp_app->name);                          err(1, "%s", snmp_app->name);
   
                 (void) ber_scanf_elements(pdu, "t{Sdd{e", &class, &type,                  (void) ober_scanf_elements(pdu, "t{Sdd{e", &class, &type,
                     &errorstatus, &errorindex, &varbind);                      &errorstatus, &errorindex, &varbind);
                 if (errorstatus != 0)                  if (errorstatus != 0)
                         snmpc_printerror((enum snmp_error) errorstatus, varbind,                          snmpc_printerror((enum snmp_error) errorstatus, varbind,
Line 650 
Line 650 
                         printf("Received report:\n");                          printf("Received report:\n");
                 if (!snmpc_print(varbind))                  if (!snmpc_print(varbind))
                         err(1, "Can't print response");                          err(1, "Can't print response");
                 ber_free_element(pdu);                  ober_free_element(pdu);
                 if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)                  if (class == BER_CLASS_CONTEXT && type == SNMP_C_REPORT)
                         return 1;                          return 1;
                 n++;                  n++;
Line 695 
Line 695 
         if ((pdu = snmp_set(agent, snmpc_varbindparse(argc, argv))) == NULL)          if ((pdu = snmp_set(agent, snmpc_varbindparse(argc, argv))) == NULL)
                 err(1, "set");                  err(1, "set");
   
         (void) ber_scanf_elements(pdu, "t{Sdd{e", &class, &type, &errorstatus,          (void) ober_scanf_elements(pdu, "t{Sdd{e", &class, &type, &errorstatus,
             &errorindex, &varbind);              &errorindex, &varbind);
         if (errorstatus != 0) {          if (errorstatus != 0) {
                 if (errorindex >= 1 && errorindex <= argc / 3)                  if (errorindex >= 1 && errorindex <= argc / 3)
Line 710 
Line 710 
                 if (!snmpc_print(varbind))                  if (!snmpc_print(varbind))
                         err(1, "Can't print response");                          err(1, "Can't print response");
         }          }
         ber_free_elements(pdu);          ober_free_elements(pdu);
         snmp_free_agent(agent);          snmp_free_agent(agent);
         return 0;          return 0;
 }  }
Line 789 
Line 789 
         char *value;          char *value;
   
         elm = elm->be_sub;          elm = elm->be_sub;
         if (ber_get_oid(elm, &oid) != 0) {          if (ober_get_oid(elm, &oid) != 0) {
                 errno = EINVAL;                  errno = EINVAL;
                 return 0;                  return 0;
         }          }
Line 828 
Line 828 
                     varbind = varbind->be_next)                      varbind = varbind->be_next)
                         i++;                          i++;
                 if (varbind != NULL &&                  if (varbind != NULL &&
                     ber_get_oid(varbind->be_sub, &vboid) == 0) {                      ober_get_oid(varbind->be_sub, &vboid) == 0) {
                         /* If user and reply conform print user input */                          /* If user and reply conform print user input */
                         if (hint != NULL &&                          if (hint != NULL &&
                             smi_string2oid(hint, &hoid) == 0 &&                              smi_string2oid(hint, &hoid) == 0 &&
                             ber_oid_cmp(&hoid, &vboid) == 0)                              ober_oid_cmp(&hoid, &vboid) == 0)
                                 oid = hint;                                  oid = hint;
                         else                          else
                                 oid = smi_oid2string(&vboid, oids,                                  oid = smi_oid2string(&vboid, oids,
Line 1056 
Line 1056 
                         if (ret == 0)                          if (ret == 0)
                                 errx(1, "%s: Bad value notation (%s)", argv[i],                                  errx(1, "%s: Bad value notation (%s)", argv[i],
                                     argv[i + 2]);                                      argv[i + 2]);
                         if ((varbind = ber_printf_elements(varbind, "{Oxt}",                          if ((varbind = ober_printf_elements(varbind, "{Oxt}",
                             &oid, addr, sizeof(addr4), BER_CLASS_APPLICATION,                              &oid, addr, sizeof(addr4), BER_CLASS_APPLICATION,
                             SNMP_T_IPADDR)) == NULL)                              SNMP_T_IPADDR)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         break;                          break;
                 case 'b':                  case 'b':
                         tmpstr = argv[i + 2];                          tmpstr = argv[i + 2];
Line 1098 
Line 1098 
                         if (errstr != NULL)                          if (errstr != NULL)
                                 errx(1, "%s: Bad value notation (%s)", argv[i],                                  errx(1, "%s: Bad value notation (%s)", argv[i],
                                     argv[i + 2]);                                      argv[i + 2]);
                         if ((varbind = ber_printf_elements(varbind, "{Oit}",                          if ((varbind = ober_printf_elements(varbind, "{Oit}",
                             &oid, lval, BER_CLASS_APPLICATION,                              &oid, lval, BER_CLASS_APPLICATION,
                             SNMP_T_COUNTER32)) == NULL)                              SNMP_T_COUNTER32)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         break;                          break;
                 case 'd':                  case 'd':
                         /* String always shrinks */                          /* String always shrinks */
Line 1133 
Line 1133 
                         if (errstr != NULL)                          if (errstr != NULL)
                                 errx(1, "%s: Bad value notation (%s)", argv[i],                                  errx(1, "%s: Bad value notation (%s)", argv[i],
                                     argv[i + 2]);                                      argv[i + 2]);
                         if ((varbind = ber_printf_elements(varbind, "{Oi}",                          if ((varbind = ober_printf_elements(varbind, "{Oi}",
                             &oid, lval)) == NULL)                              &oid, lval)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         break;                          break;
                 case 'n':                  case 'n':
                         if ((varbind = ber_printf_elements(varbind, "{O0}",                          if ((varbind = ober_printf_elements(varbind, "{O0}",
                             &oid)) == NULL)                              &oid)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         break;                          break;
                 case 'o':                  case 'o':
                         if (smi_string2oid(argv[i + 2], &oidval) == -1)                          if (smi_string2oid(argv[i + 2], &oidval) == -1)
                                 errx(1, "%s: Unknown Object Identifier (Sub-id "                                  errx(1, "%s: Unknown Object Identifier (Sub-id "
                                     "not found: (top) -> %s)", argv[i],                                      "not found: (top) -> %s)", argv[i],
                                     argv[i + 2]);                                      argv[i + 2]);
                         if ((varbind = ber_printf_elements(varbind, "{OO}",                          if ((varbind = ober_printf_elements(varbind, "{OO}",
                             &oid, &oidval)) == NULL)                              &oid, &oidval)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         break;                          break;
                 case 's':                  case 's':
                         if ((str = strdup(argv[i + 2])) == NULL)                          if ((str = strdup(argv[i + 2])) == NULL)
                                 err(1, NULL);                                  err(1, NULL);
                         strl = strlen(argv[i + 2]);                          strl = strlen(argv[i + 2]);
 pastestring:  pastestring:
                         if ((varbind = ber_printf_elements(varbind, "{Ox}",                          if ((varbind = ober_printf_elements(varbind, "{Ox}",
                             &oid, str, strl)) == NULL)                              &oid, str, strl)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         free(str);                          free(str);
                         break;                          break;
                 case 't':                  case 't':
Line 1167 
Line 1167 
                         if (errstr != NULL)                          if (errstr != NULL)
                                 errx(1, "%s: Bad value notation (%s)", argv[i],                                  errx(1, "%s: Bad value notation (%s)", argv[i],
                                     argv[i + 2]);                                      argv[i + 2]);
                         if ((varbind = ber_printf_elements(varbind, "{Oit}",                          if ((varbind = ober_printf_elements(varbind, "{Oit}",
                             &oid, lval, BER_CLASS_APPLICATION,                              &oid, lval, BER_CLASS_APPLICATION,
                             SNMP_T_TIMETICKS)) == NULL)                              SNMP_T_TIMETICKS)) == NULL)
                                 err(1, "ber_printf_elements");                                  err(1, "ober_printf_elements");
                         break;                          break;
                 case 'x':                  case 'x':
                         /* String always shrinks */                          /* String always shrinks */

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.15.2.1