<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";
        color:black;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
pre
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:Arial;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:Arial;
        color:navy;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:Arial;
        color:navy;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Greger,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>When I dial out via the PSTN the call goes
out showing the SER username<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>However, I want the call to go out showing
the user&#8217;s alias<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Lets say my gateway is 10.0.0.1<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>My SER installation is 10.0.0.2 <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>username 8000 and alias is 2075634<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>The user dials 442074567<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>When a call goes out, there is an invite
from <a href="mailto:8000@10.0.0.2">8000@10.0.0.2</a> to <a
href="mailto:442074567@10.0.0.1">442074567@10.0.0.1</a> &nbsp;&nbsp;and so the
gateway dials 442074567 on the PSTN<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>However I want the invite message to show
it is from <a href="mailto:2075634@10.0.0.2">2075634@10.0.0.2</a> &nbsp;when a
call goes out.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Andy<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New Roman"><span style='font-size:12.0pt;color:windowtext'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
size=2 color=black face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma;
color:windowtext'> Greger V. Teigre [mailto:greger@teigre.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> 13 June 2006 06:57<br>
<b><span style='font-weight:bold'>To:</span></b> Andy Thomas<br>
<b><span style='font-weight:bold'>Cc:</span></b> serusers@lists.iptel.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [Serusers] rewriting
the outgoing URI to its alias</span></font><font color=black><span
style='color:windowtext'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>Andy,<br>
I'm still not sure what you mean when referring to the &quot;username&quot; and
I'm not sure what you are trying to accomplish. If you are referring to the
Request-URI, you need to lookup based on your current Request-URI (whatever
that is at the point in your ser.cfg you want to change RURI). However, if you
are looking at getting a correct caller-id, you should rather use
Remote-Party-Id.<br>
&nbsp;&nbsp;&nbsp; The RURI should be the callee, so setting the ruri to the
caller doesn't make sense to me. Maybe you can tell what you are trying to
accomplish?<br>
g-)<br>
<br>
Andy Thomas wrote: <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"><!--[if gte mso 9]><xml>
  <u1:shapedefaults u2:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
  <u1:shapelayout u3:ext="edit">
   <u1:idmap u3:ext="edit" data="1"/>
  </u1:shapelayout>
</xml><![endif]--></u1:SmartTagType>Greger,<u1:p></u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Im already doing this for calls coming
into my SER installation.<u1:p></u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>However I want to do it the other way
around, i.e. from SER/UA to PSTN<u1:p></u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Therefore I want to rewrite the username
if the outgoing INVITE message to be the alias, not the location, when sending
to the PSTN.<u1:p></u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Andy<u1:p></u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New Roman"><span style='font-size:12.0pt;color:windowtext'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
size=2 color=black face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma;
color:windowtext'> Greger V. Teigre [<a href="mailto:greger@teigre.com">mailto:greger@teigre.com</a>]
<br>
<b><span style='font-weight:bold'>Sent:</span></b> 12 June 2006 09:33<br>
<b><span style='font-weight:bold'>To:</span></b> Andy Thomas<br>
<b><span style='font-weight:bold'>Cc:</span></b> <st1:PersonName u4:st="on"><a
href="mailto:serusers@lists.iptel.org">serusers@lists.iptel.org</a></st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [Serusers] rewriting
the outgoing URI to its alias</span></font><o:p></o:p></p>

</div>

