MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / extract_bwidth

Function extract_bwidth

parser/sdp/sdp_helpr_funcs.c:327–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327int extract_bwidth(str *body, str *bwtype, str *bwwitdth)
328{
329 char *cp, *cp1;
330 int len;
331 str bline;
332
333 cp1 = NULL;
334 for (cp = body->s; (len = body->s + body->len - cp) > 0;) {
335 cp1 = (char*)l_memmem(cp, "b=", len, 2);
336 if (cp1 == NULL || cp1 == body->s ||
337 cp1[-1] == '\n' || cp1[-1] == '\r')
338 break;
339 cp = cp1 + 2;
340 }
341 if (cp1 == NULL)
342 return -1;
343
344 bline.s = cp1 + 2;
345 bline.len = eat_line(bline.s, body->s + body->len - bline.s) - bline.s;
346 trim_len(bline.len, bline.s, bline);
347
348 cp = bline.s;
349 len = bline.len;
350 cp1 = (char*)l_memmem(cp, ":", len, 1);
351 if (cp1 == NULL) {
352 LM_ERR("invalid encoding in `b=%.*s'\n", bline.len, bline.s);
353 return -1;
354 }
355 len -= cp1 - cp;
356 if (len <= 0) {
357 LM_ERR("invalid encoding in `b=%.*s'\n", bline.len, bline.s);
358 return -1;
359 }
360 bwtype->len = cp1 - cp;
361 bwtype->s = cp;
362
363 /* skip ':' */
364 bwwitdth->s = cp1 + 1;
365 bwwitdth->len = len - 1;
366
367 return 0;
368}
369
370int extract_mediaip(str *body, str *mediaip, int *pf, char *line)
371{

Callers 1

parse_sdp_sessionFunction · 0.85

Calls 2

l_memmemFunction · 0.85
eat_lineFunction · 0.85

Tested by

no test coverage detected