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

Function ospProcessSubscribe

modules/osp/cnam.c:311–363  ·  view source on GitHub ↗

* Process SUBSCRIBE * param msg SIP message * param cnamrecord Cached CNAM record * param ignore2 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure */

Source from the content-addressed store, hash-verified

309 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
310 */
311int ospProcessSubscribe(
312 struct sip_msg* msg,
313 str* cnamrecord)
314{
315 int expire;
316 str contact = { NULL, 0 };
317 str tag = { NULL, 0 };
318 str notify = { "NOTIFY", 6 };
319 dlg_t *dialog;
320 char buffer[OSP_HEADERBUF_SIZE];
321 str headers = { buffer, sizeof(buffer) };
322 int result = MODULE_RETURNCODE_FALSE;
323
324 LM_DBG("cnam record '%.*s'\n", cnamrecord->len, cnamrecord->s);
325 /* Parse SUBSCRIBE */
326 if (ospParseSubscribe(msg) == 0) {
327 expire = 0;
328 if (msg->expires != NULL) {
329 expire = ((exp_body_t*)msg->expires->parsed)->val;
330 }
331
332 if (get_local_contact(msg->rcv.bind_address, NULL, &contact) < 0) {
333 LM_WARN("failed to get contact\n");
334 }
335
336 /* Send 200 OK reply */
337 if (ospReply200(msg, expire, &contact, &tag) == 0) {
338 /* Create dialog */
339 if ((dialog = ospCreateDialog(msg, &tag)) != NULL) {
340 /* Generate extra headers */
341 if (ospExtraHeaders(msg, expire, &contact, &headers) == 0) {
342 /* Send NOTIFY */
343 if (run_tm_api(&osp_tmb, t_request_within, &notify, &headers, cnamrecord, dialog, ospNotifyCallback, NULL, NULL) < 0) {
344 LM_ERR("failed to send notify\n");
345 } else {
346 result = MODULE_RETURNCODE_TRUE;
347 }
348 } else {
349 LM_ERR("failed to generate extre headers\n");
350 }
351 } else {
352 LM_ERR("failed to create dialog\n");
353 }
354 ospFreeDialog(dialog);
355 } else {
356 LM_ERR("failed to send ok\n");
357 }
358 } else {
359 LM_ERR("failed to parse subscribe\n");
360 }
361
362 return result;
363}

Callers

nothing calls this directly

Calls 6

ospParseSubscribeFunction · 0.85
get_local_contactFunction · 0.85
ospReply200Function · 0.85
ospCreateDialogFunction · 0.85
ospExtraHeadersFunction · 0.85
ospFreeDialogFunction · 0.85

Tested by

no test coverage detected