[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "srtp-support" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Jul 18 09:05:05 CDT 2011
branch "srtp-support" has been updated
via f843cde6bc101fa1b597dffe4989e270ffb11786 (commit)
via 6577d75e59c8b2f4241103f48fd114da433c8597 (commit)
via e528d7be81f34ac1789b74ad7415de949a1c19ed (commit)
via b61e242edd548a82eb5a492c7ffb16835746ceaa (commit)
via 32c65526dd56d0bc7e03148dfd407bfa40423fff (commit)
via ef373b282be4a218a92e9981fc0c3163c181603b (commit)
via 0a84ba53e4041c3d0afcab7caf954529b60b6f63 (commit)
via 768256f0d324d42905eb9f3832c054193cd750b2 (commit)
via 162d8a50bf6df93a6bc24d06e9042b5026c088ee (commit)
via 41e944174785ff3370b4e165d491e8ff92cc0827 (commit)
via f860396ac01e1581dfe5f56ca30434c8b01b4270 (commit)
via be2641c8edb8a41556c4a0d9c2d86fb023917792 (commit)
via 1ea02fa8ec59f386d62f04a0ef3c1adb77fd5319 (commit)
via 3fa68dd21a3f9a62ca80400e48832d0e6225a2ea (commit)
via fc2f64b78c4c57c4c3b8fea3233a9fd3f52147f6 (commit)
via 575abed0a58ba2e9f321b8ccc121a32356c7288d (commit)
via b0d2423c8b01c4432c7289f9648213e16406174a (commit)
via 1dda9776c5a1f55037ac61f5290593e25a5677cb (commit)
via 34797f06098f619838f094d9af7ec1a8c3ad4724 (commit)
via cfa23a3f19760c5266a9f4be0ad9302c977bfe8a (commit)
via a6bfcd47c9f662ac6dd4a2318d96579737a12837 (commit)
via 57993cd407779a00004dc426cb282f06bccb5bd5 (commit)
via 413750665895171f8eae4c8d86ff672b04a8f7cd (commit)
via b874caeeddf70e7b3911a4312494c8ae6de1ffd4 (commit)
via 89e5e5522e81f9f9be4351eb6aab5f346a35586d (commit)
via 448088a4f28ccdf90471cb60642d28bd4fdfd589 (commit)
via abbaa0220ce9faf1e97fd4845ee7f78076436193 (commit)
via 0ffdaa56376184435e2ebb6b59dac42fbde51ab9 (commit)
via 47ce4d4e87b887297289ff6511bde2feb807a476 (commit)
via e2736843dca94388a5ad562b7096a53451e2d037 (commit)
via 9394b46cf8c83c0cfa83e73a34886aeb9f63913b (commit)
via 66b54622b2edd8c6f41fb76950e81121813804e2 (commit)
via 66c548481a50dbbaaa4f886d41af64cc39a5bfa3 (commit)
via b694e978ae5146b198914f8e114fff6333a75662 (commit)
via 1f56ea5e07117170b407e17cc298ea9a79b60860 (commit)
via 706a6986e046909d0035038412d759ba1e6c199c (commit)
via 1624b232fe8cd35ab4a88ae0aa7d74498d98e3c9 (commit)
via 591d2f8183dbed4dce5734ae09e5c2d2cb2de8c3 (commit)
via ae5e868cf90a06e489748299eca32564f248d52b (commit)
via 1a6d54ba8e42b022e2dea6c696ab26ebac0345a2 (commit)
via c5ed036baf4b2eea39a2496e8c8267be96766dc2 (commit)
via 433163526c9c788f53fb52ae4b389e3c77f7dc31 (commit)
via fa87159c9237db447843c6523f1daa7da2a67607 (commit)
via 9ab8adb83f3038c03b8c1619bebcabbffc4e352e (commit)
via cb2abe96f218864eb0088c343b3a91ffa6e578e8 (commit)
via 480dca6e1d5a251dd2ab680f776b46f37a052660 (commit)
via 871d682ad8f89f934e68326fa6b3d861479321da (commit)
via 2e6f61b3697981bb4a1af0a4f2738ff786668269 (commit)
via f8ba9bd5baffb67df87d1726c8635bb7d5d63ff2 (commit)
via 49064db0f2c505427f826c7fc9608e39d3a2ffe2 (commit)
via 72fce78916b051f6d76a4e61de9fb5d26eec10de (commit)
via 51d7a0addacb9eae0fc88bea5b010a0559b4b887 (commit)
via df0ebe1c9b2b5eb5b99f1a5e4140dd13b3a14622 (commit)
via c5eff00eb9e4e64bac262fbc8f0ff7631c9b5cf8 (commit)
via 5aa5e56f84e645b9c5238215ef4fdeb0eba28f20 (commit)
via dd490ab030f402537f7edac3d1fcd443bc602e68 (commit)
from ce3452047ab8259656834884f5a3592378016360 (commit)
Summary of changes:
config/SipConfigurator.py | 30 +-
.../SipSessionManager/SipConfigurationIf.ice | 30 +
.../SipSessionManager/SipStateReplicationIf.ice | 17 +
src/CMakeLists.txt | 5 +
src/PJSipManager.cpp | 52 +-
src/PJSipManager.h | 19 +-
src/PJSipRegistrarModule.cpp | 831 ++++++++++++++++++++
src/PJSipRegistrarModule.h | 203 +++++
src/PJSipRegistrarModuleConstruction.cpp | 104 +++
src/SipConfiguration.cpp | 11 +
src/SipEndpoint.cpp | 15 +-
src/SipEndpoint.h | 2 +
src/SipEndpointFactory.cpp | 16 +-
src/SipEndpointFactory.h | 2 +
src/SipRegistrarListener.cpp | 113 +++
src/SipRegistrarListener.h | 46 ++
src/SipSessionManagerApp.cpp | 28 +-
src/SipSessionManagerEndpointLocator.cpp | 14 +-
src/SipStateReplicator.h | 1 +
src/SipStateReplicatorListener.cpp | 172 ++++
20 files changed, 1667 insertions(+), 44 deletions(-)
create mode 100644 src/PJSipRegistrarModule.cpp
create mode 100644 src/PJSipRegistrarModule.h
create mode 100644 src/PJSipRegistrarModuleConstruction.cpp
create mode 100644 src/SipRegistrarListener.cpp
create mode 100644 src/SipRegistrarListener.h
- Log -----------------------------------------------------------------
commit f843cde6bc101fa1b597dffe4989e270ffb11786
Merge: ce34520 6577d75
Author: Brent Eagles <beagles at digium.com>
Date: Mon Jul 18 11:34:25 2011 -0230
Merge 'origin/master' into srtp-support, resolving conflicts in:
src/CMakeLists.txt
src/PJSipManager.cpp
src/PJSipManager.h
src/SipEndpointFactory.cpp
diff --cc config/SipConfigurator.py
index 07d87d6,1d34378..2d61c7a
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@@ -19,13 -19,12 +19,13 @@@
# Sip configurator
# Bring in the common configuration infrastructure
--import Ice, Configurator, sys, os
++import Ice, Configurator, sys, os, traceback
# Load our component specific configuration definitions
-Ice.loadSlice("-I" + os.environ["ASTSCF_HOME"] + " -I" + Ice.getSliceDir() + " --all ../slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice")
+Ice.loadSlice("--underscore -I" + os.environ["ASTSCF_HOME"] + " -I" + Ice.getSliceDir() + " --all ../slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice")
import AsteriskSCF.Configuration.SipSessionManager.V1
+
# Add our own visitor implementations for the sections we support
class SipSectionVisitors(Configurator.SectionVisitors):
def visit_general(self, config, section):
@@@ -119,22 -97,6 +119,33 @@@
mapper.map('targethost', item, 'host', 'targetaddress', config.get, None)
mapper.map('targetport', item, 'port', 'targetaddress', config.getint, 5060)
+ item = AsteriskSCF.Configuration.SipSessionManager.V1.SipSignalingNATItem()
+ mapper.map('enablestun', item, 'stun', 'enableSTUN', config.get, None)
+
+ item = AsteriskSCF.Configuration.SipSessionManager.V1.SipMediaNATItem()
+ mapper.map('enablertpoverice', item, 'enableICE', 'enableRTPICE', config.get, None)
+ mapper.map('enableturn', item, 'enableTURN', 'enableRTPICE', config.get, None)
+
+ item = AsteriskSCF.Configuration.SipSessionManager.V1.SRTPCryptoItem()
-
-
++
++ class CryptoKeyHandler:
++ def __init__(self, config, keyItem):
++ self.config = config
++ self.item = keyItem
++
++ def getSuite(self, section, item):
++ self.item.suite = self.config.get(section, item)
++
++ def getKey(self, section, item):
++ self.item.cryptoKey = self.config.get(section, item)
++
+ item.cryptoKeys = [ AsteriskSCF.Configuration.SipSessionManager.V1.SRTPCryptoKey() ]
- mapper.map('enableauth', item, 'enableAuthentication', 'srtpCryptoSettings', config.get, True)
- mapper.map('enableencryption', item, 'enableEncryption', 'srtpCrytpoSettings', config.get, True)
- mapper.map('ciphersuite', item.cryptoKeys[0], 'suite', 'srtpCryptoSettings', config.get, None)
- mapper.map('cryptokey', item.cryptoKeys[0], 'cryptoKey', 'srtpCryptoSettings', config.get, None)
++ mapper.map('enableauth', item, 'enableAuthentication', 'srtpCryptoSettings', config.get, None)
++ mapper.map('enableencryption', item, 'enableEncryption', 'srtpCryptoSettings', config.get, None)
++ handler = CryptoKeyHandler(config, item.cryptoKeys[0])
++ mapper.map('ciphersuite', item, 'suite', 'srtpCryptoSettings', handler.getSuite, None)
++ mapper.map('cryptokey', item, 'cryptoKey', 'srtpCryptoSettings', handler.getKey, None)
+
class AllowableCallDirectionTransformer():
def __init__(self, config):
self.config = config
@@@ -195,6 -157,6 +206,8 @@@
mapper.execute(group, section, option)
mapper.finish(group)
++ self.groups.append(group)
++
try:
formats = config.get(section, 'formats')
configuredFormats = formats.split(',')
@@@ -215,10 -177,10 +228,9 @@@
group.configurationItems[format] = item
except:
++ traceback.print_exc()
print 'No configured formats for endpoint ' + section
-- self.groups.append(group)
--
def visit_unsupported(self, config, section):
if config.get(section, 'type') == 'transport-udp':
self.visit_transport_udp(config, section)
diff --cc slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice
index 0a1d091,f37030d..c0c85fb
--- a/slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice
+++ b/slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice
@@@ -32,427 -32,407 +32,457 @@@ module SipSessionManage
["suppress"]
module V1
{
- /**
- * Service locator category for finding the configuration service
- */
- const string ConfigurationDiscoveryCategory = "SipConfiguration";
-
- /**
- * Service locator parameters class for discovering the configuration service
- */
- unsliceable class SipConfigurationParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
- {
- /**
- * Unique name for the configuration service
- */
- string name;
- };
-
- /**
- * Local visitor class for visiting SIP configuration groups
- */
- local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
- {
- };
-
- /**
- * Generic SIP configuration group
- */
- ["visitor:SipConfigurationGroupVisitor"] class SipConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
- {
- };
-
- /**
- * General SIP configuration group that contains general items related to the SIP component as a whole
- */
- class SipGeneralGroup extends SipConfigurationGroup
- {
- };
-
- /**
- * Local visitor class for visiting SIP configuration items
- */
- local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
- {
- };
- /**
- * Generic SIP configuration item
- */
- ["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
- {
- };
-
- /**
- * SIP Endpoint group, used to configure an endpoint
- */
- class SipEndpointGroup extends SipConfigurationGroup
- {
- /**
- * Name of the endpoint being configured
- */
- string name;
- };
-
- /**
- * SIP Domain group, used to configure a specific domain
- */
- class SipDomainGroup extends SipConfigurationGroup
- {
- /**
- * Name of the domain being configured
- */
- string domain;
- };
-
- /**
- * Domain item for bindings
- */
- class SipBindingsItem extends SipConfigurationItem
- {
- /**
- * Addresses the domain is reachable over
- */
- Ice::StringSeq bindings;
- };
+/**
+ * Service locator category for finding the configuration service
+ */
+const string ConfigurationDiscoveryCategory = "SipConfiguration";
- /**
- * Generic SIP transport group that others derive from, primarily created since each one has
- * the requirement of a name
- */
- class SipTransportGroup extends SipConfigurationGroup
- {
- /**
- * Name of the specific transport. Since each one may have multiple transports this differentiates
- * them.
- */
- string name;
- };
+/**
+ * Service locator parameters class for discovering the configuration service
+ */
+unsliceable class SipConfigurationParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+{
+ /**
+ * Unique name for the configuration service
+ */
+ string name;
+};
+
+/**
+ * Local visitor class for visiting SIP configuration groups
+ */
+local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
+{
+};
- /**
- * Host information configuration item
- */
- class SipHostItem extends SipConfigurationItem
- {
- /**
- * String containing the IP address or string address
- */
- string host;
-
- /**
- * Port number
- */
- int port;
- };
+/**
+ * Generic SIP configuration group
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
+{
+};
- /**
- * Source transport address configuration item
- */
- class SipSourceTransportAddressItem extends SipHostItem
- {
- };
+/**
+ * General SIP configuration group that contains general items related to the SIP component as a whole
+ */
+class SipGeneralGroup extends SipConfigurationGroup
+{
+};
- /**
- * Target destination address configuration item
- */
- class SipTargetDestinationAddressItem extends SipHostItem
- {
- };
+/**
+ * Local visitor class for visiting SIP configuration items
+ */
+local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
+{
+};
- /**
- * Crypto certificate configuration item
- */
- class SipCryptoCertificateItem extends SipConfigurationItem
- {
- /**
- * Full location of certificate authority file
- */
- string certificateAuthority;
-
- /**
- * Full location of certificate file
- */
- string certificate;
-
- /**
- * Full location of private key file
- */
- string privateKey;
-
- /**
- * Password to open private key file
- */
- string privateKeyPassword;
- };
+/**
+ * Generic SIP configuration item
+ */
+["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+{
+};
- /**
- * Crypto requirement configuration item
- */
- class SipCryptoRequirementsItem extends SipConfigurationItem
- {
- /**
- * Require verification of server certificate
- */
- bool requireVerifiedServer = false;
-
- /**
- * Require verification of client certificate
- */
- bool requireVerifiedClient = false;
-
- /**
- * Require client certificate be present
- */
- bool requireClientCertificate = false;
- };
+/**
+ * SIP Endpoint group, used to configure an endpoint
+ */
+class SipEndpointGroup extends SipConfigurationGroup
+{
+ /**
+ * Name of the endpoint being configured
+ */
+ string name;
+};
+
+/**
+ * SIP Domain group, used to configure a specific domain
+ */
+class SipDomainGroup extends SipConfigurationGroup
+{
+ /**
+ * Name of the domain being configured
+ */
+ string domain;
+};
+
+/**
+ * Domain item for bindings
+ */
+class SipBindingsItem extends SipConfigurationItem
+{
+ /**
+ * Addresses the domain is reachable over
+ */
+ Ice::StringSeq bindings;
+};
+
+/**
+ * Generic SIP transport group that others derive from, primarily created since each one has
+ * the requirement of a name
+ */
+class SipTransportGroup extends SipConfigurationGroup
+{
+ /**
+ * Name of the specific transport. Since each one may have multiple transports this differentiates
+ * them.
+ */
+ string name;
+};
+
+/**
+ * Host information configuration item
+ */
+class SipHostItem extends SipConfigurationItem
+{
+ /**
+ * String containing the IP address or string address
+ */
+ string host;
+
+ /**
+ * Port number
+ */
+ int port;
+};
+
+/**
+ * Source transport address configuration item
+ */
+class SipSourceTransportAddressItem extends SipHostItem
+{
+};
- /**
- * TLS protocol methods
- */
- enum TLSProtocolMethod
- {
- PROTOCOLMETHODUNSPECIFIED,
- PROTOCOLMETHODTLSV1,
- PROTOCOLMETHODSSLV2,
- PROTOCOLMETHODSSLV3,
- PROTOCOLMETHODSSLV23,
- };
+/**
+ * Target destination address configuration item
+ */
+class SipTargetDestinationAddressItem extends SipHostItem
+{
+};
- /**
- * General crypto configuration item
- */
- class SipCryptoItem extends SipConfigurationItem
- {
- /**
- * TLS protocol method to use
- */
- TLSProtocolMethod protocolMethod = PROTOCOLMETHODUNSPECIFIED;
-
- /**
- * Supported ciphers (OpenSSL format)
- */
- string supportedCiphers;
-
- /**
- * Server name
- */
- string serverName;
-
- /**
- * TLS negotiation timeout in seconds
- */
- int timeout = 0;
- };
+/**
+ * Crypto certificate configuration item
+ */
+class SipCryptoCertificateItem extends SipConfigurationItem
+{
+ /**
+ * Full location of certificate authority file
+ */
+ string certificateAuthority;
+
+ /**
+ * Full location of certificate file
+ */
+ string certificate;
+
+ /**
+ * Full location of private key file
+ */
+ string privateKey;
+
+ /**
+ * Password to open private key file
+ */
+ string privateKeyPassword;
+};
+
+/**
+ * Crypto requirement configuration item
+ */
+class SipCryptoRequirementsItem extends SipConfigurationItem
+{
+ /**
+ * Require verification of server certificate
+ */
+ bool requireVerifiedServer = false;
+
+ /**
+ * Require verification of client certificate
+ */
+ bool requireVerifiedClient = false;
+
+ /**
+ * Require client certificate be present
+ */
+ bool requireClientCertificate = false;
+};
+
+/**
+ * TLS protocol methods
+ */
+enum TLSProtocolMethod
+{
+ PROTOCOLMETHODUNSPECIFIED,
+ PROTOCOLMETHODTLSV1,
+ PROTOCOLMETHODSSLV2,
+ PROTOCOLMETHODSSLV3,
+ PROTOCOLMETHODSSLV23,
+};
+
+/**
+ * General crypto configuration item
+ */
+class SipCryptoItem extends SipConfigurationItem
+{
+ /**
+ * TLS protocol method to use
+ */
+ TLSProtocolMethod protocolMethod = PROTOCOLMETHODUNSPECIFIED;
+
+ /**
+ * Supported ciphers (OpenSSL format)
+ */
+ string supportedCiphers;
+
+ /**
+ * Server name
+ */
+ string serverName;
+
+ /**
+ * TLS negotiation timeout in seconds
+ */
+ int timeout = 0;
+};
+
+/**
+ * SRTP Crypto Key information.
+ */
+class SRTPCryptoKey
+{
+ /**
+ * The cipher suite name.
+ */
+ string suite;
- /**
- * Routing service configuration item
- */
- class SipRoutingItem extends SipConfigurationItem
- {
- /**
- * Name of the routing service to use
- */
- string routingServiceName;
- };
+ /**
+ * The key information for the suite.
+ */
+ string cryptoKey;
+};
- /**
- * RTP Media service configuration item
- */
- class SipRTPMediaServiceItem extends SipConfigurationItem
- {
- /**
- * Name of the RTP media service to use
- */
- string mediaServiceName;
-
- /**
- * Whether to choose an IPv6 RTP media service or not
- */
- bool requireIPv6 = false;
- };
+sequence<SRTPCryptoKey> SRTPCryptoKeySeq;
- /**
- * Signaling NAT configuration item
- */
- class SipSignalingNATItem extends SipConfigurationItem
- {
- /**
- * Boolean for whether STUN is enabled
- */
- bool stun;
- };
+/**
+ * SRTP crypto configuration.
+ */
+class SRTPCryptoItem extends SipConfigurationItem
+{
- /**
- * Media NAT configuration item
- */
- class SipMediaNATItem extends SipConfigurationItem
- {
- /**
- * Boolean for whether symmetric RTP is enabled
- */
- bool symmetricRTP;
-
- /**
- * Boolean for whether STUN is enabled
- */
- bool stun;
-
- /**
- * Boolean for whether ICE is enabled
- */
- bool interactiveconnectivityestablishment;
-
- /**
- * Boolean for whether TURN is enabled
- */
- bool turn;
- };
+ /**
+ * Most of the time the following values will be false. They can be overriden to be true however.
+ */
+ bool enableAuthentication;
+ bool enableEncryption;
- /**
- * Access control lists item
- */
- class SipACLItem extends SipConfigurationItem
- {
- /**
- * Name of this ACL item. A user may want to have multiple.
- */
- string name;
-
- /**
- * Ranges of allowed hosts
- */
- Ice::StringSeq allowRanges;
-
- /**
- * Specific allowed hosts
- */
- Ice::StringSeq allowHosts;
-
- /**
- * Ranges of denied hosts
- */
- Ice::StringSeq denyRanges;
-
- /**
- * Specific denied hosts
- */
- Ice::StringSeq denyHosts;
- };
+ /**
+ * The suites and keys supported by this endpoint.
+ */
+ SRTPCryptoKeySeq cryptoKeys;
+};
+/**
+ * Routing service configuration item
+ */
+class SipRoutingItem extends SipConfigurationItem
+{
+ /**
+ * Name of the routing service to use
+ */
+ string routingServiceName;
+};
+
+/**
+ * RTP Media service configuration item
+ */
+class SipRTPMediaServiceItem extends SipConfigurationItem
+{
+ /**
+ * Name of the RTP media service to use
+ */
+ string mediaServiceName;
+
+ /**
+ * Whether to choose an IPv6 RTP media service or not
+ */
+ bool requireIPv6 = false;
+};
+
+/**
+ * Signaling NAT configuration item
+ */
+class SipSignalingNATItem extends SipConfigurationItem
+{
+ /**
+ * Boolean for whether STUN is enabled
+ */
+ bool stun;
+};
+
+/**
+ * STUN server to be used by Sip signalling.
+ */
+class SipSignalingSTUNHostItem extends SipConfigurationItem
+{
+ /**
+ * Address for the STUN server.
+ **/
+ string address;
+
+ /**
+ * Port for the STUN host.
+ */
+ int port;
+};
+
+/**
+ * Media NAT configuration item
+ */
+class SipMediaNATItem extends SipConfigurationItem
+{
+ /**
+ * Boolean for whether ICE is enabled
+ */
+ bool enableICE;
+
+ /**
+ * Boolean for whether TURN is enabled
+ */
+ bool enableTURN;
+};
+
+/**
+ * Access control lists item
+ */
+class SipACLItem extends SipConfigurationItem
+{
+ /**
+ * Name of this ACL item. A user may want to have multiple.
+ */
+ string name;
+
+ /**
+ * Ranges of allowed hosts
+ */
+ Ice::StringSeq allowRanges;
+
+ /**
+ * Specific allowed hosts
+ */
+ Ice::StringSeq allowHosts;
+
+ /**
+ * Ranges of denied hosts
+ */
+ Ice::StringSeq denyRanges;
+
+ /**
+ * Specific denied hosts
+ */
+ Ice::StringSeq denyHosts;
+};
+
+/**
+ * Allowable call directions
+ */
+enum SipAllowableCallDirection
+{
+ Disabled,
+ Inbound,
+ Outbound,
+ Both,
+};
+
+/**
+ * Allowable call direction item
+ */
+class SipAllowableCallDirectionItem extends SipConfigurationItem
+{
+ /**
+ * What direction is permitted for this endpoint
+ */
+ SipAllowableCallDirection callDirection = Both;
+};
+
+/**
++* Allowable media format item
++*/
++class SipMediaFormatItem extends SipConfigurationItem
++{
+ /**
- * Allowable call directions
++ * Name of the media format
+ */
- enum SipAllowableCallDirection
- {
- Disabled,
- Inbound,
- Outbound,
- Both,
- };
++ string name;
+
+ /**
- * Allowable call direction item
++ * Sample rate for frames
++ *
++ * This is specified in Hz and has a default value of 8000.
+ */
- class SipAllowableCallDirectionItem extends SipConfigurationItem
- {
- /**
- * What direction is permitted for this endpoint
- */
- SipAllowableCallDirection callDirection = Both;
- };
++ int sampleRate = 8000;
+
+ /**
- * Allowable media format item
++ * Amount of audio in frames
++ *
++ * This is specified in
+ */
- class SipMediaFormatItem extends SipConfigurationItem
- {
- /**
- * Name of the media format
- */
- string name;
-
- /**
- * Sample rate for frames
- *
- * This is specified in Hz and has a default value of 8000.
- */
- int sampleRate = 8000;
-
- /**
- * Amount of audio in frames
- *
- * This is specified in
- */
- int frameSize;
-
- /**
- * Any format specific parameters
- */
- Ice::StringSeq formatSpecific;
- };
++ int frameSize;
+
+ /**
- * User agent presentation configuration item
++ * Any format specific parameters
+ */
- class SipUserAgentItem extends SipConfigurationItem
- {
- /**
- * String that our user agent should appear as
- */
- string userAgent;
- };
++ Ice::StringSeq formatSpecific;
++};
+
- /**
- * Transport information configuration item
- */
- class SipEndpointTransportItem extends SipConfigurationItem
- {
- /**
- * What directions to require secure transport in
- */
- SipAllowableCallDirection secureTransport = Disabled;
- };
++/**
+ * User agent presentation configuration item
+ */
+class SipUserAgentItem extends SipConfigurationItem
+{
+ /**
+ * String that our user agent should appear as
+ */
+ string userAgent;
+};
+
+/**
+ * Transport information configuration item
+ */
+class SipEndpointTransportItem extends SipConfigurationItem
+{
+ /**
+ * What directions to require secure transport in
+ */
+ SipAllowableCallDirection secureTransport = Disabled;
+};
+
+/**
+ * Group of configuration items related to a UDP transport
+ */
+class SipUDPTransportGroup extends SipTransportGroup
+{
+};
- /**
- * Group of configuration items related to a UDP transport
- */
- class SipUDPTransportGroup extends SipTransportGroup
- {
- };
+/**
+ * Group of configuration items related to a TCP transport
+ */
+class SipTCPTransportGroup extends SipTransportGroup
+{
+};
- /**
- * Group of configuration items related to a TCP transport
- */
- class SipTCPTransportGroup extends SipTransportGroup
- {
- };
+/**
+ * Group of configuration items related to a TLS transport
+ */
+class SipTLSTransportGroup extends SipTransportGroup
+{
+};
- /**
- * Group of configuration items related to a TLS transport
- */
- class SipTLSTransportGroup extends SipTransportGroup
- {
- };
+/**
+ * Group of configuration items related to a STUN enabled transport
+ */
+class SipSTUNTransportGroup extends SipTransportGroup
+{
+};
}; /* module V1 */
diff --cc src/CMakeLists.txt
index 3086153,b4570ac..88354c0
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -33,24 -36,8 +36,26 @@@ astscf_component_add_files(SipSessionMa
astscf_component_add_files(SipSessionManager SipConfiguration.h)
astscf_component_add_files(SipSessionManager SipStateReplicatorListener.cpp)
astscf_component_add_files(SipSessionManager SipStateReplicator.h)
+astscf_component_add_files(SipSessionManager Transports.cpp)
+astscf_component_add_files(SipSessionManager Transports.h)
+astscf_component_add_files(SipSessionManager UDPTransport.cpp)
+astscf_component_add_files(SipSessionManager UDPTransport.h)
+astscf_component_add_files(SipSessionManager TCPTransport.cpp)
+astscf_component_add_files(SipSessionManager TCPTransport.h)
+astscf_component_add_files(SipSessionManager TLSTransport.cpp)
+astscf_component_add_files(SipSessionManager TLSTransport.h)
+astscf_component_add_files(SipSessionManager PJUtil.h)
+astscf_component_add_files(SipSessionManager DebugUtil.h)
+astscf_component_add_files(SipSessionManager SipModule.h)
+astscf_component_add_files(SipSessionManager STUNModule.cpp)
+astscf_component_add_files(SipSessionManager STUNModule.h)
+astscf_component_add_files(SipSessionManager STUNTransport.cpp)
+astscf_component_add_files(SipSessionManager STUNTransport.h)
+astscf_component_add_files(SipSessionManager STUNTransportConfig.cpp)
+astscf_component_add_files(SipSessionManager STUNTransportConfig.h)
+astscf_component_add_files(SipSessionManager NATOptions.h)
+ astscf_component_add_files(SipSessionManager SipRegistrarListener.cpp)
+ astscf_component_add_files(SipSessionManager SipRegistrarListener.h)
astscf_component_add_slices(SipSessionManager PROJECT SipIf.ice)
astscf_component_add_slices(SipSessionManager PROJECT AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice)
astscf_component_add_slices(SipSessionManager PROJECT AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice)
diff --cc src/PJSipManager.cpp
index d0c9c88,87f0e2d..ec7d202
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@@ -34,7 -23,8 +34,8 @@@ using namespace std
namespace
{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
+Logger logger = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
+ const std::string RegistrarId("SipRegistrar");
}
@@@ -88,11 -79,6 +86,7 @@@ PJSipManager::~PJSipManager(
}
}
- pjsip_endpoint* PJSipManager::getEndpoint()
- {
- return mEndpoint;
- }
+
void PJSipManager::registerSessionModule(const boost::shared_ptr<SipEndpointFactory>& endpointFactoryPtr,
const AsteriskSCF::Discovery::SmartProxy<
AsteriskSCF::SessionCommunications::V1::SessionRouterPrx>& sessionRouter,
@@@ -110,170 -96,144 +104,192 @@@ void PJSipManager::registerLoggingModul
mLoggingModule = new PJSipLoggingModule(mEndpoint);
}
+ void PJSipManager::registerRegistrarModule(
+ const RegistrarListenerPrx& defaultListener,
+ const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Replication::SipSessionManager::V1::SipStateReplicatorPrx>& stateReplicator,
+ Ice::ObjectAdapterPtr& adapter)
+ {
+ mRegistrarModule = new PJSipRegistrarModule(mEndpoint, defaultListener, stateReplicator);
+ //The registrar implements a published interface, so we need to add it to
+ //the object adapter
+ adapter->add(mRegistrarModule->getRegistrar(),
+ adapter->getCommunicator()->stringToIdentity(RegistrarId));
+ }
+
+ pjsip_endpoint* PJSipManager::getEndpoint()
+ {
+ return mEndpoint;
+ }
+
+ PJSipSessionModulePtr PJSipManager::getSessionModule()
+ {
+ return mSessionModule;
+ }
+
+ PJSipLoggingModulePtr PJSipManager::getLoggingModule()
+ {
+ return mLoggingModule;
+ }
+
+ PJSipRegistrarModulePtr PJSipManager::getRegistrarModule()
+ {
+ return mRegistrarModule;
+ }
+
-bool PJSipManager::setTransports(pjsip_endpoint *endpoint, const Ice::PropertiesPtr& props)
+void PJSipManager::addTransport(const string& id, const TransportPtr& transport)
{
- //XXX We'll also want to allow for TCP and TLS-specific
- //addresses to be specified.
- pj_sockaddr udpAddr;
- pj_status_t status;
- std::string udpBindAddr = props->getProperty("Sip.Transport.UdpBindAddr");
-
- if (udpBindAddr.empty())
+ //
+ // Reap destroyed transports and add the new one.
+ //
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ map<string, TransportPtr>::iterator i = mTransports.begin();
+ while (i != mTransports.end())
{
- return true;
+ if (i->second->isDestroyed())
+ {
+ mTransports.erase(i);
+ }
+ else
+ {
+ ++i;
+ }
}
+ mTransports.insert(make_pair(id, transport));
+}
- pj_str_t udpString;
- pj_cstr(&udpString, udpBindAddr.c_str());
- //UNSPEC family means "you figure out the address family, pjlib!"
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
- if (udpAddr.addr.sa_family == pj_AF_INET())
+TransportPtr PJSipManager::getTransport(const string& id)
+{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ map<string, TransportPtr>::iterator i = mTransports.begin();
+ while (i != mTransports.end())
{
- //XXX The fourth parameter should probably be controlled through
- //configuration. PJSIP reference says it should be the number of
- //processors on the machine.
- //
- status = pjsip_udp_transport_start(endpoint, &udpAddr.ipv4, NULL, 2, &mUdpTransport);
- if (status != PJ_SUCCESS)
+ if (i->second->isDestroyed())
{
- lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
+ mTransports.erase(i);
}
- }
- else if (udpAddr.addr.sa_family == pj_AF_INET6())
- {
- status = pjsip_udp_transport_start6(endpoint, &udpAddr.ipv6, NULL, 2, &mUdpTransport);
- if (status != PJ_SUCCESS)
+ else
{
- lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
+ ++i;
}
}
- //XXX Note that TCP and TLS stuff should be done here. Also note that
- //currently PJSIP does not have functions for starting IPv6 TCP or
- //TLS transports, so we'll have to modify the code to allow for it.
- return true;
+ i = mTransports.find(id);
+ if (i != mTransports.end())
+ {
+ return i->second;
+ }
+ return TransportPtr();
}
-pjsip_transport *PJSipManager::createUDPTransport(std::string address, int port)
+void PJSipManager::addModule(const string& moduleName, const SipModulePtr& module)
{
- pj_sockaddr udpAddr;
- pj_status_t status;
- pj_str_t udpString;
- pj_cstr(&udpString, address.c_str());
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
- pj_sockaddr_set_port(&udpAddr, boost::lexical_cast<pj_uint16_t>(port));
-
- pjsip_transport *udpTransport = NULL;
- if (udpAddr.addr.sa_family == pj_AF_INET())
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ SipModuleMap::iterator i = mModules.find(moduleName);
+ if (i != mModules.end())
{
- status = pjsip_udp_transport_start(mEndpoint, &udpAddr.ipv4, NULL, 2, &udpTransport);
- }
- else if (udpAddr.addr.sa_family == pj_AF_INET6())
- {
- status = pjsip_udp_transport_start6(mEndpoint, &udpAddr.ipv6, NULL, 2, &udpTransport);
+ mModules.erase(i);
}
+ mModules.insert(make_pair(moduleName, module));
+}
- if (status != PJ_SUCCESS)
+SipModulePtr PJSipManager::getModule(const string& moduleName)
+{
+ boost::shared_lock<boost::shared_mutex> lock(mLock);
+ SipModuleMap::const_iterator i = mModules.find(moduleName);
+ if (i != mModules.end())
{
- lg(Error) << "Failed to create UDP transport.";
+ return i->second;
}
+ return SipModulePtr();
+}
- return udpTransport;
+void PJSipManager::handleEvents()
+{
+ onHandleEvents(mModules);
+ const pj_time_val delay = {0, 10};
+ pjsip_endpt_handle_events(mEndpoint, &delay);
}
- PJSipSessionModulePtr PJSipManager::getSessionModule()
- {
- return mSessionModule;
- }
-
- PJSipLoggingModulePtr PJSipManager::getLoggingModule()
- {
- return mLoggingModule;
- }
-
-pjsip_tpfactory *PJSipManager::createTCPTransport(std::string address, int port)
+pj_caching_pool* PJSipManager::getCachingPool()
{
- pj_sockaddr tcpAddr;
- pj_str_t tcpString;
- pj_cstr(&tcpString, address.c_str());
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &tcpString, &tcpAddr);
- pj_sockaddr_set_port(&tcpAddr, boost::lexical_cast<pj_uint16_t>(port));
+ return &mCachingPool;
+}
- pjsip_tpfactory *tcpTransport = NULL;
+pj_pool_t* PJSipManager::getMemoryPool()
+{
+ return mMemoryPool;
+}
- if (pjsip_tcp_transport_start(mEndpoint, &tcpAddr, 2, &tcpTransport) != PJ_SUCCESS)
+void PJSipManager::initializeDefaultTransports(const Ice::PropertiesPtr& properties)
+{
+ string bindAddress = properties->getPropertyWithDefault("Sip.Transport.UdpBindAddr", "0.0.0.0:5060");
+ string addressPart;
+ int portPart = 5060;
+ size_t colon = bindAddress.rfind(':');
+ if (colon != string::npos)
{
- lg(Error) << "Failed to create TCP transport.";
+ addressPart = bindAddress.substr(0, colon);
+ portPart = boost::lexical_cast<int>(bindAddress.substr(colon+1));
+ }
+ else
+ {
+ addressPart = bindAddress;
+ }
+ //
+ // It is entirely possible that the default transport is instantiable. We'll eat this error for
+ // now, but it might be better to abort out.
+ //
+ TransportPtr defaultUDPTransport = createUDPTransport(shared_from_this(), addressPart, portPart);
+ if (defaultUDPTransport)
+ {
+ mTransports.insert(make_pair(defaultUDPTransport->id(), defaultUDPTransport));
+ }
+ else
+ {
+ logger(Error) << "Unable to create default transport";
}
-
- return tcpTransport;
}
-pjsip_tpfactory *PJSipManager::createTLSTransport(std::string address, int port, pjsip_tls_setting *)
+PJSipManager::PJSipManager() :
+ mEndpoint(0),
+ mSessionModule(0),
+ mLoggingModule(0),
+ mPjThread(0),
+ mMemoryPool(0)
{
- pj_sockaddr tlsAddr;
- pj_str_t tlsString;
- pj_cstr(&tlsString, address.c_str());
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &tlsString, &tlsAddr);
- pj_sockaddr_set_port(&tlsAddr, boost::lexical_cast<pj_uint16_t>(port));
-
- pjsip_tpfactory *tlsTransport = NULL;
+ memset(&mCachingPool, 0, sizeof(mCachingPool));
-#if PJSIP_HAS_TLS_TRANSPORT
- if (pjsip_tls_transport_start(mEndpoint, tlsSettings, &tlsAddr, NULL, 2, &tlsTransport) != PJ_SUCCESS)
-#endif
+ pj_status_t status = pj_init();
+ if (fail(status))
{
- lg(Error) << "Failed to create TLS transport.";
+ const char* message = "Failed to Initialize PJSIP";
+ logger(Error) << message;
+ throw InternalInitializationException(message);
}
+ // The third parameter is just copied from
+ // example code from PJLIB. This can be adjusted
+ // if necessary.
+ pj_caching_pool_init(&mCachingPool, NULL, 1024 * 1024);
+ pjsip_endpt_create(&mCachingPool.factory, "SIP", &mEndpoint);
- return tlsTransport;
+ //
+ // Careful! This was after the setTransports call, so reordering it might cause issues.
+ //
+ mMemoryPool = pj_pool_create(&mCachingPool.factory, "SIP", 1024, 1024, NULL);
+ if (!mMemoryPool)
+ {
+ const char* message = "Failed to create a memory pool";
+ logger(Error) << message;
+ throw InternalInitializationException(message);
+ }
+
+ status = pj_thread_create(mMemoryPool, "SIP", (pj_thread_proc *) &monitorThread,
+ this, PJ_THREAD_DEFAULT_STACK_SIZE * 2, 0, &mPjThread);
+ if (fail(status))
+ {
+ const char* message = "Failed to create SIP maintenance thread";
+ logger(Error) << message;
+ throw InternalInitializationException(message);
+ }
}
}; //End namespace SipSessionManager
diff --cc src/PJSipManager.h
index 7975fad,226a674..921455f
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@@ -30,8 -30,7 +30,9 @@@
#include "PJSipSessionModule.h"
#include "PJSipLoggingModule.h"
+#include "Transports.h"
+#include "SipModule.h"
+ #include "PJSipRegistrarModule.h"
namespace AsteriskSCF
{
@@@ -71,11 -66,12 +72,16 @@@ public
*/
PJSipLoggingModulePtr getLoggingModule();
+ pj_caching_pool* getCachingPool();
+
+ pj_pool_t* getMemoryPool();
+
/**
+ * Get a reference to the PJSIP registrar module
+ */
+ PJSipRegistrarModulePtr getRegistrarModule();
+
+ /**
* Register the PJSipSessionModule, responsible
* for basic call handling
*/
@@@ -93,23 -89,33 +99,33 @@@
*/
void registerLoggingModule();
+ /**
+ * Register the PJSIPRegistrar, responsible
+ * for keeping track of bindings of contact URIs to
+ * addresses of record.
+ */
+ void registerRegistrarModule(
+ const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& defaultListener,
+ const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Replication::SipSessionManager::V1::SipStateReplicatorPrx>& stateReplicator,
+ Ice::ObjectAdapterPtr& adapter);
+
- /**
- * Create a UDP transport.
- */
- pjsip_transport *createUDPTransport(std::string, int);
+
+ //
+ // TODO: move this transport collection stuff to a transport manager or something.
+ // PJSipManager does not need it.
+ //
-
/**
- * Create a TCP transport.
- */
- pjsip_tpfactory *createTCPTransport(std::string, int);
+ * Add a transport the module.
+ **/
+ void addTransport(const std::string& id, const TransportPtr& transport);
+ TransportPtr getTransport(const std::string& id);
- /**
- * Create a TLS transport.
- */
- pjsip_tpfactory *createTLSTransport(std::string, int, pjsip_tls_setting*);
+ void addModule(const std::string& id, const SipModulePtr& module);
+ SipModulePtr getModule(const std::string& moduleName);
+
+ void handleEvents();
private:
- static PJSipManager *mInstance;
pjsip_endpoint *mEndpoint;
PJSipSessionModulePtr mSessionModule;
PJSipLoggingModulePtr mLoggingModule;
diff --cc src/SipConfiguration.cpp
index 3e12ea4,d4077a8..b710c35
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@@ -189,7 -183,12 +189,12 @@@ class EndpointConfigHelper : public boo
{
mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateDirection, mConfig, direction));
}
-
++
+ void visitSipMediaFormatItem(const SipMediaFormatItemPtr& format)
+ {
+ mUpdates.push_back(boost::bind(&EndpointConfigHelper::addFormat, mConfig, format));
+ }
-
+
void visitSipSourceTransportAddressItem(const SipSourceTransportAddressItemPtr& source)
{
mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateSource, mConfig, source));
@@@ -1121,6 -1062,6 +1131,7 @@@ private
{
endpointGroup = i->second;
}
++ std::cerr << "XXX wha" << std::endl;
SipEndpointPtr endpoint = mEndpointFactory->findByName(group->name);
if (!endpoint)
{
diff --cc src/SipEndpoint.cpp
index f0d0e8b,59b78e8..8393972
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@@ -425,14 -407,14 +434,16 @@@ SDPDescriptorServicePrx SipEndpoint::ge
// Dynamic payloads get searched via name while static payloads get searched by number
if (descriptor->payload < 96)
{
-- if ((*configuredFormat)->getDescriptor()->payload == descriptor->payload)
++ SDPDescriptorPtr currentDescriptor = (*configuredFormat)->getDescriptor();
++ if (currentDescriptor && currentDescriptor->payload == descriptor->payload)
{
return (*configuredFormat)->getDescriptorService();
}
}
else
{
-- if ((*configuredFormat)->getDescriptor()->subtype == descriptor->subtype)
++ SDPDescriptorPtr currentDescriptor = (*configuredFormat)->getDescriptor();
++ if (currentDescriptor && currentDescriptor->subtype == descriptor->subtype)
{
return (*configuredFormat)->getDescriptorService();
}
diff --cc src/SipEndpointFactory.cpp
index 7080460,eb3486f..49724d6
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@@ -14,7 -14,8 +14,8 @@@
* at the top of the source tree.
*/
+#include <pjlib.h>
+ #include <AsteriskSCF/logger.h>
-
#include "SipEndpoint.h"
#include "SipEndpointFactory.h"
@@@ -42,8 -50,8 +50,8 @@@ void SipEndpointFactory::remove(std::st
SipEndpointPtr SipEndpointFactory::findByName(const std::string& endpointName)
{
-- std::vector<SipEndpointPtr>::iterator iter;
-- for (iter = mEndpoints.begin(); iter != mEndpoints.end(); ++ iter)
++ for (std::vector<SipEndpointPtr>::const_iterator iter = mEndpoints.begin();
++ iter != mEndpoints.end(); ++iter)
{
if (*(*iter) == endpointName)
{
diff --cc src/SipStateReplicator.h
index 9e98b8b,a6bbb22..d53bc81
--- a/src/SipStateReplicator.h
+++ b/src/SipStateReplicator.h
@@@ -42,8 -42,9 +42,9 @@@ struct SipStateReplicatorListenerImpl
class SipStateReplicatorListenerI : public AsteriskSCF::Replication::SipSessionManager::V1::SipStateReplicatorListener
{
public:
- SipStateReplicatorListenerI(const boost::shared_ptr<SipEndpointFactory>& factory, PJSipManager *manager);
+ SipStateReplicatorListenerI(const boost::shared_ptr<SipEndpointFactory>& factory, const PJSipManagerPtr& manager);
void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
+ void stateRemovedForItems(const AsteriskSCF::Replication::SipSessionManager::V1::SipStateItemSeq&, const Ice::Current&);
void stateSet(const AsteriskSCF::Replication::SipSessionManager::V1::SipStateItemSeq&, const Ice::Current&);
bool operator==(const SipStateReplicatorListenerI &rhs);
private:
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list