Hi,
I am new to SER and I am looking for how to determine whether the caller and the callee are behind NAT. I found some example code from Zeus. But I do not understand how I can distinguished whether the caller is the caller and the callee is the callee. Here is the code:
/**************************************************************************************************************************/ Jan,
See below. Also, always CC the list so that other people can help you.
Zeus
Flag 4 is set when the caller is behind NAT. Flag 5 is set when the callee is behind NAT.
Would you be so kind and tell me how do you test messages to set these flags?
/* Check for UAC behind NAT This is done by nat_uac_test("7") which checks for 1. RFC 1918 address in Contact - 01 2. different src_ip and Via header - 02 3. RFC1918 in Top Via - 04 */ /*********************************************************************************************************************1. Right here - it seems to me that if both the caller and the callee are behind NAT. It will be flag as (4) and do the force_rport.*********************************************************************************************************************/ if (nat_uac_test("3")) { /* 1 + 2 = 3 */ xlog("L_NOTICE", "%rm: Client is behind NAT\n"); setflag(4); /* Flag it's a nated R-URI */ if (method=="REGISTER" || !search("^Record-Route:")) { force_rport(); if (!method=="MESSAGE") { /* MESSAGE has no Contact header, see RFC 3428 */ fix_nated_contact(); }; }; } else { xlog("L_NOTICE", "%rm: Client is not behind a NAT\n"); };... Other checking .../********************************************************************************************************************2. Then down here - it seems to me that the caller and the callee will be mark as flag 5. Then save into the location. Later on, how can I tell ifthe packet comes to SER is a caller or the callee ????. I could not understand this.********************************************************************************************************************/ if (method=="REGISTER") { if (isflagset(4)) { setflag(5); /* Turn on NAT Ping and flag it as a NAT callee */ };
if (!save("location")) { xlog("L_ERR", "%rm: Failed\n"); sl_reply_error(); }; break; };
/********************************************************************************************************************/
I am trying to make SER works with two UAs behind a same NAT. Any help would be very appreciated. Regards,Trong