SIP URI Call from outside

I have CommuniGate and Asterisk.
172.17.35.183 - Asterisk;
172.17.35.158 - CG;

Trying to call from CG to Asterisk (SIP URI (sip:200@172.17.35.183) )

Call is OK. on SIP-agent i receive CallerID(name).
but when i try to recall, SIP URI is name@172.17.35.183 instead of name@172.17.35.158.

I know this is not standard Asterisk usage, but i hope it’s possible.

Packet to Asterisk:

<— SIP read from 172.17.35.158:5060 —>
INVITE sip:200@172.17.35.183;user=phone SIP/2.0
Via: SIP/2.0/UDP 172.17.35.158:5060;branch=z9hG4bK1878;upaddr=172.17.35.2;rport
P-CGP-Identity: sbabenkov@172.17.35.158
Record-Route: sip:172.17.35.158:5060;lr
Record-Route: sip:rev.488.dialog.cgatepro;lr
Via: SIP/2.0/TCP 172.17.35.2:5060;branch=z9hG4bK024fsnl23o1s3g2qnll5mgr;rport=54652
Max-Forwards: 69
From: sip:sbabenkov@172.17.35.158;tag=bi5bqqnf6lhc745ds2i0
To: sip:200@172.17.35.183;user=phone
Call-ID: 9VOZqEvooIdRqK2AV7T71k00O6kOLD
Contact: sip:sbabenkov@172.17.35.2
CSeq: 851 INVITE
Expires: 120
Supported: 100rel,sec-agree
Privacy: none
Accept: application/sdp
User-Agent: E71-1 RM-346 210.21.006
Allow: INVITE,ACK,BYE,CANCEL,REFER,NOTIFY,OPTIONS,PRACK
P-Preferred-Identity: sip:sbabenkov@172.17.35.158
Content-Type: application/sdp
Content-Length: 523

From Asterisk to Agent:

INVITE sip:200@172.17.35.7 SIP/2.0
Via: SIP/2.0/UDP 172.17.35.183:5060;branch=z9hG4bK5577a6f8;rport
From: “sbabenkov” sip:sbabenkov@172.17.35.183;tag=as43c68036
To: sip:200@172.17.35.7
Contact: sip:sbabenkov@172.17.35.183
Call-ID: 3a4706042a3917bf2d43215870737a82@172.17.35.183
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 70
Date: Tue, 21 Apr 2009 08:44:47 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Type: application/sdp
Content-Length: 363

I’ve tried to set CALLERID(num) like this:

exten => s,n,Set(CALLERID(num)=“sip:300@172.17.35.158”)

After that i receive

From: "300@172.17.35.158" sip:sip:300@172.17.35.158@172.17.35.183;tag=as237db75d
Contact: sip:sip:300@172.17.35.158@172.17.35.183

I just want Asterisk not to add it’s IP in the end.

Is it possible without source editing ?
If not, where and what should i change?

Sorry for my English… it’s not my native language.

Up. Anybody?

Problem solved with little cheating.

Ð’ from-sip-external:
exten => s,n,Set(TMP=${CUT(SIP_HEADER(From),<,2)})
exten => s,n,Set(TMP=${CUT(TMP,>,1)})
exten => s,n,Set(TMP=${IF(${TMP:0:4}=“sip:”?${TMP:4):${TMP})})
exten => s,n,Set(TMP1=${CUT(TMP,@,1)})
exten => s,n,Set(TMP2=${CUT(TMP,@,2)})
exten => s,n,Set(CALLERID(num)=${TMP1}%25${TMP2})

[from-internal-custom]
;Test if Redirect
exten => _.,10,GotoIf($[${REGEX("%" ${EXTEN})}]?20)
exten => _.,11,Goto(from-internal,${EXTEN},1)
exten => h,1,HangUp()

exten => _.,20,Set(TMP1=${CUT(EXTEN,%,1)})
exten => _.,21,Set(TMP2=${CUT(EXTEN,%,2)})
exten => _.,22,Macro(uridial,${TMP1}@${TMP2})
exten => _.,23,HangUp()