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

Function parse_allow

parser/parse_allow.c:43–90  ·  view source on GitHub ↗

* This method is used to parse all Allow HF body. * * params: msg : sip msg * returns 0 on success, * -1 on failure. */

Source from the content-addressed store, hash-verified

41 * -1 on failure.
42 */
43int parse_allow(struct sip_msg *msg)
44{
45 unsigned int allow;
46 struct hdr_field *hdr;
47 struct allow_body *ab = 0;
48
49 /* maybe the header is already parsed! */
50 if (msg->allow && msg->allow->parsed)
51 return 0;
52
53 /* parse to the end in order to get all ALLOW headers */
54 if (parse_headers(msg,HDR_EOH_F,0)==-1 || !msg->allow)
55 return -1;
56
57 /* bad luck! :-( - we have to parse them */
58 allow = 0;
59 for( hdr=msg->allow ; hdr ; hdr=hdr->sibling) {
60 if (hdr->parsed) {
61 allow |= ((struct allow_body*)hdr->parsed)->allow;
62 continue;
63 }
64
65 ab = (struct allow_body*)pkg_malloc(sizeof(struct allow_body));
66 if (ab == 0) {
67 LM_ERR("out of pkg_memory\n");
68 return -1;
69 }
70
71 if (parse_methods(&(hdr->body), &(ab->allow))!=0) {
72 LM_ERR("bad allow body header\n");
73 set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM,
74 "error parsing ALLOW header");
75 set_err_reply(400, "bad headers");
76 goto error;
77 }
78 ab->allow_all = 0;
79 hdr->parsed = (void*)ab;
80 allow |= ab->allow;
81 }
82
83 ((struct allow_body*)msg->allow->parsed)->allow_all = allow;
84 return 0;
85
86error:
87 if(ab!=0)
88 pkg_free(ab);
89 return -1;
90}
91

Callers 3

check_message_supportFunction · 0.85
dup_req_infoFunction · 0.85
pack_ciFunction · 0.85

Calls 3

parse_methodsFunction · 0.85
set_err_infoFunction · 0.85
set_err_replyFunction · 0.85

Tested by

no test coverage detected