[Serusers] I need to alter and duplicate REGISTER saves

Jerome Martin jmartin at western.fr
Fri May 6 11:23:11 CEST 2005


Hi,

I tried many things but none seems to work. I am using ser 0.8.4.
With the following code in ser.cfg, every time a REGISTER arrives with 
the 33XXXXXX format, the request is logged in my duplicates log, but the 
subst line does not seem to work. I tried replace and replace_all also, 
but no luck.
I though that maybe the exported shell variables I am dumping in my log 
file are not updated after the subst, but a serctl ul show clearly 
display only the 33XXXXXX numbers in the location database.

Here is the code I am using :

        if (method=="REGISTER") {

                        save("location");
                        exec_msg("echo -e REGISTER `date` '\n' `printenv 
| grep SIP` '\n' >> /var/log/ser-register.log");
                       
                        if (search("^From.*sip:33.*")) {
                                subst('/sip\:33/sip\:0/g');
                                save_noreply("location");
                                exec_msg("echo -e REGISTER DUP `date` 
'\n' `printenv | grep SIP` '\n' >> /var/log/ser-register-dup.log");
                                break;
                        }

                        break;
                };

Any idea ?


Alan Litster wrote:

>>Hi,
>>
>>Thanks for your reply.
>>
>>Alan Litster wrote:
>>
>>    
>>
>>>Doing it the way you've suggested would mean modifying the From and To
>>>
>>>
>>>      
>>>
>>Indeed. I already tried that, using the replace() / replace_all()
>>textops functions, but I could not even manage to have the header
>>modified. It just did nothing at all ....
>>    
>>
>I've had the situation where I've needed to update the Refer-To: header as
>the gateway was unable to handle it in a satisfactory manor. For this I used
>the subst function in the textops module, I'm not sure if this functions any
>differently to the replace functions.
>
>  
>
>>Besides, in the recent thread Re: [Serusers] HF replace, someone said
>>that modifying From: and To "is not allowed".
>>    
>>
>It's recomended not too, though most people want to modify the From on
>INVITE's. It may not be such a problem on a REGISTER method, just do a
>save_noreply("location")
>
>  
>
>>But I am wondering ... ain't it the "Contact:" header which is used by
>>register.so/usrloc.so ?
>>    
>>
>It's Contact header is used as the location of the UAC,
>'username at ipaddress_of_uac'. The From/To fields are used as the username
>part on the sip registrar, generally the From/To are the same though may not
>always be the case.
>See http://www.faqs.org/rfcs/rfc3261.html section 10.2
>
>  
>
>>>fields, then doing a save. This should in theory all the UAC to
>>>      
>>>
>>register on
>>    
>>
>>>the two addresses, it could get a little messy.
>>>
>>>
>>>      
>>>
>>I agree. I anticipate a few issues on that side.
>>
>>    
>>
>>>An alternative would be to create an alias, this would be fine
>>>      
>>>
>>if you knew
>>    
>>
>>>before hand what format they would register with.
>>>
>>>
>>>      
>>>
>>Well, I know which server will send what format, and I can afford to
>>hardcode the IPs in the ser.cfg. But after reading the section about
>>aliases in the ser Admin's manual, I must confess it is not clear for
>>me. Could you elaborate on that idea ?
>>    
>>
>In your example you want lookup("33122334455") to return the same as
>lookup("0122334455"). Well if 33122334455 is an alias for 0122334455 it
>will. First it does an alias lookup of 33122334455 at mydomain.com which
>replaces the r-uri with 0122334455 at mydomain.com then it does a lookup on
>that, finds a match and does a further replace with 0122334455 at 1.2.3.4 (The
>IP address of the UAC from the Contact record)
>
>  
>
>>>>-----Original Message-----
>>>>From: serusers-bounces at iptel.org [mailto:serusers-bounces at lists.iptel.org]On
>>>>Behalf Of Jerome Martin
>>>>Sent: 04 May 2005 15:16
>>>>To: serusers at lists.iptel.org
>>>>Subject: [Serusers] I need to alter and duplicate REGISTER saves
>>>>
>>>>
>>>>Hello everyone,
>>>>
>>>>After looking everywhere in the docs and ML archives, I couldn't find a
>>>>way to solve my problem, so I would appreciate any help.
>>>>
>>>>We have several iPBX servers sending REGISTERs to a SER registrar. Some
>>>>of those servers send us the numbers to register as aor in the form
>>>>0XXXXXXXXX (local numbering plan), some other in the form 33XXXXXXXXX
>>>>(local country code prefix). For various reasons, we need to handle
>>>>those different REGISTERs simultaneously, and be able to lookup both
>>>>formats in the location database.
>>>>
>>>>What I'm looking for is a way to "duplicate" the REGISTER entries, i.e.
>>>>when ser receives a REGISTER for 33XXXXXXXXX, I'd like it to save() the
>>>>33XXXXXXXXX, but also create an entry for the corresponding 0XXXXXXXXX.
>>>>
>>>>Example : SER receives a REGISTER request for 33122334455. I'd like to
>>>>have two aors in the location database, so that lookup("33122334455")
>>>>and lookup("0123344556") would both return the same thing.
>>>>
>>>>What I have in mind is something like this :
>>>>
>>>>if (method=="REGISTER") {
>>>>   # Always save the original aor
>>>>   save("location");
>>>>
>>>>  # If the number starts with 33, also save a duplicate aor in the
>>>>0XXXXXXXXX format
>>>>   if (search("^From.*sip:33.*")) {
>>>>
>>>>      # Insert some code to alter the received SIP message and
>>>>        
>>>>
>>change the
>>    
>>
>>>>      # number in order to save the 0XXXXXXXXX aor
>>>>      # ...
>>>>      # ...
>>>>      # ...
>>>>
>>>>       save("location");
>>>>       break;
>>>>   }
>>>>   break;
>>>>};
>>>>
>>>>Can anyone help ?
>>>>
>>>>Best Regards,
>>>>Jerome Martin
>>>>
>>>>_______________________________________________
>>>>Serusers mailing list
>>>>serusers at lists.iptel.org
>>>>http://lists.iptel.org/mailman/listinfo/serusers
>>>>
>>>>
>>>>        
>>>>
>>>-----------------------------------------------------------------
>>>      
>>>
>>----------------------------
>>    
>>
>>>This email, and any files transmitted with it, is copyright and
>>>      
>>>
>>may contain confidential information.
>>    
>>
>>>The contents are intended for the use of the addressee(s) only.
>>>Unauthorized use may be unlawful.
>>>If you receive this email by mistake, please advise sender immediately.
>>>The views of the author may not necessarily constitute the views
>>>      
>>>
>>of the company.
>>    
>>
>>>Nothing in this mail shall bind the company in any contract or
>>>      
>>>
>>obligation.
>>    
>>
>>>Tel  +44 (0) 20 8002 6000
>>>Fax  +44 (0) 20 8002 6060
>>>
>>>______________________________________________________________________
>>>This email has been scanned by the MessageLabs Email Security System.
>>>For more information please visit http://www.messagelabs.com/email
>>>______________________________________________________________________
>>>
>>>
>>>      
>>>
>
>---------------------------------------------------------------------------------------------
>This email, and any files transmitted with it, is copyright and may contain confidential information.
>The contents are intended for the use of the addressee(s) only.
>Unauthorized use may be unlawful.
>If you receive this email by mistake, please advise sender immediately.
>The views of the author may not necessarily constitute the views of the company.
>Nothing in this mail shall bind the company in any contract or obligation.
>
>Tel  +44 (0) 20 8002 6000
>Fax  +44 (0) 20 8002 6060
>
>______________________________________________________________________
>This email has been scanned by the MessageLabs Email Security System.
>For more information please visit http://www.messagelabs.com/email 
>______________________________________________________________________
>  
>




More information about the sr-users mailing list