diff options
Diffstat (limited to 'lib/yang_wrappers.c')
-rw-r--r-- | lib/yang_wrappers.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index dc049a3..a013395 100644 --- a/lib/yang_wrappers.c +++ b/lib/yang_wrappers.c @@ -168,10 +168,9 @@ struct yang_data *yang_data_new_dec64(const char *xpath, double value) double yang_dnode_get_dec64(const struct lyd_node *dnode, const char *xpath_fmt, ...) { - const double denom[19] = {1e0, 1e-1, 1e-2, 1e-3, 1e-4, - 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, - 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, - 1e-15, 1e-16, 1e-17, 1e-18}; + const double denom[19] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, + 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, + 1e14, 1e15, 1e16, 1e17, 1e18 }; const struct lysc_type_dec *dectype; const struct lyd_value *dvalue; @@ -179,7 +178,7 @@ double yang_dnode_get_dec64(const struct lyd_node *dnode, const char *xpath_fmt, dectype = (const struct lysc_type_dec *)dvalue->realtype; assert(dectype->basetype == LY_TYPE_DEC64); assert(dectype->fraction_digits < sizeof(denom) / sizeof(*denom)); - return (double)dvalue->dec64 * denom[dectype->fraction_digits]; + return (double)dvalue->dec64 / denom[dectype->fraction_digits]; } double yang_get_default_dec64(const char *xpath_fmt, ...) @@ -1020,6 +1019,13 @@ void yang_str2mac(const char *value, struct ethaddr *mac) (void)prefix_str2mac(value, mac); } +void yang_dnode_get_mac(struct ethaddr *mac, const struct lyd_node *dnode, + const char *xpath_fmt, ...) +{ + const char *canon = YANG_DNODE_XPATH_GET_CANON(dnode, xpath_fmt); + (void)prefix_str2mac(canon, mac); +} + struct yang_data *yang_data_new_date_and_time(const char *xpath, time_t time) { struct tm tm; @@ -1046,6 +1052,17 @@ struct yang_data *yang_data_new_date_and_time(const char *xpath, time_t time) return yang_data_new(xpath, timebuf); } +float yang_dnode_get_bandwidth_ieee_float32(const struct lyd_node *dnode, + const char *xpath_fmt, ...) +{ + const char *canon = YANG_DNODE_XPATH_GET_CANON(dnode, xpath_fmt); + float value; + + assert(sscanf(canon, "%a", &value) == 1); + + return value; +} + const char *yang_nexthop_type2str(uint32_t ntype) { switch (ntype) { |