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

Function contact_iterator

parser/contact/parse_contact.c:132–228  ·  view source on GitHub ↗

* Contact header field iterator, returns next contact if any, it doesn't * parse message header if not absolutely necessary */

Source from the content-addressed store, hash-verified

130 * parse message header if not absolutely necessary
131 */
132int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
133{
134 static struct hdr_field* hdr = 0;
135 struct hdr_field* last;
136 contact_body_t* cb;
137
138 if (!msg) {
139 LM_ERR("invalid parameter value\n");
140 return -1;
141 }
142
143 if (!prev) {
144 /* No pointer to previous contact given, find topmost
145 * contact and return pointer to the first contact
146 * inside that header field
147 */
148 hdr = msg->contact;
149 if (!hdr) {
150 if (parse_headers(msg, HDR_CONTACT_F, 0) == -1) {
151 LM_ERR("failed to parse headers\n");
152 return -1;
153 }
154
155 hdr = msg->contact;
156 }
157
158 if (hdr) {
159 if (parse_contact(hdr) < 0) {
160 LM_ERR("failed to parse Contact\n");
161 return -1;
162 }
163 } else {
164 *c = 0;
165 return 1;
166 }
167
168 cb = (contact_body_t*)hdr->parsed;
169 *c = cb->contacts;
170 return 0;
171 } else {
172 /* Check if there is another contact in the
173 * same header field and if so then return it
174 */
175 if (prev->next) {
176 *c = prev->next;
177 return 0;
178 }
179
180 /* Try to find and parse another Contact
181 * header field
182 */
183 last = hdr;
184 hdr = hdr->next;
185
186 /* Search another already parsed Contact
187 * header field
188 */
189 while(hdr && hdr->type != HDR_CONTACT_T) {

Callers 3

allow_registerFunction · 0.85
check_message_supportFunction · 0.85
add_rcv_param_fFunction · 0.85

Calls 1

parse_contactFunction · 0.85

Tested by

no test coverage detected