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

Function do_parse_rr_body

parser/parse_rr.c:41–142  ·  view source on GitHub ↗

* Parse Route or Record-Route body */

Source from the content-addressed store, hash-verified

39 * Parse Route or Record-Route body
40 */
41static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
42{
43 rr_t* r, *last;
44 str s;
45 param_hooks_t hooks;
46
47 /* Make a temporary copy of the string pointer */
48 if(buf==0 || len<=0)
49 {
50 LM_DBG("no body for record-route\n");
51 r = NULL;
52 *head = 0;
53 goto parse_error;
54 }
55 s.s = buf;
56 s.len = len;
57 trim_leading(&s);
58
59 last = 0;
60
61 while(1) {
62 /* Allocate and clear rr structure */
63 r = (rr_t*)pkg_malloc(sizeof(rr_t));
64 if (!r) {
65 LM_ERR("no pkg memory left\n");
66 goto error;
67 }
68 memset(r, 0, sizeof(rr_t));
69
70 /* Parse name-addr part of the header */
71 if (parse_nameaddr(&s, &r->nameaddr) < 0) {
72 LM_ERR("failed to parse name-addr\n");
73 goto parse_error;
74 }
75 r->len = r->nameaddr.len;
76
77 /* Shift just behind the closing > */
78 s.s = r->nameaddr.name.s + r->nameaddr.len; /* Point just behind > */
79 s.len -= r->nameaddr.len;
80
81 trim_leading(&s); /* Skip any white-chars */
82
83 if (s.len == 0) goto ok; /* Nothing left, finish */
84
85 if (s.s[0] == ';') { /* Route parameter found */
86 s.s++;
87 s.len--;
88 trim_leading(&s);
89
90 if (s.len == 0) {
91 LM_ERR("failed to parse params\n");
92 goto parse_error;
93 }
94
95 /* Parse all parameters */
96 if (parse_params(&s, CLASS_ANY, &hooks, &r->params) < 0) {
97 LM_ERR("failed to parse params\n");
98 goto parse_error;

Callers 2

parse_rr_bodyFunction · 0.85
parse_rrFunction · 0.85

Calls 4

trim_leadingFunction · 0.85
parse_nameaddrFunction · 0.85
parse_paramsFunction · 0.85
free_rrFunction · 0.85

Tested by

no test coverage detected