diff --git a/apps/snmp/snmp_handler.c b/apps/snmp/snmp_handler.c index 3e948fd9..5914efe7 100644 --- a/apps/snmp/snmp_handler.c +++ b/apps/snmp/snmp_handler.c @@ -253,7 +253,7 @@ snmp_scalar_get(clicon_handle h, netsnmp_set_request_error(reqinfo, requests, SNMP_NOSUCHINSTANCE); goto ok; } - if (type_yang2asn1(ys, &asn1type) < 0) + if (type_yang2asn1(ys, &asn1type, 1) < 0) goto done; if ((ret = type_snmpstr2val(snmpstr, &asn1type, &snmpval, &snmplen, &reason)) < 0) goto done; @@ -383,7 +383,7 @@ clixon_snmp_scalar_handler(netsnmp_mib_handler *handler, break; case MODE_SET_RESERVE1: /* 0 */ /* Translate from YANG ys leaf type to SNMP asn1.1 type ids (not value), also cvtype */ - if (type_yang2asn1(ys, &asn1_type) < 0) + if (type_yang2asn1(ys, &asn1_type, 0) < 0) goto done; if (requestvb->type != asn1_type){ clicon_debug(1, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type); diff --git a/apps/snmp/snmp_lib.c b/apps/snmp/snmp_lib.c index 8aaec720..fbc9f83f 100644 --- a/apps/snmp/snmp_lib.c +++ b/apps/snmp/snmp_lib.c @@ -154,6 +154,7 @@ snmp_handle_free(clixon_snmp_handle *sh) * * @param[in] ys YANG leaf node * @param[out] asn1_type ASN.1 type id + * @param[in] extended Special case clixon extended types used in xml<->asn1 data conversions * @retval 0 OK * @retval -1 Error * @see type_yang2snmp, yang only @@ -162,7 +163,8 @@ snmp_handle_free(clixon_snmp_handle *sh) */ int type_yang2asn1(yang_stmt *ys, - int *asn1_type) + int *asn1_type, + int extended) { int retval = -1; yang_stmt *yrestype; /* resolved type */ @@ -201,10 +203,10 @@ type_yang2asn1(yang_stmt *ys, else if (strcmp(origtype, "timeticks")==0){ at = ASN_TIMETICKS; /* Clixon extended string type */ } - else if (strcmp(origtype, "phys-address")==0){ + else if (extended && strcmp(origtype, "phys-address")==0){ at = CLIXON_ASN_PHYS_ADDR; /* Clixon extended string type */ } - else if (strcmp(origtype, "SnmpAdminString")==0){ + else if (extended && strcmp(origtype, "SnmpAdminString")==0){ at = CLIXON_ASN_ADMIN_STRING; /* cf extension display-type 255T? */ } diff --git a/apps/snmp/snmp_lib.h b/apps/snmp/snmp_lib.h index d0f4fbef..5c02cccd 100644 --- a/apps/snmp/snmp_lib.h +++ b/apps/snmp/snmp_lib.h @@ -61,7 +61,7 @@ typedef struct clixon_snmp_handle clixon_snmp_handle; int snmp_access_str2int(char *modes_str); const char *snmp_msg_int2str(int msg); int snmp_handle_free(clixon_snmp_handle *sh); -int type_yang2asn1(yang_stmt *ys, int *asn1_type); +int type_yang2asn1(yang_stmt *ys, int *asn1_type, int extended); int type_snmp2xml(yang_stmt *ys, netsnmp_variable_list *requestvb, netsnmp_agent_request_info *reqinfo, diff --git a/apps/snmp/snmp_register.c b/apps/snmp/snmp_register.c index cfbc933f..a3409c01 100644 --- a/apps/snmp/snmp_register.c +++ b/apps/snmp/snmp_register.c @@ -136,7 +136,7 @@ mib_yang_leaf(clicon_handle h, if (yang_extension_value(ys, "max-access", IETF_YANG_SMIV2_NS, NULL, &modes_str) < 0) goto done; /* Sanity check of types */ - if (type_yang2asn1(ys, NULL) < 0) + if (type_yang2asn1(ys, NULL, 0) < 0) goto done; /* Get modes (access) read-only, read-write, not-accessible, accessible-for-notify @@ -292,7 +292,7 @@ mib_yang_table(clicon_handle h, yang_argument_get(ylist), keyname); goto done; } - if (type_yang2asn1(yleaf, &asn1type) < 0) + if (type_yang2asn1(yleaf, &asn1type, 0) < 0) // goto done; goto ok; // XXX skip if (snmp_varlist_add_variable(&table_info->indexes,