returns the body of the SIP message (if none, an empty body will be returned) */
| 429 | /* returns the body of the SIP message (if none, an empty body will be returned) |
| 430 | */ |
| 431 | inline static int get_body(struct sip_msg *msg, str *body) |
| 432 | { |
| 433 | unsigned int hdrs_len; |
| 434 | int ct_len; |
| 435 | |
| 436 | if (sdp_get_custom_body(msg, body) == 0) { |
| 437 | LM_DBG("found custom 'SDP ops' body, len: %d\n", body->len); |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | if ( parse_headers(msg,HDR_EOH_F, 0)==-1 ) |
| 442 | return -1; |
| 443 | |
| 444 | if (msg->unparsed){ |
| 445 | hdrs_len=(unsigned int)(msg->unparsed-msg->buf); |
| 446 | } else { |
| 447 | return -1; |
| 448 | } |
| 449 | |
| 450 | if ((hdrs_len+2<=msg->len) && (strncmp(CRLF,msg->unparsed,CRLF_LEN)==0) ) |
| 451 | body->s = msg->unparsed + CRLF_LEN; |
| 452 | else if ( (hdrs_len+1<=msg->len) && |
| 453 | (*(msg->unparsed)=='\n' || *(msg->unparsed)=='\r' ) ) |
| 454 | body->s = msg->unparsed + 1; |
| 455 | else { |
| 456 | /* no body */ |
| 457 | body->s = NULL; |
| 458 | body->len = 0; |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | /* determin the length of the body */ |
| 463 | body->len = msg->buf + msg->len - body->s; |
| 464 | |
| 465 | /* double check the len against content-length hdr |
| 466 | (if present, it must be already parsed); |
| 467 | NOTE that the CT hdr may be missing if using UDP, so |
| 468 | we do not consider its missing an err case */ |
| 469 | if (msg->content_length) { |
| 470 | ct_len = get_content_length( msg ); |
| 471 | if (ct_len<body->len) |
| 472 | body->len = ct_len; |
| 473 | } else if (msg->rcv.proto!=PROTO_UDP) { |
| 474 | /* no ct -> no body */ |
| 475 | body->s = NULL; |
| 476 | body->len = 0; |
| 477 | } |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | /* |
| 483 | * Get the callid of a message. If returned value is 0, the callid is stored |
no test coverage detected