--- channels/chan_sip.c	2010-08-12 22:55:38.000000000 +0200
+++ channels/chan_sip.c	2010-08-12 23:44:18.000000000 +0200
@@ -14984,6 +14984,23 @@
 	target.chan1 = targetcall_pvt->owner;				/* Transferer to Asterisk */
 	target.chan2 = ast_bridged_channel(targetcall_pvt->owner);	/* Asterisk to target */
 
+        /* IRONTEC */
+        ast_log(LOG_NOTICE, "Hola, soy un REFER!\n");
+        ast_log(LOG_NOTICE, "Chan1: %s\n", current->chan1->name);
+        const char *ironcallid = pbx_builtin_getvar_helper(current->chan1, "SIPCALLID");
+        ast_log(LOG_NOTICE, "Call-ID pata 1: %s\n", ironcallid);
+        ast_log(LOG_NOTICE, "Hola, soy la otra parte del REFER!\n");
+        ast_log(LOG_NOTICE, "Target Chan1: %s\n", target.chan1->name);
+        if (target.chan2) {
+                pbx_builtin_setvar_helper(target.chan1, "__ORIGINAL_CALLID", ironcallid);
+                if(current->chan2) {
+                        ast_log(LOG_NOTICE, "Chan2: %s\n", current->chan2->name);
+                        ast_log(LOG_NOTICE, "Target Chan2: %s\n", target.chan2->name);
+                        pbx_builtin_setvar_helper(target.chan1, "__ORIGINAL_CALLERID", current->chan2->cid.cid_num);
+                }
+        }
+        /* /IRONTEC */
+
 	if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
 		/* Wrong state of new channel */
 		if (option_debug > 3) {
