* Process SUBSCRIBE * param msg SIP message * param cnamrecord Cached CNAM record * param ignore2 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure */
| 309 | * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure |
| 310 | */ |
| 311 | int 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, ¬ify, &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 | } |
nothing calls this directly
no test coverage detected