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

Function check_message_support

modules/msilo/msilo.c:1314–1392  ·  view source on GitHub ↗

* Check if REGISTER request has contacts that support MESSAGE method or * if MESSAGE method is listed in Allow header and contact does not have * methods parameter. */

Source from the content-addressed store, hash-verified

1312 * methods parameter.
1313 */
1314int check_message_support(struct sip_msg* msg)
1315{
1316 contact_t* c;
1317 unsigned int allow_message = 0;
1318 unsigned int allow_hdr = 0;
1319 str *methods_body;
1320 unsigned int methods;
1321
1322 /* Parse all headers in order to see all Allow headers */
1323 if (parse_headers(msg, HDR_EOH_F, 0) == -1)
1324 {
1325 LM_ERR("failed to parse headers\n");
1326 return -1;
1327 }
1328
1329 if (parse_allow(msg) == 0)
1330 {
1331 allow_hdr = 1;
1332 allow_message = get_allow_methods(msg) & METHOD_MESSAGE;
1333 }
1334 LM_DBG("Allow message: %u\n", allow_message);
1335
1336 if (!msg->contact)
1337 {
1338 LM_DBG("no Contact found\n");
1339 return -1;
1340 }
1341 if (parse_contact(msg->contact) < 0)
1342 {
1343 LM_ERR("failed to parse Contact HF\n");
1344 return -1;
1345 }
1346 if (((contact_body_t*)msg->contact->parsed)->star)
1347 {
1348 LM_DBG("* Contact found\n");
1349 return -1;
1350 }
1351
1352 if (contact_iterator(&c, msg, 0) < 0)
1353 return -1;
1354
1355 /*
1356 * Check contacts for MESSAGE method in methods parameter list
1357 * If contact does not have methods parameter, use Allow header methods,
1358 * if any. Stop if MESSAGE method is found.
1359 */
1360 while(c)
1361 {
1362 if (c->methods)
1363 {
1364 methods_body = &(c->methods->body);
1365 if (parse_methods(methods_body, &methods) < 0)
1366 {
1367 LM_ERR("failed to parse contact methods\n");
1368 return -1;
1369 }
1370 if (methods & METHOD_MESSAGE)
1371 {

Callers 1

m_dumpFunction · 0.85

Calls 4

parse_allowFunction · 0.85
parse_contactFunction · 0.85
contact_iteratorFunction · 0.85
parse_methodsFunction · 0.85

Tested by

no test coverage detected