<u1:p></u1:p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>I see a lot of confusion on the different user related
ids in SIP. Let me try to explain (and answer your question, Andy, at the end
of the post...)<br>
<br>
Let's start at the user agent(UA) side:<br>
--------------------<br>
AOR: Address of record is the <a href="mailto:sip:myuser@domain.com">sip:myuser@domain.com</a>
address that you are known as, just like your email address.&nbsp; Many user
agents don't ask for AOR, but builds it from other parameters you need to set<br>
Username: The username is normally the user (before @) of AOR)<br>
Realm: Often the domain portion of the AOR, thus AOR = sip:username@realm<br>
Friendly name/displayname: &quot;My name&quot;<br>
<br>
Out of this info, the From header is constructed:<br>
From: &quot;My name&quot; &lt;sip:username@realm&gt;<br>
---<br>
Entirely separate (but sometimes confused in user agents):<br>
Authentication username: The user used for authentication<br>
Authentication realm: The realm to authenticate within<br>
Very often the authentication realm is implicitly assumed to be the same as the
AOR realm<br>
---<br>
Then, the user agent will create the Contact header. The Contact header should
be the public contact address of your current location. Thus: Contact:
sip:username@mypublicip:5060<br>
If the user agent is behind a NAT, the mypublicip will be a private address.<br>
---<br>
A sidenote: Unless registration server is explicitly specified, the realm in
the AOR will be used for looking up the SIP registration server using DNS SRV
or A lookups. You should avoid putting the FQDN of your SIP server in the
realm. <br>
Also, you may in some user agents specify outbound proxy. This is the proxy
where the user agent will send INVITEs (and other outbound messages).<br>
-------------------<br>
<br>
And on the SER side:<br>
-------------------<br>
Authentication user/realm are used to do Digest authentication, but are then
forgotten (i.e. not stored).<br>
The AOR is registered in the location table, together with the Contact header,
as well as the source ip and port (if different from Contact). The
fix_nated_register() function handles this setting of the so-called received
parameter.<br>
<br>
So, to the routing: <br>
- Messages that need to be routed (i.e. do not have Route headers) will have a
Request URI; the first line and the part after the message type: INVITE <a
href="mailto:sip:username@domain.com">sip:username@domain.com</a><br>
- It is by changing this request URI, you do routing.&nbsp; The t_relay()
command uses the URI to forward the message correctly<br>
- Before forwarding to a user agent, you want the request uri to be the same as
the stored Contact header for the AOR you are looking up. If not, the user
agent may reply with a 404 User not found<br>
- The From header is NOT used for routing, and for backwards RFC compatibility,
you should not change the From header as some UAs will use the content of the
&gt;From header to match a dialog (however, if your UAs from experience still
work, there should not be a problem doing it, it's just not RFC-compliant and
may pop up and kick your butt later ;-)<br>
- The AOR in location table is used for looking up incoming messages if you can
find a direct match between the Request-URI in the incoming message and the
stored AOR. If not, you can use the aliases table (and
lookup(&quot;aliases&quot;)) to match the Request-URI with something in the
aliases table, that again will map to the AOR in the location table<br>
---<br>
So keeping this (fairly simple) concept in focus: Routing (regardless of LCR,
avps or whatever) should focus on finding the correct Request-URI before you
call t_relay().<br>
<br>
BUT, there are ways of &quot;messing&quot; up this...<br>
---<br>
- There are several commands in SER you can use to override the Request-URI
(forward_*). They should be avoided, unless you have a valid reason for having
a Request-URI in the message you are forwarding that is NOT resolvable (either
IP address or DNS name or DNS SRV/A resolvable) to the party you are forwarding
to. The reason can be if you want the R-URI to contain the AOR and then forward
the message to a server handling voicemail<br>
- The dst_uri parameter (implicitly set by lookup) will tell t_relay() to send
the message to dst_uri instead of the Request-URI. lookup() will set this when
it finds that the Contact stored for the AOR also has an associated received
ip:port (because the user agent was NATed)<br>
<br>
In general trying all sorts of tricks o fix-up things the way you need it may
not be so smart. Stick to the basics and question yourself: Is this something I
really want to do?<br>
----------------------<br>
<br>
To Andy, you want the aliases table to map to the AOR (as registered by the UA
in the REGISTER command). You do lookup(&quot;aliases&quot;) to resolve your
DID into an AOR. Then, later you can do lookup(&quot;location&quot;) to map the
AOR to the location of the UA (i.e. Contact/dst_uri). Then your Request-URI
will be correct.<br>
<br>
g-)<br>
<br>
Andy Thomas wrote: <u1:p></u1:p><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Does anyone know how I would do this-<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>For all users who have PSTN access, they are assigned
a number in the MySQL alias table which matches a PSTN DDI number.<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>e.g. user 8000 has an alias of 2071231234, so on an
incoming call the lookup(&#8220;aliases&#8221;) function correctly matches the
DDI to the user.<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I want my ser.cfg to rewrite the user on an outgoing
call, if a number exists in the alias table for that user<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Obviously, the rewriteuser function will be used, but
what do I put in after that?<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I have tried rewriteuser (lookup
(&#8221;aliases&#8221;))&nbsp; but that doesn&#8217;t work<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Can anyone help?<u5:p></u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u1:p></u1:p><o:p></o:p></p>

<pre wrap=""><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'>

<hr size=4 width="90%" align=center>

</span></font></pre><pre style='text-align:center'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>_______________________________________________<u1:p></u1:p><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>Serusers mailing list<u1:p></u1:p><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="mailto:Serusers@lists.iptel.org">Serusers@lists.iptel.org</a><u1:p></u1:p><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="http://lists.iptel.org/mailman/listinfo/serusers">http://lists.iptel.org/mailman/listinfo/serusers</a><u1:p></u1:p><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>&nbsp; <u1:p></u1:p><o:p></o:p></span></font></pre><pre
wrap=""><font size=2 color=black face="Courier New"><span style='font-size:
10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre style='text-align:center'><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>

<hr size=4 width="90%" align=center>

</span></font></pre><pre><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>_______________________________________________<o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>Serusers mailing list<o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="mailto:Serusers@lists.iptel.org">Serusers@lists.iptel.org</a><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="http://lists.iptel.org/mailman/listinfo/serusers">http://lists.iptel.org/mailman/listinfo/serusers</a><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>&nbsp; <o:p></o:p></span></font></pre></div>

</body>

</html>