| 4248 | } |
| 4249 | |
| 4250 | static inline void pv_handle_rtpstat(enum rtpe_stat s, str *index, |
| 4251 | pv_value_t *res, bencode_item_t *dict) |
| 4252 | { |
| 4253 | |
| 4254 | bencode_item_t *c, *i, *m, *tag = NULL; |
| 4255 | int mos, mos_no, mos_max, mos_min, mos_at; |
| 4256 | time_t created = 0; |
| 4257 | str tmp; |
| 4258 | char *key; |
| 4259 | enum rtpe_stat_type t = rtpe_get_stat_by_type(s); |
| 4260 | enum rtpe_stat_dict d = rtpe_get_stat_by_dict(s); |
| 4261 | |
| 4262 | /* init to null */ |
| 4263 | pv_get_null(NULL, NULL, res); |
| 4264 | |
| 4265 | if (t == STAT_MIN_AT || t == STAT_MAX_AT) { |
| 4266 | /* for min and max, store when the session was created */ |
| 4267 | c = bencode_dictionary_get_expect(dict, "created", BENCODE_INTEGER); |
| 4268 | if (!c) { |
| 4269 | LM_DBG("no created number in the dictionary!\n"); |
| 4270 | return; |
| 4271 | } |
| 4272 | created = c->value; |
| 4273 | } |
| 4274 | |
| 4275 | if (index) { |
| 4276 | tag = bencode_dictionary_get_tag(dict, index); |
| 4277 | if (!tag) { |
| 4278 | LM_DBG("no session with tag %.*s\n", index->len, index->s); |
| 4279 | return; |
| 4280 | } |
| 4281 | } |
| 4282 | dict = bencode_dictionary_get_expect(dict, "SSRC", BENCODE_DICTIONARY); |
| 4283 | if (!dict) { |
| 4284 | LM_DBG("no SSRC node in response!\n"); |
| 4285 | return; |
| 4286 | } |
| 4287 | |
| 4288 | /* search for the dictionary of this tag */ |
| 4289 | mos = 0; |
| 4290 | mos_no = 0; |
| 4291 | mos_max = -1; |
| 4292 | mos_min = INT_MAX; |
| 4293 | mos_at = -1; |
| 4294 | for (c = dict->child; c; c = c->sibling) { |
| 4295 | /* if a tag exists, check if this SSRC belongs to it */ |
| 4296 | if (tag) { |
| 4297 | if (c->type == BENCODE_STRING) { |
| 4298 | BENCODE_GET_STR(c, &tmp); |
| 4299 | if (!bencode_dictionary_tag_has_ssrc(tag, &tmp, index)) |
| 4300 | continue; |
| 4301 | /* this is the SSRC we are interested in! */ |
| 4302 | c = c->sibling; |
| 4303 | if (!c) { |
| 4304 | LM_DBG("no value for %.*s SSRC\n", tmp.len, tmp.s); |
| 4305 | return; |
| 4306 | } |
| 4307 | } else |
no test coverage detected