| 2407 | } |
| 2408 | |
| 2409 | static cJSON *dict_avp_dec_ip(struct avp_hdr * h, struct dict_avp_data *avp) |
| 2410 | { |
| 2411 | int af; |
| 2412 | char buf[INET6_ADDRSTRLEN]; |
| 2413 | |
| 2414 | if (avp->avp_basetype != AVP_TYPE_OCTETSTRING) { |
| 2415 | LM_ERR("invalid base type for IP: %d\n", avp->avp_basetype); |
| 2416 | return NULL; |
| 2417 | } |
| 2418 | |
| 2419 | af = (h->avp_value->os.len == INET6_ADDRSTRLEN?AF_INET6:AF_INET); |
| 2420 | if (inet_ntop(af, h->avp_value->os.data, buf, INET6_ADDRSTRLEN) == NULL) { |
| 2421 | LM_ERR("cannot convert to an IP\n"); |
| 2422 | return NULL; |
| 2423 | } |
| 2424 | return cJSON_CreateString(buf);; |
| 2425 | } |
| 2426 | |
| 2427 | static int dict_avp_enc_hex(cJSON *obj, struct dict_avp_data *avp, int _, str *ret) |
| 2428 | { |
nothing calls this directly
no test coverage detected