]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5668 --resolve mod_rayo: offer from/to do not match SIP
authorChris Rienzo <chris.rienzo@grasshopper.com>
Tue, 6 Aug 2013 19:30:22 +0000 (15:30 -0400)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Tue, 6 Aug 2013 19:30:22 +0000 (15:30 -0400)
src/mod/event_handlers/mod_rayo/mod_rayo.c

index 3aa255f8332f60b7ddccbb998ac8adcb5dfc94af..79d2179053b8c0477acc9060c81d8fc5007d3b69 100644 (file)
@@ -2728,12 +2728,35 @@ static iks *rayo_create_offer(struct rayo_call *call, switch_core_session_t *ses
        switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel);
        iks *presence = iks_new("presence");
        iks *offer = iks_insert(presence, "offer");
+       const char *val;
 
        iks_insert_attrib(presence, "from", RAYO_JID(call));
-       iks_insert_attrib(offer, "from", profile->caller_id_number);
-       iks_insert_attrib(offer, "to", profile->destination_number);
        iks_insert_attrib(offer, "xmlns", RAYO_NS);
 
+       if ((val = switch_channel_get_variable(channel, "sip_from_uri"))) {
+               /* is a SIP call - pass the URI */
+               if (!strchr(val, ':')) {
+                       iks_insert_attrib_printf(offer, "from", "sip:%s", val);
+               } else {
+                       iks_insert_attrib(offer, "from", val);
+               }
+       } else {
+               /* pass caller ID */
+               iks_insert_attrib(offer, "from", profile->caller_id_number);
+       }
+
+       if ((val = switch_channel_get_variable(channel, "sip_to_uri"))) {
+               /* is a SIP call - pass the URI */
+               if (!strchr(val, ':')) {
+                       iks_insert_attrib_printf(offer, "to", "sip:%s", val);
+               } else {
+                       iks_insert_attrib(offer, "to", val);
+               }
+       } else {
+               /* pass dialed number */
+               iks_insert_attrib(offer, "to", profile->destination_number);
+       }
+
        /* add signaling headers */
        {
                switch_event_header_t *var;