Pārlūkot izejas kodu

uac: uac_replace_to() exported via inter-module api

Daniel-Constantin Mierla 10 gadi atpakaļ
vecāks
revīzija
40a598387f
2 mainītis faili ar 21 papildinājumiem un 0 dzēšanām
  1. 2 0
      modules/uac/api.h
  2. 19 0
      modules/uac/uac.c

+ 2 - 0
modules/uac/api.h

@@ -4,10 +4,12 @@
 
 
 typedef int (*uac_replace_from_t)(sip_msg_t *, str *, str *);
+typedef int (*uac_replace_to_t)(sip_msg_t *, str *, str *);
 typedef int (*uac_req_send_t)(void);
 
 typedef struct uac_binds {
 	uac_replace_from_t	replace_from;
+	uac_replace_to_t	replace_to;
 	uac_req_send_t      req_send;
 } uac_api_t;
 

+ 19 - 0
modules/uac/uac.c

@@ -512,6 +512,24 @@ static int w_replace_to(struct sip_msg* msg, char* p1, char* p2)
 
 }
 
+int replace_to_api(sip_msg_t *msg, str* pd, str* pu)
+{
+	str *uri;
+	str *dsp;
+	if ( msg->to==0 && (parse_headers(msg,HDR_TO_F,0)!=0 || msg->to==0) ) {
+		LM_ERR("failed to find/parse TO hdr\n");
+		return -1;
+	}
+
+	uri = (pu!=NULL && pu->len>0)?pu:NULL;
+	dsp = (pd!=NULL && pd->len>0)?pd:NULL;
+
+	LM_DBG("dsp=%p (len=%d) , uri=%p (len=%d)\n", dsp, dsp?dsp->len:0,
+			uri, uri?uri->len:0);
+
+	return replace_uri(msg, dsp, uri, msg->to, &rr_to_param, &restore_to_avp, 0);
+}
+
 
 static int w_uac_auth(struct sip_msg* msg, char* str, char* str2)
 {
@@ -582,6 +600,7 @@ int bind_uac(uac_api_t *uacb)
 
 	memset(uacb, 0, sizeof(uac_api_t));
 	uacb->replace_from = replace_from_api;
+	uacb->replace_to = replace_to_api;
 	uacb->req_send = uac_req_send;
 	return 0;
 }