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

Function pv_get_msg_body

pvar.c:1649–1749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1647}
1648
1649static int pv_get_msg_body(struct sip_msg *msg, pv_param_t *param,
1650 pv_value_t *res)
1651{
1652 str s;
1653 int idx=-1;
1654 int idxf=-1;
1655 int distance=0;
1656 struct sip_msg_body* sbody;
1657 struct body_part* body_part;
1658 struct body_part* neg_index[2];
1659 unsigned int mime;
1660
1661 if(msg==NULL)
1662 return -1;
1663
1664 if (pv_get_spec_index(msg, param, &idx, &idxf)!=0) {
1665 LM_ERR("invalid index\n");
1666 return -1;
1667 }
1668
1669 /* any index specified */
1670 if (param->pvi.type==0 || idxf==PV_IDX_ALL) {
1671 if (param->pvn.u.isname.name.n==0) {
1672 /* no name/mime -> requests all bodies */
1673 if (get_body( msg, &s)!=0 || s.len==0 ) {
1674 LM_DBG("no message body\n");
1675 return pv_get_null(msg, param, res);
1676 }
1677 goto end;
1678 } else {
1679 /* return first part with the requested mime */
1680 idx = 0;
1681 }
1682 }
1683
1684 if ( parse_sip_body(msg)<0 || (sbody=msg->body)==NULL ) {
1685 LM_DBG("no body found\n");
1686 return pv_get_null(msg, param, res);
1687 }
1688
1689 mime = param->pvn.u.isname.name.n;
1690 LM_DBG("--------mime is <%d>, idx=%d\n",mime, idx);
1691
1692#define first_part_by_mime( _part_start, _part_end, _mime) \
1693 do {\
1694 _part_end = _part_start;\
1695 while( (_part_end) && \
1696 !(is_body_part_received(_part_end) && ((_mime)==0 || \
1697 (_mime)==(_part_end)->mime )) ) { \
1698 _part_end = (_part_end)->next; \
1699 } \
1700 }while(0)
1701
1702 if (idx<0) {
1703 first_part_by_mime( &sbody->first, neg_index[1], mime );
1704 neg_index[0] = neg_index[1];
1705
1706 if (neg_index[0]==NULL) {

Callers 1

pv_get_sdpFunction · 0.85

Calls 5

pv_get_spec_indexFunction · 0.85
get_bodyFunction · 0.85
pv_get_nullFunction · 0.85
parse_sip_bodyFunction · 0.85
pv_get_strvalFunction · 0.85

Tested by

no test coverage detected