<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/2041/1/7/_/styles/combined.css?spaceKey=TOP&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/TOP/Registrar">Registrar</a></h2>
<h4>Page <b>added</b> by <a href="https://wiki.asterisk.org/wiki/display/~mmichelson">Mark Michelson</a>
</h4>
<br/>
<div class="notificationGreySide">
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Work in progress</td></tr></table></div>
<h1><a name="Registrar-Registrar%27sDuties"></a>Registrar's Duties</h1>
<p>The SIP registrar's job is to maintain a mapping of addresses-of-record (AoRs) to contact URIs. The registrar is responsible for letting other SIP services within a cluster know of updates to this mapping. The registrar populates this mapping based on incoming SIP REGISTER requests it receives.</p>
<h1><a name="Registrar-Registrationdata"></a>Registration data</h1>
<p>First, let's define what a single "registration" is. A registration in Asterisk SCF is a single contact URI that is bound to an AoR. We can infer from this that a single AoR may have multiple registrations associated with it, and we can also see that a single REGISTER message may create multiple registrations in Asterisk SCF.</p>
<p>Registrations need to be defined in slice since the registrar will need to replicate its state. Here we go:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
class Registration
{
/**
* The URI associated with this particular registration.
*/
string contact;
/**
* The Call-ID from the latest successful registration.
*/
string callid;
/**
* The CSeq from the latest successful registration.
*/
int cseq;
/**
* A UNIX timestamp indicating when the registration is set
* to expire
*/
int expiration;
};
sequence<Registration> RegistrationSeq;
dictionary<string, RegistrationSeq> RegistrationDict;
]]></script>
</div></div>
<p>The <tt>Registration</tt> object represents all the state data that needs to be replicated between registrars. Individual registrars will be responsible for scheduling destruction of their local registration objects. This can be accomplished using the expiration transmitted in the <tt>Registration</tt>.</p>
<h1><a name="Registrar-Interfaces"></a>Interfaces</h1>
<p>The registrar won't have much in the way of public interfaces since the data it makes available is pushed out to the other SIP services.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
/**
* The first string in the dictionary is an AoR
* The string sequence is a list of all contacts
* bound to the particular AoR.
*/
dictionary<string, StringSeq> ContactDict;
/**
* A RegistrarListener is updated when registration
* information changes. Typical RegistrarListeners will
* be SIP services that require up-to-date registration
* information.
*/
interface RegistrarListener
{
/**
* Alerts the listener that contacts have been added.
* The AoR may itself be new or an AoR with previous
* bindings may have new contacts added to it.
*/
void contactsAdded(ContactDict contacts);
/**
* Alerts the listener that contacts have been removed.
* There is no specific call for indicating that an AoR
* no longer has contacts associated with it. After this
* method has been called, listeners should take
* appropriate action if the AoR has no bound contacts.
*/
void contactsRemoved(ContactDict contacts);
};
interface Registrar
{
/**
* Add a new listener to the registrar.
* The return value is the map of all AoRs and their
* bindings.
*/
ContactDict addListener(RegistrarListener *listener);
/**
* Remove a listener.
*/
void removeListener(RegistrarLister *listener);
/**
* Get the mapping of all active registrations.
*/
RegistrationDict getRegistrations();
/**
* Get all registrations associated with a particular AoR
*/
RegistrationSeq getRegistrations(string aor);
};
]]></script>
</div></div>
<p>A <tt>RegistrationListener</tt> registers itself with the <tt>Registrar</tt> in order to receive updates about the <tt>Registrar</tt>'s bindings. A <tt>RegistrarListener</tt> is always provided with a <tt>ContactDict</tt> instead of a <tt>RegistrationDict</tt> because information besides the contact in a <tt>Registration</tt> is not useful outside the registrar service. If a component wishes to get a full <tt>Registration</tt> it may use a variant of <tt>getRegistrations</tt> to do so.</p>
<h1><a name="Registrar-Operation"></a>Operation</h1>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;">
<a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/TOP/Registrar">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/display/TOP/Registrar?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>