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

Function w_forward

core_cmds.c:752–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750}
751
752static int w_forward(struct sip_msg *msg, struct proxy_l *dest)
753{
754 struct sip_uri next_hop, *u;
755 struct proxy_l* p;
756 int ret;
757
758 if (!dest) {
759 /* parse uri and build a proxy */
760 if (msg->dst_uri.len) {
761 ret = parse_uri(msg->dst_uri.s, msg->dst_uri.len,
762 &next_hop);
763 u = &next_hop;
764 } else {
765 ret = parse_sip_msg_uri(msg);
766 u = &msg->parsed_uri;
767 }
768 if (ret<0) {
769 LM_ERR("forward: bad_uri dropping packet\n");
770 return E_BAD_ADDRESS;
771 }
772 /* create a temporary proxy*/
773 p=mk_proxy(u->maddr_val.len?&u->maddr_val:&u->host,
774 u->port_no, u->proto, (u->type==SIPS_URI_T)?1:0 );
775 if (p==0){
776 LM_ERR("bad host name in uri, dropping packet\n");
777 return E_BAD_ADDRESS;
778 }
779 } else {
780 if (0==(p=clone_proxy(dest))) {
781 LM_ERR("failed to clone proxy, dropping packet\n");
782 return E_OUT_OF_MEM;
783 }
784 }
785
786 ret=forward_request(msg, p);
787 free_proxy(p); /* frees only p content, not p itself */
788 pkg_free(p);
789
790 if (ret==0)
791 ret=1;
792 return ret;
793}
794
795static int w_send(struct sip_msg *msg, struct proxy_l *dest, str *headers)
796{

Callers

nothing calls this directly

Calls 6

parse_uriFunction · 0.85
parse_sip_msg_uriFunction · 0.85
mk_proxyFunction · 0.85
clone_proxyFunction · 0.85
forward_requestFunction · 0.85
free_proxyFunction · 0.85

Tested by

no test coverage detected