[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Sep 7 14:32:06 CDT 2010
branch "master" has been updated
via db8c0d391fc71d23653cc29558a21b6a264c7057 (commit)
via 05aa24c02f5bd6081cf74103c88159bbb08a572a (commit)
via f4b265add6ac8c2aa6925fe4aeef4555c976492a (commit)
via 5135a57d1cfb97a78549c7425e9e6353d90e92a2 (commit)
via 44338faab51702b8e5a473cfe748d8c4474e43c1 (commit)
via a0e415b79113430093df01a53ea9ae6317706e0c (commit)
from 58529157c6a31c4c708f28d84d76318bda4663e3 (commit)
Summary of changes:
src/PJSipSessionModule.cpp | 7 +++++
src/SipChannelServiceApp.cpp | 22 +++++++++++++++-
src/SipEndpoint.cpp | 59 +++++++++++++++++++++++++++++++++++++----
src/SipEndpoint.h | 17 ++++++++++-
4 files changed, 96 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit db8c0d391fc71d23653cc29558a21b6a264c7057
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 7 14:33:11 2010 -0500
Add usage of the call direction session option.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index e71f7dc..9506b07 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -130,6 +130,13 @@ static void handle_new_invite(pjsip_rx_data *rdata)
pjsip_inv_send_msg(inv_session, tdata);
return;
}
+ SipEndpointConfig &config = *(caller)->getConfig();
+ if (config.sessionConfig.callDirection != BOTH && config.sessionConfig.callDirection != INBOUND)
+ {
+ pjsip_inv_answer(inv_session, 403, NULL, NULL, &tdata);
+ pjsip_inv_send_msg(inv_session, tdata);
+ return;
+ }
(*caller)->setInviteSession(inv_session);
(*caller)->setDialog(dlg);
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index b9c306f..b0ce755 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -29,6 +29,12 @@ public:
pjsip_dialog *dialog;
SipEndpointConfig &config = mEndpoint->getConfig();
+ if (config.sessionConfig.callDirection != BOTH && config.sessionConfig.callDirection != OUTBOUND)
+ {
+ std::cerr << "[ERROR] Policy disallows placing outgoing calls to endpoint " << mEndpoint->getName() << std::endl;
+ return false;
+ }
+
char local[64];
pj_ansi_sprintf(local, "sip:%s", config.sessionConfig.sourceAddress.c_str());
local_uri = pj_str(local);
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 4ecd502..84fdcc8 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -256,6 +256,8 @@ public:
SipEndpointConfig &getConfig() { return mConfig; };
+ std::string getName() { return mName; };
+
private:
void requestRTPSessions(Hydra::Media::V1::FormatSeq& formats);
commit 05aa24c02f5bd6081cf74103c88159bbb08a572a
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 7 14:09:04 2010 -0500
Add session option configuration and usage of the source address.
When calls are placed, we use the configured source address as our local
URI. Your shoulders will likely hurt like crazy if you don't configure a
local address to use since we don't have a default method of doing things.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index a8bc227..b9c306f 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -27,13 +27,13 @@ public:
{
pj_str_t local_uri, remote_uri;
pjsip_dialog *dialog;
+ SipEndpointConfig &config = mEndpoint->getConfig();
char local[64];
- pj_ansi_sprintf(local, "sip:172.16.1.13:5060");
+ pj_ansi_sprintf(local, "sip:%s", config.sessionConfig.sourceAddress.c_str());
local_uri = pj_str(local);
char remote[64];
- SipEndpointConfig &config = mEndpoint->getConfig();
bool userDefined = config.transportConfig.user.size() != 0;
pj_ansi_sprintf(remote, "sip:%s%s%s",
userDefined ? config.transportConfig.user.c_str() : "",
@@ -398,7 +398,7 @@ void SipEndpoint::setConfiguration(Ice::PropertyDict props)
setTransportConfiguration(props);
//setAuthConfiguration(props);
//setRegistrationConfiguration(props);
- //setSessionConfiguration(props);
+ setSessionConfiguration(props);
//setMediaConfiguration(props);
//setSubscriptionConfiguration(props);
}
@@ -436,6 +436,33 @@ void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
}
}
+void SipEndpoint::setSessionConfiguration(Ice::PropertyDict props)
+{
+ std::string prefix("Sip.Endpoint");
+ prefix.append(mName);
+ prefix.append(".Session.");
+ Ice::PropertyDict::iterator direction = props.find(prefix + "CallDirection");
+ if (direction != props.end())
+ {
+ mConfig.sessionConfig.callDirection = SipEndpointConfig::stringToDirection(direction->second);
+ }
+ Ice::PropertyDict::iterator address = props.find(prefix + "SourceAddress");
+ if (address != props.end())
+ {
+ pj_str_t addr;
+ pj_sockaddr sockaddr;
+ pj_cstr(&addr, address->second.c_str());
+ if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &sockaddr) != PJ_SUCCESS)
+ {
+ std::cerr << "[ERROR] Bad address specifier in session configuration for SIP endpoint " << mName << std::endl;
+ }
+ else
+ {
+ mConfig.sessionConfig.sourceAddress = address->second;
+ }
+ }
+}
+
Direction SipEndpointConfig::stringToDirection(std::string directionString)
{
if (directionString == "Both")
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index f15a2e4..4ecd502 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -266,6 +266,12 @@ private:
void setTransportConfiguration(Ice::PropertyDict props);
+ void setSessionConfiguration(Ice::PropertyDict props);
+ void setRegistrationConfiguration(Ice::PropertyDict props);
+ void setAuthConfiguration(Ice::PropertyDict props);
+ void setMediaConfiguration(Ice::PropertyDict props);
+ void setSubscriptionConfiguration(Ice::PropertyDict props);
+
/**
* The name of the endpoint
*/
commit f4b265add6ac8c2aa6925fe4aeef4555c976492a
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 7 13:50:46 2010 -0500
Add parsing and usage of a "user" field when placing calls to Sip Endpoints.
The last basic thing left for configuration is the local IP address to place
in outbound URIs when placing calls to a particular endpoint.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 9f2ef8a..a8bc227 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -33,7 +33,12 @@ public:
local_uri = pj_str(local);
char remote[64];
- pj_ansi_sprintf(remote, "sip:%s", mEndpoint->getConfig().transportConfig.address.c_str());
+ SipEndpointConfig &config = mEndpoint->getConfig();
+ bool userDefined = config.transportConfig.user.size() != 0;
+ pj_ansi_sprintf(remote, "sip:%s%s%s",
+ userDefined ? config.transportConfig.user.c_str() : "",
+ userDefined ? "@" : "",
+ config.transportConfig.address.c_str());
remote_uri = pj_str(remote);
// Create a UAC dialog for the outgoing call
@@ -424,6 +429,11 @@ void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
{
mConfig.transportConfig.secureTransport = SipEndpointConfig::stringToDirection(direction->second);
}
+ Ice::PropertyDict::iterator user = props.find(prefix + "User");
+ if (user != props.end())
+ {
+ mConfig.transportConfig.user = user->second;
+ }
}
Direction SipEndpointConfig::stringToDirection(std::string directionString)
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 94ded7f..f15a2e4 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -66,6 +66,9 @@ class SipEndpointTransportConfig
public:
// The IP address and port of the endpoint.
std::string address;
+ // The user name to use in the request URI for
+ // this endpoint
+ std::string user;
// Security policy. In which call directions
// do we require TLS?
Direction secureTransport;
commit 5135a57d1cfb97a78549c7425e9e6353d90e92a2
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 7 13:27:53 2010 -0500
Use the configured address when calling out to a Sip Endpoint.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 2a156aa..9f2ef8a 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -32,9 +32,8 @@ public:
pj_ansi_sprintf(local, "sip:172.16.1.13:5060");
local_uri = pj_str(local);
- // TODO: Based on configuration populate the IP address for this remote URI
char remote[64];
- pj_ansi_sprintf(remote, "sip:%s:%d", "172.16.1.10", 5060);
+ pj_ansi_sprintf(remote, "sip:%s", mEndpoint->getConfig().transportConfig.address.c_str());
remote_uri = pj_str(remote);
// Create a UAC dialog for the outgoing call
@@ -409,11 +408,16 @@ void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
if (IpAddress != props.end())
{
pj_str_t addr;
+ pj_sockaddr sockaddr;
pj_cstr(&addr, IpAddress->second.c_str());
- if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &mConfig.transportConfig.address) != PJ_SUCCESS)
+ if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &sockaddr) != PJ_SUCCESS)
{
std::cerr << "[ERROR] Bad address specifier in transport configuration for SIP endpoint " << mName << std::endl;
}
+ else
+ {
+ mConfig.transportConfig.address = IpAddress->second;
+ }
}
Ice::PropertyDict::iterator direction = props.find(prefix + "SecureTransport");
if (direction != props.end())
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index f608a69..94ded7f 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -65,7 +65,7 @@ class SipEndpointTransportConfig
{
public:
// The IP address and port of the endpoint.
- pj_sockaddr address;
+ std::string address;
// Security policy. In which call directions
// do we require TLS?
Direction secureTransport;
@@ -251,6 +251,8 @@ public:
*/
Hydra::Session::V1::SessionEndpointPtr getSessionEndpoint() { return mSessionEndpoint; };
+ SipEndpointConfig &getConfig() { return mConfig; };
+
private:
void requestRTPSessions(Hydra::Media::V1::FormatSeq& formats);
commit 44338faab51702b8e5a473cfe748d8c4474e43c1
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 7 10:52:58 2010 -0500
Make module registration configurable.
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 48a0616..3badf65 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -145,6 +145,7 @@ private:
void registerWithRoutingService();
void deregisterFromRoutingService();
void configureEndpoints(boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr);
+ void registerPJSipModules();
bool mDone;
std::string mAppName;
@@ -388,6 +389,25 @@ void SipChannelServiceApp::configureEndpoints(boost::shared_ptr<SipEndpointFacto
}
}
+void SipChannelServiceApp::registerPJSipModules()
+{
+ Ice::PropertiesPtr props = communicator()->getProperties();
+ Ice::StringSeq moduleNames = props->getPropertyAsList("Sip.Modules");
+ for (Ice::StringSeq::iterator i = moduleNames.begin();
+ i != moduleNames.end();
+ ++i)
+ {
+ //We should probably delegate the responsibility of mapping
+ //module names to modules to the PJSIP session manager instead.
+ //Since there's only a single configurable module at the moment,
+ //we'll just do it here instead.
+ if (*i == "Session")
+ {
+ mPJSipManager->registerSessionModule();
+ }
+ }
+}
+
/**
* Create the primary functional objects of this component.
* @param appName Name of the application or component.
@@ -426,7 +446,7 @@ void SipChannelServiceApp::initialize(const std::string appName)
configureEndpoints(endpointFactoryPtr);
- mPJSipManager->registerSessionModule();
+ registerPJSipModules();
}
catch(...)
{
commit a0e415b79113430093df01a53ea9ae6317706e0c
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 7 10:03:21 2010 -0500
Make the string to direction function static.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 4779c9f..2a156aa 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -418,7 +418,7 @@ void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
Ice::PropertyDict::iterator direction = props.find(prefix + "SecureTransport");
if (direction != props.end())
{
- mConfig.transportConfig.secureTransport = mConfig.stringToDirection(direction->second);
+ mConfig.transportConfig.secureTransport = SipEndpointConfig::stringToDirection(direction->second);
}
}
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 3a678e8..f608a69 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -182,7 +182,7 @@ public:
/* Convert a specified direction string into its proper
* enumerated value.
*/
- Direction stringToDirection(std::string directionString);
+ static Direction stringToDirection(std::string directionString);
private:
};
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list