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

Function get_body

parser/msg_parser.h:431–480  ·  view source on GitHub ↗

returns the body of the SIP message (if none, an empty body will be returned) */

Source from the content-addressed store, hash-verified

429/* returns the body of the SIP message (if none, an empty body will be returned)
430 */
431inline 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

Callers 15

clen_builderFunction · 0.85
msg_translator.cFile · 0.85
pv_get_msg_bodyFunction · 0.85
mwi_publ_handlFunction · 0.85
uac_authFunction · 0.85
Notify2XmppFunction · 0.85
pv_authorizeFunction · 0.85
rls_handle_notifyFunction · 0.85
handle_publishFunction · 0.85
extract_sdialog_infoFunction · 0.85

Calls 1

sdp_get_custom_bodyFunction · 0.85

Tested by

no test coverage detected