SNMP frontend: Types and indexes

Added timestamp and inet address
First go at index names
This commit is contained in:
Olof hagsand 2022-05-30 11:23:52 +02:00
parent 68eda07cc4
commit ff52cad3a8
6 changed files with 137 additions and 180 deletions

View file

@ -208,7 +208,7 @@ snmp_scalar_get(clicon_handle h,
cxobj *xt = NULL; cxobj *xt = NULL;
cxobj *xerr; cxobj *xerr;
cxobj *x; cxobj *x;
char *snmpstr = NULL; char *xmlstr = NULL;
u_char *snmpval = NULL; u_char *snmpval = NULL;
size_t snmplen = 0; size_t snmplen = 0;
int ret; int ret;
@ -230,13 +230,13 @@ snmp_scalar_get(clicon_handle h,
goto done; goto done;
} }
/* /*
* The xml to snmp value conversion is done here. It is done in two steps: * The xml to snmp value conversion is done in two steps:
* 1. From XML to SNMP string, there is a special case for enumeration, and for default value * 1. From XML to SNMP string, there is a special case for enumeration, and for default value
* 2. From SNMP string to SNMP binary value which invloves parsing * 2. From SNMP string to SNMP binary value which invloves parsing
*/ */
if ((x = xpath_first(xt, nsc, "%s", xpath)) != NULL){ if ((x = xpath_first(xt, nsc, "%s", xpath)) != NULL){
assert(xml_spec(x) == ys); assert(xml_spec(x) == ys);
if ((ret = type_xml2snmpstr(xml_body(x), ys, &snmpstr)) < 0) if ((ret = type_xml2snmp_pre(xml_body(x), ys, &xmlstr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE); netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE);
@ -244,7 +244,7 @@ snmp_scalar_get(clicon_handle h,
} }
} }
else if (defaultval != NULL){ else if (defaultval != NULL){
if ((snmpstr = strdup(defaultval)) == NULL){ if ((xmlstr = strdup(defaultval)) == NULL){
clicon_err(OE_UNIX, errno, "strdup"); clicon_err(OE_UNIX, errno, "strdup");
goto done; goto done;
} }
@ -255,7 +255,7 @@ snmp_scalar_get(clicon_handle h,
} }
if (type_yang2asn1(ys, &asn1type, 1) < 0) if (type_yang2asn1(ys, &asn1type, 1) < 0)
goto done; goto done;
if ((ret = type_snmpstr2val(snmpstr, &asn1type, &snmpval, &snmplen, &reason)) < 0) if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clicon_debug(1, "%s %s", __FUNCTION__, reason); clicon_debug(1, "%s %s", __FUNCTION__, reason);
@ -274,8 +274,8 @@ snmp_scalar_get(clicon_handle h,
done: done:
if (reason) if (reason)
free(reason); free(reason);
if (snmpstr) if (xmlstr)
free(snmpstr); free(xmlstr);
if (snmpval) if (snmpval)
free(snmpval); free(snmpval);
if (xt) if (xt)

View file

@ -201,7 +201,13 @@ type_yang2asn1(yang_stmt *ys,
at = ASN_OCTET_STR; at = ASN_OCTET_STR;
} }
else if (strcmp(origtype, "timeticks")==0){ else if (strcmp(origtype, "timeticks")==0){
at = ASN_TIMETICKS; /* Clixon extended string type */ at = ASN_TIMETICKS;
}
else if (strcmp(origtype, "timestamp")==0){
at = ASN_TIMETICKS;
}
else if (strcmp(origtype, "InetAddress")==0){
at = ASN_IPADDRESS;
} }
else if (extended && strcmp(origtype, "phys-address")==0){ else if (extended && strcmp(origtype, "phys-address")==0){
at = CLIXON_ASN_PHYS_ADDR; /* Clixon extended string type */ at = CLIXON_ASN_PHYS_ADDR; /* Clixon extended string type */
@ -335,17 +341,21 @@ type_snmp2xml(yang_stmt *ys,
} }
/*! Given xml value and YANG,m return corresponding malloced snmp string /*! Given xml value and YANG,m return corresponding malloced snmp string
* There is a special case for enumeration which is integer in snmp, string in YANG *
* @param[in] xmlstr * For special cases to prepare for proper xml2snmp translation. This includes translating
* @retval 1 OK * from string values to numeric values for enumeration and boolean.
* @retval 0 Invalid type * @param[in] xmlstr0 XML string pre
* @retval -1 Error * @param[in] ys Yang node
* @param[out] xmlstr1 XML string ready for translation
* @retval 1 OK
* @retval 0 Invalid type
* @retval -1 Error
* @see type_snmp2xml for snmpset * @see type_snmp2xml for snmpset
*/ */
int int
type_xml2snmpstr(char *xmlstr, type_xml2snmp_pre(char *xmlstr0,
yang_stmt *ys, yang_stmt *ys,
char **snmpstr) char **xmlstr1)
{ {
int retval = -1; int retval = -1;
@ -355,8 +365,8 @@ type_xml2snmpstr(char *xmlstr,
char *str = NULL; char *str = NULL;
int ret; int ret;
if (snmpstr == NULL){ if (xmlstr1 == NULL){
clicon_err(OE_UNIX, EINVAL, "snmpstr"); clicon_err(OE_UNIX, EINVAL, "xmlstr1");
goto done; goto done;
} }
/* Get yang type of leaf and trasnslate to ASN.1 */ /* Get yang type of leaf and trasnslate to ASN.1 */
@ -364,10 +374,10 @@ type_xml2snmpstr(char *xmlstr,
goto done; goto done;
restype = yrestype?yang_argument_get(yrestype):NULL; restype = yrestype?yang_argument_get(yrestype):NULL;
if (strcmp(restype, "enumeration") == 0){ /* special case for enum */ if (strcmp(restype, "enumeration") == 0){ /* special case for enum */
if ((ret = yang_enum2valstr(yrestype, xmlstr, &str)) < 0) if ((ret = yang_enum2valstr(yrestype, xmlstr0, &str)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clicon_debug(1, "Invalid enum valstr %s", xmlstr); clicon_debug(1, "Invalid enum valstr %s", xmlstr0);
goto fail; goto fail;
} }
} }
@ -377,15 +387,15 @@ type_xml2snmpstr(char *xmlstr,
* 2) Truthvalue actually translates to enum true(1)/false(0) * 2) Truthvalue actually translates to enum true(1)/false(0)
*/ */
else if (strcmp(restype, "boolean") == 0){ else if (strcmp(restype, "boolean") == 0){
if (strcmp(xmlstr, "false")==0) if (strcmp(xmlstr0, "false")==0)
str = "0"; str = "0";
else else
str = "1"; str = "1";
} }
else{ else{
str = xmlstr; str = xmlstr0;
} }
if ((*snmpstr = strdup(str)) == NULL){ if ((*xmlstr1 = strdup(str)) == NULL){
clicon_err(OE_UNIX, errno, "strdup"); clicon_err(OE_UNIX, errno, "strdup");
goto done; goto done;
} }
@ -409,14 +419,14 @@ type_xml2snmpstr(char *xmlstr,
* @retval 0 Invalid * @retval 0 Invalid
* @retval -1 Error * @retval -1 Error
* @note asn1type can be rewritten from CLIXON_ASN_ to ASN_ * @note asn1type can be rewritten from CLIXON_ASN_ to ASN_
* XXX See sprint_realloc_timeticks * @see type_xml2snmp_pre for some pre-condition XML special cases (eg enums and bool)
*/ */
int int
type_snmpstr2val(char *snmpstr, type_xml2snmp(char *snmpstr,
int *asn1type, int *asn1type,
u_char **snmpval, u_char **snmpval,
size_t *snmplen, size_t *snmplen,
char **reason) char **reason)
{ {
int retval = -1; int retval = -1;
int ret; int ret;
@ -627,123 +637,59 @@ yang2xpath(yang_stmt *ys,
return retval; return retval;
} }
#ifdef NOTUSED
/*! /*!
* @param[in] ys Yang statement
* @param[out] xpath Malloced xpath string, use free() after use
* @retval 0 OK
* @retval -1 Error
*/ */
int int
clixon_table_create(netsnmp_table_data_set *table0, snmp_body2oid(cxobj *xi,
yang_stmt *ys, cg_var *cv)
clicon_handle h)
{ {
int retval = -1; int retval = -1;
cvec *nsc = NULL; yang_stmt *yi;
cxobj *xt = NULL; int asn1_type;
cxobj *xerr; char *body;
char *xpath; size_t len;
cxobj *xtable; cbuf *enc = NULL;
cxobj *xe; int i;
cxobj *xleaf;
char *valstr;
netsnmp_table_data *table;
netsnmp_table_row *row;
netsnmp_table_row *tmprow;
int i;
int ret;
cvec *keyvec = NULL;
if (table0 == NULL || (table = table0->table) == NULL){ if ((yi = xml_spec(xi)) == NULL)
clicon_err(OE_UNIX, EINVAL, "table0 /->table is NULL"); goto ok;
if (type_yang2asn1(yi, &asn1_type, 0) < 0)
goto done; goto done;
body = xml_body(xi);
switch (asn1_type){
case ASN_INTEGER:
case ASN_GAUGE:
case ASN_TIMETICKS:
case ASN_COUNTER64:
case ASN_COUNTER:
case ASN_IPADDRESS:
if (cv_string_set(cv, body) < 0){
clicon_err(OE_UNIX,errno, "cv_string_set");
goto done;
}
break;
case ASN_OCTET_STR:{ /* encode to N.c.c.c.c */
if ((enc = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
len = strlen(body);
cprintf(enc, "%zu", len);
for (i=0; i<len; i++)
cprintf(enc, ".%u", body[i]&0xff);
if (cv_string_set(cv, cbuf_get(enc)) < 0){
clicon_err(OE_UNIX,errno, "cv_string_set");
goto done;
}
break;
} }
if (xml_nsctx_yang(ys, &nsc) < 0) default:
goto done; break;
if (yang2xpath(ys, keyvec, &xpath) < 0)
goto done;
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
goto done;
} }
ok:
#if 1
/* Boils down to snmp_varlist_add_variable */
if (snmp_varlist_add_variable(&table->indexes_template,
NULL,
0,
ASN_OCTET_STR,
NULL,
0) == NULL){
clicon_err(OE_XML, errno, "snmp_varlist_add_variable");
goto done;
}
if ((ret = netsnmp_table_set_add_default_row(table0, 2, ASN_OCTET_STR, 1, NULL, 0)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_table_set_add_default_row");
goto done;
}
if ((ret = netsnmp_table_set_add_default_row(table0, 3, ASN_OCTET_STR, 1, NULL, 0)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_table_set_add_default_row");
goto done;
}
#else
netsnmp_table_dataset_add_index(table, ASN_OCTET_STR);
netsnmp_table_set_multi_add_default_row(table0, 2, ASN_OCTET_STR, 1, NULL, 0, 3, ASN_OCTET_STR, 1, NULL, 0, 0);
#endif
if ((xtable = xpath_first(xt, nsc, "%s", xpath)) != NULL) {
for (tmprow = table->first_row; tmprow; tmprow = tmprow->next)
netsnmp_table_dataset_remove_and_delete_row(table0, tmprow);
xe = NULL; /* Loop thru entries in table */
while ((xe = xml_child_each(xtable, xe, CX_ELMNT)) != NULL) {
if ((row = netsnmp_create_table_data_row()) == NULL){
clicon_err(OE_UNIX, errno, "netsnmp_create_table_data_row");
goto done;
}
xleaf = NULL; /* Loop thru leafs in entry */
i = 1; /* tableindex start at 1 */
while ((xleaf = xml_child_each(xe, xleaf, CX_ELMNT)) != NULL) {
valstr = xml_body(xleaf);
if (i == 1){ // Assume first entry is key XXX should check YANG
#if 1
if ((snmp_varlist_add_variable(&row->indexes, NULL, 0, ASN_OCTET_STR, (const u_char *)valstr, strlen(valstr))) == NULL){
clicon_err(OE_XML, errno, "snmp_varlist_add_variable");
goto done;
}
#else
netsnmp_table_row_add_index(row, ASN_OCTET_STR, valstr, strlen(valstr));
#endif
}
else{
if ((ret = netsnmp_set_row_column(row, i, ASN_OCTET_STR, valstr, strlen(valstr))) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_set_row_column");
goto done;
}
if ((ret = netsnmp_mark_row_column_writable(row, i, 1)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_set_row_column");
goto done;
}
}
i++;
}
netsnmp_table_dataset_add_row(table0, row);
}
}
retval = 0; retval = 0;
done:
done: if (enc)
if (xt) cbuf_free(enc);
xml_free(xt);
if (nsc)
xml_nsctx_free(nsc);
return retval; return retval;
} }
#endif

View file

@ -67,9 +67,10 @@ int type_snmp2xml(yang_stmt *ys,
netsnmp_agent_request_info *reqinfo, netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests, netsnmp_request_info *requests,
char **valstr); char **valstr);
int type_xml2snmpstr(char *xmlstr, yang_stmt *ys, char **snmpstr); int type_xml2snmp_pre(char *xmlstr, yang_stmt *ys, char **snmpstr);
int type_snmpstr2val(char *snmpstr, int *asn1type, u_char **snmpval, size_t *snmplen, char **reason); int type_xml2snmp(char *snmpstr, int *asn1type, u_char **snmpval, size_t *snmplen, char **reason);
int yang2xpath(yang_stmt *ys, cvec *keyvec, char **xpath); int yang2xpath(yang_stmt *ys, cvec *keyvec, char **xpath);
int snmp_body2oid(cxobj *xi, cg_var *cv);
#endif /* _SNMP_LIB_H_ */ #endif /* _SNMP_LIB_H_ */

View file

@ -94,9 +94,9 @@
* @retval -1 Error * @retval -1 Error
*/ */
static int static int
mib_yang_leaf(clicon_handle h, mibyang_leaf_register(clicon_handle h,
yang_stmt *ys, yang_stmt *ys,
cvec *cvk) cvec *cvk)
{ {
int retval = -1; int retval = -1;
netsnmp_handler_registration *nhreg = NULL; netsnmp_handler_registration *nhreg = NULL;
@ -135,7 +135,7 @@ mib_yang_leaf(clicon_handle h,
} }
if (yang_extension_value(ys, "max-access", IETF_YANG_SMIV2_NS, NULL, &modes_str) < 0) if (yang_extension_value(ys, "max-access", IETF_YANG_SMIV2_NS, NULL, &modes_str) < 0)
goto done; goto done;
/* Sanity check of types */ /* Only for sanity check of types initially to fail early */
if (type_yang2asn1(ys, NULL, 0) < 0) if (type_yang2asn1(ys, NULL, 0) < 0)
goto done; goto done;
@ -200,7 +200,9 @@ mib_yang_leaf(clicon_handle h,
return retval; return retval;
} }
/*! Parse smiv2 extensions for YANG container/list /*! Register table entry handler itself (not column/row leafs)
*
* Parse smiv2 extensions for YANG container/list
* *
* Typical table: * Typical table:
* container x { * container x {
@ -216,9 +218,9 @@ mib_yang_leaf(clicon_handle h,
* @retval -1 Error * @retval -1 Error
*/ */
static int static int
mib_yang_table(clicon_handle h, mibyang_table_register(clicon_handle h,
yang_stmt *ys, yang_stmt *ys,
yang_stmt *ylist) yang_stmt *ylist)
{ {
int retval = -1; int retval = -1;
netsnmp_handler_registration *nhreg; netsnmp_handler_registration *nhreg;
@ -325,7 +327,7 @@ mib_yang_table(clicon_handle h,
return retval; return retval;
} }
/*! Register table sub-oid:s /*! Register table sub-oid:s of existing entries in clixon
* This assumes a table contains a set of keys and a list of leafs only * This assumes a table contains a set of keys and a list of leafs only
* The function makes a query to the datastore and registers all table entries that * The function makes a query to the datastore and registers all table entries that
* currently exists. This means it registers for a static table. If new rows or columns * currently exists. This means it registers for a static table. If new rows or columns
@ -338,9 +340,9 @@ mib_yang_table(clicon_handle h,
* @retval -1 Error * @retval -1 Error
*/ */
static int static int
mib_traverse_table(clicon_handle h, mibyang_table_traverse_static(clicon_handle h,
yang_stmt *ys, yang_stmt *ys,
yang_stmt *ylist) yang_stmt *ylist)
{ {
int retval = -1; int retval = -1;
cvec *nsc = NULL; cvec *nsc = NULL;
@ -358,6 +360,7 @@ mib_traverse_table(clicon_handle h,
int i; int i;
cxobj *xi; cxobj *xi;
clicon_debug(1, "%s %s", __FUNCTION__, yang_argument_get(ys));
if (xml_nsctx_yang(ys, &nsc) < 0) if (xml_nsctx_yang(ys, &nsc) < 0)
goto done; goto done;
if (yang2xpath(ys, NULL, &xpath) < 0) if (yang2xpath(ys, NULL, &xpath) < 0)
@ -389,7 +392,8 @@ mib_traverse_table(clicon_handle h,
cv = cvec_i(cvk, i); cv = cvec_i(cvk, i);
if ((xi = xml_find_type(xrow, NULL, cv_string_get(cv0), CX_ELMNT)) == NULL) if ((xi = xml_find_type(xrow, NULL, cv_string_get(cv0), CX_ELMNT)) == NULL)
break; break;
cv_string_set(cv, xml_body(xi)); if (snmp_body2oid(xi, cv) < 0)
goto done;
} }
if (i<cvec_len(cvk0)) if (i<cvec_len(cvk0))
continue; /* skip row, not all indexes */ continue; /* skip row, not all indexes */
@ -397,7 +401,7 @@ mib_traverse_table(clicon_handle h,
while ((xcol = xml_child_each(xrow, xcol, CX_ELMNT)) != NULL) { while ((xcol = xml_child_each(xrow, xcol, CX_ELMNT)) != NULL) {
if ((y = xml_spec(xcol)) == NULL) if ((y = xml_spec(xcol)) == NULL)
continue; continue;
if (mib_yang_leaf(h, y, cvk) < 0) if (mibyang_leaf_register(h, y, cvk) < 0)
goto done; goto done;
} }
} }
@ -435,17 +439,18 @@ mib_traverse_table(clicon_handle h,
* @retval -1 Error, aborted at first error encounter * @retval -1 Error, aborted at first error encounter
*/ */
static int static int
mib_traverse(clicon_handle h, mibyang_traverse(clicon_handle h,
yang_stmt *yn) yang_stmt *yn)
{ {
int retval = -1; int retval = -1;
yang_stmt *ys = NULL; yang_stmt *ys = NULL;
yang_stmt *yp; yang_stmt *yp;
int ret; int ret;
clicon_debug(1, "%s %s", __FUNCTION__, yang_argument_get(yn));
switch(yang_keyword_get(yn)){ switch(yang_keyword_get(yn)){
case Y_LEAF: case Y_LEAF:
if (mib_yang_leaf(h, yn, NULL) < 0) if (mibyang_leaf_register(h, yn, NULL) < 0)
goto done; goto done;
break; break;
case Y_CONTAINER: /* See list case */ case Y_CONTAINER: /* See list case */
@ -453,10 +458,11 @@ mib_traverse(clicon_handle h,
case Y_LIST: /* If parent is container -> identify as table */ case Y_LIST: /* If parent is container -> identify as table */
yp = yang_parent_get(yn); yp = yang_parent_get(yn);
if (yang_keyword_get(yp) == Y_CONTAINER){ if (yang_keyword_get(yp) == Y_CONTAINER){
/* Specialize table traversal */ /* Register table entry handler itself (not column/row leafs) */
if (mib_yang_table(h, yp, yn) < 0) if (mibyang_table_register(h, yp, yn) < 0)
goto done; goto done;
if (mib_traverse_table(h, yp, yn) < 0) /* Register table sub-oid:s of existing entries in clixon */
if (mibyang_table_traverse_static(h, yp, yn) < 0)
goto done; goto done;
goto ok; goto ok;
} }
@ -469,7 +475,7 @@ mib_traverse(clicon_handle h,
while ((ys = yn_each(yn, ys)) != NULL) { while ((ys = yn_each(yn, ys)) != NULL) {
if (!yang_schemanode(ys)) if (!yang_schemanode(ys))
continue; continue;
if ((ret = mib_traverse(h, ys)) < 0) if ((ret = mibyang_traverse(h, ys)) < 0)
goto done; goto done;
if (ret > 0){ if (ret > 0){
retval = ret; retval = ret;
@ -497,11 +503,13 @@ clixon_snmp_traverse_mibyangs(clicon_handle h)
yang_stmt *yspec; yang_stmt *yspec;
yang_stmt *ymod; yang_stmt *ymod;
/* XXX Hardcoded, replace this with generic MIB */
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clicon_err(OE_FATAL, 0, "No DB_SPEC"); clicon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
} }
/* Loop over clixon configuration file to find all CLICON_SNMP_MIB, and
* then loop over all those MIBs to register OIDs with netsnmp
*/
x = NULL; x = NULL;
while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) { while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) {
if (strcmp(xml_name(x), "CLICON_SNMP_MIB") != 0) if (strcmp(xml_name(x), "CLICON_SNMP_MIB") != 0)
@ -520,7 +528,7 @@ clixon_snmp_traverse_mibyangs(clicon_handle h)
goto done; goto done;
} }
/* Recursively traverse the mib-yang to find extensions */ /* Recursively traverse the mib-yang to find extensions */
if (mib_traverse(h, ymod) < 0) if (mibyang_traverse(h, ymod) < 0)
goto done; goto done;
} }
retval = 0; retval = 0;

View file

@ -219,13 +219,15 @@ expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
NAME=ifCounterDiscontinuityTime NAME=ifCounterDiscontinuityTime
OID=$OID11 OID=$OID11
VALUE=1234567890 VALUE=1234567890
TYPE=Gauge32 # TimeStamp #TYPE=Gauge32 # TimeStamp
TYPE=Timeticks
new "Set $NAME $VALUE" new "Set $NAME $VALUE"
expectpart "$($snmpset $OID u $VALUE)" 0 "$OID = $TYPE: $VALUE" echo "$snmpset $OID t $VALUE"
expectpart "$($snmpset $OID t $VALUE)" 0 "$OID = $TYPE: ($VALUE) 142 days, 21:21:18.90"
new "Get $NAME $VALUE" new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: ($VALUE) 142 days, 21:21:18.90"
NAME=ifStackStatus NAME=ifStackStatus
OID=$OID12 OID=$OID12

View file

@ -167,7 +167,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext netSnmpExampleInteger" new "Test SNMP getnext netSnmpExampleInteger"
expectpart "$($snmpgetnext $OID1)" 0 "$OID2 = INTEGER: -1" expectpart "$($snmpgetnext $OID)" 0 "$OID2 = INTEGER: -1"
NAME=netSnmpExampleSleeper NAME=netSnmpExampleSleeper
OID=$OID2 OID=$OID2
@ -178,7 +178,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext netSnmpExampleSleeper" new "Test SNMP getnext netSnmpExampleSleeper"
expectpart "$($snmpgetnext $OID2)" 0 "$OID3 = STRING: This is not default" expectpart "$($snmpgetnext $OID)" 0 "$OID3 = STRING: This is not default"
NAME=netSnmpExampleString NAME=netSnmpExampleString
OID=$OID3 OID=$OID3
@ -189,7 +189,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext netSnmpExampleString" new "Test SNMP getnext netSnmpExampleString"
expectpart "$($snmpgetnext $OID3)" 0 "$OID4 = Timeticks: (12345) 0:02:03.45" expectpart "$($snmpgetnext $OID)" 0 "$OID4 = Timeticks: (12345) 0:02:03.45"
NAME=ifTableLastChange NAME=ifTableLastChange
OID=$OID4 OID=$OID4
@ -200,7 +200,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ipTableLastChange" new "Test SNMP getnext ipTableLastChange"
expectpart "$($snmpgetnext $OID4)" 0 "$OID5 = INTEGER: 48" expectpart "$($snmpgetnext $OID)" 0 "$OID5 = INTEGER: 48"
NAME=ifType NAME=ifType
OID=$OID5 OID=$OID5
@ -211,7 +211,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifType" new "Test SNMP getnext ifType"
expectpart "$($snmpgetnext $OID5)" 0 "$OID6 = Gauge32: 123123123" expectpart "$($snmpgetnext $OID)" 0 "$OID6 = Gauge32: 123123123"
NAME=ifSpeed NAME=ifSpeed
OID=$OID6 OID=$OID6
@ -222,7 +222,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifSpeed" new "Test SNMP getnext ifSpeed"
expectpart "$($snmpgetnext $OID6)" 0 "$OID7 = INTEGER: 3" expectpart "$($snmpgetnext $OID)" 0 "$OID7 = INTEGER: 3"
NAME=ifAdminStatus NAME=ifAdminStatus
OID=$OID7 OID=$OID7
@ -233,7 +233,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifAdminStatus" new "Test SNMP getnext ifAdminStatus"
expectpart "$($snmpgetnext $OID7)" 0 "$OID8 = Counter32: 123456" expectpart "$($snmpgetnext $OID)" 0 "$OID8 = Counter32: 123456"
NAME=ifInOctets NAME=ifInOctets
OID=$OID8 OID=$OID8
@ -244,7 +244,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifInOctets" new "Test SNMP getnext ifInOctets"
expectpart "$($snmpgetnext $OID8)" 0 "$OID9 = Counter64: 4294967296" expectpart "$($snmpgetnext $OID)" 0 "$OID9 = Counter64: 4294967296"
NAME=ifHCInOctets NAME=ifHCInOctets
OID=$OID9 OID=$OID9
@ -255,7 +255,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifHCInOctets" new "Test SNMP getnext ifHCInOctets"
expectpart "$($snmpgetnext $OID9)" 0 "$OID10 = INTEGER: 1" expectpart "$($snmpgetnext $OID)" 0 "$OID10 = INTEGER: 1"
NAME=ifPromiscuousMode NAME=ifPromiscuousMode
OID=$OID10 OID=$OID10
@ -266,18 +266,18 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifPromiscuousMode" new "Test SNMP getnext ifPromiscuousMode"
expectpart "$($snmpgetnext $OID10)" 0 "$OID11 = Gauge32: 1234567890" expectpart "$($snmpgetnext $OID)" 0 "$OID11 = Timeticks: (1234567890) 142 days, 21:21:18.90"
NAME=ifCounterDiscontinuityTime NAME=ifCounterDiscontinuityTime
OID=$OID11 OID=$OID11
VALUE=1234567890 VALUE="(1234567890) 142 days, 21:21:18.90"
TYPE=Gauge32 # timestamp TYPE=TimeTicks
new "Get $NAME $VALUE" new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifCounterDiscontinuityTime" new "Test SNMP getnext ifCounterDiscontinuityTime"
expectpart "$($snmpgetnext $OID11)" 0 "$OID12 = INTEGER: 1" expectpart "$($snmpgetnext $OID)" 0 "$OID12 = INTEGER: 1"
NAME=ifStackStatus NAME=ifStackStatus
OID=$OID12 OID=$OID12
@ -288,7 +288,7 @@ new "Get $NAME $VALUE"
expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE" expectpart "$($snmpget $OID)" 0 "$OID = $TYPE: $VALUE"
new "Test SNMP getnext ifStackStatus" new "Test SNMP getnext ifStackStatus"
expectpart "$($snmpgetnext $OID12)" 0 "" # XXX table OID #expectpart "$($snmpgetnext $OID)" 0 "" # XXX table OID should it work?
#----------------- table #----------------- table