enables specifying contact in SIP registration

based on a patch by Andreas agranig at sipwise
sayer/1.4-spce2.6
Stefan Sayer 15 years ago committed by Stefan Sayer
parent 02230087ce
commit dfda667434

@ -42,6 +42,7 @@
#define CFG_PARAM_AUTH "auth_user"
#define CFG_PARAM_PASS "pwd"
#define CFG_PARAM_PROXY "proxy"
#define CFG_PARAM_CONTACT "contact"
#define MAX_ACCOUNTS 100
@ -72,6 +73,7 @@ int RegistrationAgentFactory::onLoad()
ri.auth_user = cfg.getParameter(CFG_PARAM_AUTH+idx_str,"");
ri.passwd = cfg.getParameter(CFG_PARAM_PASS+idx_str,"");
ri.proxy = cfg.getParameter(CFG_PARAM_PROXY+idx_str,"");
ri.contact = cfg.getParameter(CFG_PARAM_CONTACT+idx_str,"");
if (!ri.domain.length() || !ri.user.length()) {
// not including the passwd: might be IP based registration
@ -85,9 +87,9 @@ int RegistrationAgentFactory::onLoad()
ri.auth_user = ri.user;
dialer.add_reg(ri);
DBG("Adding registration account #%d (%s %s %s %s %s)\n", i,
DBG("Adding registration account #%d (%s %s %s %s %s %s)\n", i,
ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(),
ri.auth_user.c_str(), ri.proxy.c_str());
ri.auth_user.c_str(), ri.proxy.c_str(), ri.contact.c_str());
i ++;
idx_str = int2str(i);
@ -130,10 +132,11 @@ void RegThread::create_registration(RegInfo& ri) {
di_args.push(ri.domain.c_str());
di_args.push(ri.user.c_str());
di_args.push(ri.display_name.c_str()); // display name
di_args.push(ri.auth_user.c_str()); // auth_user
di_args.push(ri.passwd.c_str()); // pwd
di_args.push("reg_agent"); //sess_link
di_args.push(ri.proxy.c_str());
di_args.push(ri.auth_user.c_str()); // auth_user
di_args.push(ri.passwd.c_str()); // pwd
di_args.push("reg_agent"); //sess_link
di_args.push(ri.proxy.c_str());
di_args.push(ri.contact.c_str());
uac_auth_i->invoke("createRegistration", di_args, reg_handle);
if (reg_handle.size())

@ -41,6 +41,7 @@ struct RegInfo {
string auth_user;
string passwd;
string proxy;
string contact;
string handle;
};

@ -15,6 +15,8 @@
#auth_user=myuser
# optional (defaults to resolved by domain):
#proxy=sip.mydomain.net:5060
# optional (default to <user>@<publicip/localip>):
#contact=sip:myuser@10.0.0.2
#
# For multiple registrations add more entries
@ -26,6 +28,7 @@
#display_name1=xyz
#auth_user1=xyz
#proxy1=sip.iptel.org:5060
#contact1=sip:xyz@10.0.0.3
#domain2=iptel.org
#user2=xyz

@ -79,6 +79,10 @@ SIPRegistration::SIPRegistration(const string& handle,
// clear dlg.callid? ->reregister?
dlg.updateStatusFromLocalRequest(req);
dlg.cseq = 50;
if(!info.contact.empty()) {
dlg.contact_uri = SIP_HDR_COLSP(SIP_HDR_CONTACT) "<sip:";
dlg.contact_uri += info.contact + ">" + CRLF;
}
}
SIPRegistration::~SIPRegistration() {
@ -102,12 +106,16 @@ void SIPRegistration::doRegistration()
// set outbound proxy as next hop
if (!info.proxy.empty()) {
dlg.outbound_proxy = info.proxy;
} else if (!AmConfig::OutboundProxy.empty())
} else if (!AmConfig::OutboundProxy.empty()) {
dlg.outbound_proxy = AmConfig::OutboundProxy;
//else
// dlg.outbound_proxy = "";
}
if(!info.contact.empty()) {
dlg.contact_uri = SIP_HDR_COLSP(SIP_HDR_CONTACT) "<"
+ info.contact + ">" + CRLF;
}
if (dlg.sendRequest(req.method, "", "", "Expires: 1000\n") < 0)
if (dlg.sendRequest(req.method, "", "", "Expires: 3600\n") < 0)
ERROR("failed to send registration.\n");
// save TS
@ -131,6 +139,10 @@ void SIPRegistration::doUnregister()
dlg.outbound_proxy = AmConfig::OutboundProxy;
//else
// dlg.outbound_proxy = "";
if(!info.contact.empty()) {
dlg.contact_uri = SIP_HDR_COLSP(SIP_HDR_CONTACT) "<";
dlg.contact_uri += info.contact + ">" + CRLF;
}
if (dlg.sendRequest(req.method, "", "", "Expires: 0\n") < 0)
ERROR("failed to send deregistration.\n");
@ -592,13 +604,14 @@ string SIPRegistrarClient::createRegistration(const string& domain,
const string& auth_user,
const string& pwd,
const string& sess_link,
const string& proxy) {
const string& proxy,
const string& contact) {
string handle = AmSession::getNewId();
instance()->
postEvent(new SIPNewRegistrationEvent(SIPRegistrationInfo(domain, user,
name, auth_user, pwd,
proxy),
proxy, contact),
handle, sess_link));
return handle;
}
@ -639,6 +652,7 @@ void SIPRegistrarClient::listRegistrations(AmArg& res) {
r["auth_user"] = it->second->getInfo().auth_user;
r["proxy"] = it->second->getInfo().proxy;
r["event_sink"] = it->second->getEventSink();
r["contact"] = it->second->getInfo().contact;
res.push(r);
}
@ -650,9 +664,11 @@ void SIPRegistrarClient::invoke(const string& method, const AmArg& args,
AmArg& ret)
{
if(method == "createRegistration"){
string proxy;
string proxy, contact;
if (args.size() > 6)
proxy = args.get(6).asCStr();
if (args.size() > 7)
contact = args.get(7).asCStr();
ret.push(createRegistration(args.get(0).asCStr(),
args.get(1).asCStr(),
@ -660,7 +676,7 @@ void SIPRegistrarClient::invoke(const string& method, const AmArg& args,
args.get(3).asCStr(),
args.get(4).asCStr(),
args.get(5).asCStr(),
proxy
proxy, contact
).c_str());
}
else if(method == "removeRegistration"){

@ -49,15 +49,17 @@ struct SIPRegistrationInfo {
string auth_user;
string pwd;
string proxy;
string contact;
SIPRegistrationInfo(const string& domain,
const string& user,
const string& name,
const string& auth_user,
const string& pwd,
const string& proxy)
const string& proxy,
const string& contact)
: domain(domain),user(user),name(name),
auth_user(auth_user),pwd(pwd),proxy(proxy)
auth_user(auth_user),pwd(pwd),proxy(proxy),contact(contact)
{ }
};
@ -211,7 +213,8 @@ class SIPRegistrarClient : public AmThread,
const string& auth_user,
const string& pwd,
const string& sess_link,
const string& proxy);
const string& proxy,
const string& contact);
void removeRegistration(const string& handle);
bool hasRegistration(const string& handle);

@ -1,8 +1,9 @@
Readme for reg_agent module
This module uses the registrar_client to register the contact
sems@<local_ip>:<sip_port> at a SIP registrar. The accounts
(identities) are set in the config file.
This module uses the registrar_client to register SEMS
at a SIP registrar. The accounts (identities) are set in
the config file.
If the registration is not successful, it tries to
re-register.

@ -22,6 +22,9 @@ args:
CStr pwd : password
CStr sess_link : local tag of session or name of factory that receives
events about the status of the registration
optional:
CStr proxy : proxy to be used for registration
CStr contact : contact to register
returns: CStr handle : used to remove the registration or correlate events

Loading…
Cancel
Save