[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
Mon Oct 11 16:31:08 CDT 2010


branch "master" has been updated
       via  0379aab8523e02982ee9c6cf50d3a84ec1a05ca3 (commit)
       via  eb2424c5429e4c1dd814fd098485629fe9813921 (commit)
       via  0a04eb9bd251ba1a6eaed4d5274ade453b93f594 (commit)
       via  8defc4efbdbd7f8a514e016a1aa17fc9f20176c6 (commit)
       via  41a730882ffed6a9c62bad651485f15080ffc9d3 (commit)
       via  d889fbe12b7e9809c59cd9c3a51fa3b4c633b749 (commit)
      from  d35013e16d1cb5439fb1995f39115c462d99ae93 (commit)

Summary of changes:
 src/CMakeLists.txt                     |    3 +
 src/PJSipDummyModule.h                 |   39 +++++++++++++
 src/PJSipDummyModuleConstruction.cpp   |   96 ++++++++++++++++++++++++++++++++
 src/PJSipLoggingModule.cpp             |   78 ++++++++++++++++++++++++++
 src/PJSipLoggingModule.h               |   35 ++++++++++++
 src/PJSipLoggingModuleConstruction.cpp |   88 +++++++++++++++++++++++++++++
 src/PJSipManager.cpp                   |    9 +++
 src/PJSipManager.h                     |   14 +++++
 src/SipChannelServiceApp.cpp           |    4 +
 9 files changed, 366 insertions(+), 0 deletions(-)
 create mode 100644 src/PJSipDummyModule.h
 create mode 100644 src/PJSipDummyModuleConstruction.cpp
 create mode 100644 src/PJSipLoggingModule.cpp
 create mode 100644 src/PJSipLoggingModule.h
 create mode 100644 src/PJSipLoggingModuleConstruction.cpp


- Log -----------------------------------------------------------------
commit 0379aab8523e02982ee9c6cf50d3a84ec1a05ca3
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 11 15:48:39 2010 -0500

    Add printing of outgoing messages, too.

diff --git a/src/PJSipLoggingModule.cpp b/src/PJSipLoggingModule.cpp
index a75972b..6577729 100644
--- a/src/PJSipLoggingModule.cpp
+++ b/src/PJSipLoggingModule.cpp
@@ -45,24 +45,28 @@ pj_status_t PJSipLoggingModule::unload()
 pj_bool_t PJSipLoggingModule::on_rx_request(pjsip_rx_data *rdata)
 {
 	lg(Debug) << "Incoming SIP request" << std::endl;
+	lg(Debug) << rdata->pkt_info.packet << std::endl;
 	return PJ_FALSE;
 }
 
 pj_bool_t PJSipLoggingModule::on_rx_response(pjsip_rx_data *rdata)
 {
 	lg(Debug) << "Incoming SIP response" << std::endl;
+	lg(Debug) << rdata->pkt_info.packet << std::endl;
 	return PJ_FALSE;
 }
 
 pj_status_t PJSipLoggingModule::on_tx_request(pjsip_tx_data *tdata)
 {
 	lg(Debug) << "Outgoing SIP request" << std::endl;
+	lg(Debug) << tdata->buf.start << std::endl;
 	return PJ_SUCCESS;
 }
 
 pj_status_t PJSipLoggingModule::on_tx_response(pjsip_tx_data *tdata)
 {
 	lg(Debug) << "Outgoing SIP response" << std::endl;
+	lg(Debug) << tdata->buf.start << std::endl;
 	return PJ_SUCCESS;
 }
 

commit eb2424c5429e4c1dd814fd098485629fe9813921
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 11 14:43:13 2010 -0500

    Add necessary config parsing and PJSipManager changes to
    accommodate the logging module. It works!

diff --git a/src/PJSipLoggingModule.cpp b/src/PJSipLoggingModule.cpp
index 344a532..a75972b 100644
--- a/src/PJSipLoggingModule.cpp
+++ b/src/PJSipLoggingModule.cpp
@@ -47,6 +47,7 @@ pj_bool_t PJSipLoggingModule::on_rx_request(pjsip_rx_data *rdata)
 	lg(Debug) << "Incoming SIP request" << std::endl;
 	return PJ_FALSE;
 }
+
 pj_bool_t PJSipLoggingModule::on_rx_response(pjsip_rx_data *rdata)
 {
 	lg(Debug) << "Incoming SIP response" << std::endl;
@@ -56,11 +57,13 @@ pj_bool_t PJSipLoggingModule::on_rx_response(pjsip_rx_data *rdata)
 pj_status_t PJSipLoggingModule::on_tx_request(pjsip_tx_data *tdata)
 {
 	lg(Debug) << "Outgoing SIP request" << std::endl;
+	return PJ_SUCCESS;
 }
 
 pj_status_t PJSipLoggingModule::on_tx_response(pjsip_tx_data *tdata)
 {
 	lg(Debug) << "Outgoing SIP response" << std::endl;
+	return PJ_SUCCESS;
 }
 
 void PJSipLoggingModule::on_tsx_state(pjsip_transaction *tsx, pjsip_event *event)
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index ecc620f..f6d02b6 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -74,6 +74,10 @@ void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
       serviceLocator, stateReplicator, replica);
 }
 
+void PJSipManager::registerLoggingModule(pjsip_endpoint *endpt)
+{
+   mLoggingModule = new PJSipLoggingModule(endpt);
+}
 
 pjsip_endpoint *PJSipManager::getEndpoint()
 {
@@ -85,6 +89,11 @@ pjsip_module &PJSipManager::getSessionModule()
    return mSessionModule->getModule();
 }
 
+pjsip_module &PJSipManager::getLoggingModule()
+{
+   return mLoggingModule->getModule();
+}
+
 bool PJSipManager::setTransports(pjsip_endpoint *endpoint, Ice::PropertiesPtr props)
 {
    //XXX We'll also want to allow for TCP and TLS-specific
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 60b3036..15c27cf 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -17,6 +17,7 @@
 
 #include <boost/shared_ptr.hpp>
 #include "PJSipSessionModule.h"
+#include "PJSipLoggingModule.h"
 
 namespace AsteriskSCF
 {
@@ -46,6 +47,12 @@ public:
 	 * Get a reference to the PJSIP session module
 	 */
 	pjsip_module &getSessionModule();
+
+	/**
+	 * Get a reference to the PJSIP logging module
+	 */
+	pjsip_module &getLoggingModule();
+
 	/**
 	 * Register the PJSipSessionModule, responsible
 	 * for basic call handling
@@ -57,10 +64,17 @@ public:
 		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica
 	);
+
+	/**
+	 * Register the PJSipLoggingModule, responsible
+	 * for logging incoming and outgoing SIP messages
+	 */
+	void registerLoggingModule(pjsip_endpoint *endpt);
 private:
 	static PJSipManager *mInstance;
 	pjsip_endpoint *mEndpoint;
 	PJSipSessionModule *mSessionModule;
+	PJSipLoggingModule *mLoggingModule;
 	pj_thread_t *mPjThread;
 	pj_caching_pool mCachingPool;
 	pj_pool_t *mMemoryPool;
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 6e2b107..7f160a5 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -460,6 +460,10 @@ void SipChannelService::registerPJSipModules(pjsip_endpoint *endpt)
          mPJSipManager->registerSessionModule(endpt, mEndpointFactory,
             mSessionRouter, mServiceLocator, mStateReplicator, mReplicaService);
       }
+	  else if (*i == "Logging" || *i == "Logger")
+	  {
+	     mPJSipManager->registerLoggingModule(endpt);
+	  }
    }
    lg(Debug) << "Registered PJSIP modules";
 }

commit 0a04eb9bd251ba1a6eaed4d5274ade453b93f594
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 11 13:51:26 2010 -0500

    Write up stubs for the logging module.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index beabb3b..891d062 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -34,6 +34,9 @@ hydra_component_add_file(SipChannelService PJSipModule.h)
 hydra_component_add_file(SipChannelService PJSipSessionModule.cpp)
 hydra_component_add_file(SipChannelService PJSipSessionModuleConstruction.cpp)
 hydra_component_add_file(SipChannelService PJSipSessionModule.h)
+hydra_component_add_file(SipChannelService PJSipLoggingModule.cpp)
+hydra_component_add_file(SipChannelService PJSipLoggingModuleConstruction.cpp)
+hydra_component_add_file(SipChannelService PJSipLoggingModule.h)
 hydra_component_add_file(SipChannelService SipStateReplicatorListener.cpp)
 hydra_component_add_file(SipChannelService SipStateReplicator.h)
 
diff --git a/src/PJSipDummyModule.h b/src/PJSipDummyModule.h
index 6412236..ebf7444 100644
--- a/src/PJSipDummyModule.h
+++ b/src/PJSipDummyModule.h
@@ -8,6 +8,7 @@
 
 #pragma once
 
+#include "PJSipModule.h"
 /**
  * This header is intended to be used as a basis
  * for writing PJSIP modules in Asterisk SCF.
@@ -19,7 +20,7 @@ namespace AsteriskSCF
 namespace SipChannelService
 {
 
-class PJSipDummyModule
+class PJSipDummyModule : public PJSipModule
 {
 public:
 	PJSipDummyModule(pjsip_endpoint *endpt);
diff --git a/src/PJSipLoggingModule.cpp b/src/PJSipLoggingModule.cpp
new file mode 100644
index 0000000..344a532
--- /dev/null
+++ b/src/PJSipLoggingModule.cpp
@@ -0,0 +1,71 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+#include "PJSipLoggingModule.h"
+#include "logger.h"
+
+using namespace AsteriskSCF::System::Logging;
+
+namespace
+{
+Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.SipChannelService");
+}
+
+namespace AsteriskSCF
+{
+
+namespace SipChannelService
+{
+
+pj_status_t PJSipLoggingModule::load(pjsip_endpoint *endpt)
+{
+   return PJ_SUCCESS;
+}
+
+pj_status_t PJSipLoggingModule::start()
+{
+   return PJ_SUCCESS;
+}
+
+pj_status_t PJSipLoggingModule::stop()
+{
+   return PJ_SUCCESS;
+}
+
+pj_status_t PJSipLoggingModule::unload()
+{
+   return PJ_SUCCESS;
+}
+
+pj_bool_t PJSipLoggingModule::on_rx_request(pjsip_rx_data *rdata)
+{
+	lg(Debug) << "Incoming SIP request" << std::endl;
+	return PJ_FALSE;
+}
+pj_bool_t PJSipLoggingModule::on_rx_response(pjsip_rx_data *rdata)
+{
+	lg(Debug) << "Incoming SIP response" << std::endl;
+	return PJ_FALSE;
+}
+
+pj_status_t PJSipLoggingModule::on_tx_request(pjsip_tx_data *tdata)
+{
+	lg(Debug) << "Outgoing SIP request" << std::endl;
+}
+
+pj_status_t PJSipLoggingModule::on_tx_response(pjsip_tx_data *tdata)
+{
+	lg(Debug) << "Outgoing SIP response" << std::endl;
+}
+
+void PJSipLoggingModule::on_tsx_state(pjsip_transaction *tsx, pjsip_event *event)
+{
+}
+
+};
+};
diff --git a/src/PJSipLoggingModule.h b/src/PJSipLoggingModule.h
index dacb8da..9673d1c 100644
--- a/src/PJSipLoggingModule.h
+++ b/src/PJSipLoggingModule.h
@@ -8,13 +8,15 @@
 
 #pragma once
 
+#include "PJSipModule.h"
+
 namespace AsteriskSCF
 {
 
 namespace SipChannelService
 {
 
-class PJSipLoggingModule
+class PJSipLoggingModule : public PJSipModule
 {
 public:
 	PJSipLoggingModule(pjsip_endpoint *endpt);
diff --git a/src/PJSipLoggingModuleConstruction.cpp b/src/PJSipLoggingModuleConstruction.cpp
index 545bf28..d49a217 100644
--- a/src/PJSipLoggingModuleConstruction.cpp
+++ b/src/PJSipLoggingModuleConstruction.cpp
@@ -66,7 +66,12 @@ PJSipLoggingModule::PJSipLoggingModule(pjsip_endpoint *endpt)
 	loggingModule = this;
 	char name[] = "Logging Module";
 	mModule.name = pj_str(name);
-	mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
+	// This is the highest priority module. We do this
+	// so that on outgoing messages, the transport information
+	// will have been filled in by the transport layer. This way
+	// what we log is exactly the same as what goes out over the
+	// wire.
+	mModule.priority = 0;
 	mModule.load = loggingLoad;
 	mModule.start = loggingStart;
 	mModule.stop = loggingStop;
@@ -78,3 +83,6 @@ PJSipLoggingModule::PJSipLoggingModule(pjsip_endpoint *endpt)
 	mModule.on_tsx_state = loggingOnTsxState;
 	pjsip_endpt_register_module(endpt, &mModule);
 }
+
+};
+};

commit 8defc4efbdbd7f8a514e016a1aa17fc9f20176c6
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 11 12:36:21 2010 -0500

    use the dummy module to write up a quick logging module constructor.

diff --git a/src/PJSipLoggingModule.h b/src/PJSipLoggingModule.h
new file mode 100644
index 0000000..dacb8da
--- /dev/null
+++ b/src/PJSipLoggingModule.h
@@ -0,0 +1,33 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+#pragma once
+
+namespace AsteriskSCF
+{
+
+namespace SipChannelService
+{
+
+class PJSipLoggingModule
+{
+public:
+	PJSipLoggingModule(pjsip_endpoint *endpt);
+	pj_status_t load(pjsip_endpoint *endpoint);
+	pj_status_t start();
+	pj_status_t stop();
+	pj_status_t unload();
+	pj_bool_t on_rx_request(pjsip_rx_data *rdata);
+	pj_bool_t on_rx_response(pjsip_rx_data *rdata);
+	pj_status_t on_tx_request(pjsip_tx_data *tdata);
+	pj_status_t on_tx_response(pjsip_tx_data *tdata);
+	void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
+};
+
+};
+};
diff --git a/src/PJSipLoggingModuleConstruction.cpp b/src/PJSipLoggingModuleConstruction.cpp
new file mode 100644
index 0000000..545bf28
--- /dev/null
+++ b/src/PJSipLoggingModuleConstruction.cpp
@@ -0,0 +1,80 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+#include "PJSipLoggingModule.h"
+
+namespace AsteriskSCF
+{
+
+namespace SipChannelService
+{
+
+static PJSipLoggingModule *loggingModule;
+
+static pj_status_t loggingLoad(pjsip_endpoint *endpoint)
+{
+	return loggingModule->load(endpoint);
+}
+
+static pj_status_t loggingStart()
+{
+	return loggingModule->unload();
+}
+
+static pj_status_t loggingStop()
+{
+	return loggingModule->stop();
+}
+
+static pj_status_t loggingUnload()
+{
+	return loggingModule->unload();
+}
+
+static pj_bool_t loggingOnRxRequest(pjsip_rx_data *rdata)
+{
+	return loggingModule->on_rx_request(rdata);
+}
+
+static pj_bool_t loggingOnRxResponse(pjsip_rx_data *rdata)
+{
+	return loggingModule->on_rx_response(rdata);
+}
+
+static pj_bool_t loggingOnTxRequest(pjsip_tx_data *tdata)
+{
+	return loggingModule->on_tx_request(tdata);
+}
+
+static pj_status_t loggingOnTxResponse(pjsip_tx_data *tdata)
+{
+	return loggingModule->on_tx_response(tdata);
+}
+
+static void loggingOnTsxState(pjsip_transaction *tsx, pjsip_event *event)
+{
+	return loggingModule->on_tsx_state(tsx, event);
+}
+
+PJSipLoggingModule::PJSipLoggingModule(pjsip_endpoint *endpt)
+{
+	loggingModule = this;
+	char name[] = "Logging Module";
+	mModule.name = pj_str(name);
+	mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
+	mModule.load = loggingLoad;
+	mModule.start = loggingStart;
+	mModule.stop = loggingStop;
+	mModule.unload = loggingUnload;
+	mModule.on_rx_request = loggingOnRxRequest;
+	mModule.on_rx_response = loggingOnRxResponse;
+	mModule.on_tx_request = loggingOnTxRequest;
+	mModule.on_tx_response = loggingOnTxResponse;
+	mModule.on_tsx_state = loggingOnTsxState;
+	pjsip_endpt_register_module(endpt, &mModule);
+}

commit 41a730882ffed6a9c62bad651485f15080ffc9d3
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 11 12:35:47 2010 -0500

    Add a couple extra comments.

diff --git a/src/PJSipDummyModuleConstruction.cpp b/src/PJSipDummyModuleConstruction.cpp
index a92284d..81299c1 100644
--- a/src/PJSipDummyModuleConstruction.cpp
+++ b/src/PJSipDummyModuleConstruction.cpp
@@ -14,6 +14,17 @@ namespace AsteriskSCF
 namespace SipChannelService
 {
 
+/**
+ * This file sets up the construction of
+ * your new module. Using this method, we can
+ * separate the C-style callbacks from PJSIP
+ * from the C++-style class members of our
+ * module class.
+ *
+ * For more information on PJSIP module callbacks,
+ * see the PJSIP developer's guide.
+ */
+
 static PJSipDummyModule *dummyModule;
 
 static pj_status_t dummyLoad(pjsip_endpoint *endpoint)
@@ -67,6 +78,11 @@ PJSipDummyModule::PJSipDummyModule(pjsip_endpoint *endpt)
 	char name[] = "Dummy Module";
 	mModule.name = pj_str(name);
 	mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
+	/* Note that not all PJSIP module callbacks are required.
+	 * If you don't wish to have one defined, feel free to set
+	 * it NULL in this listing and remove the corresponding
+	 * static function above.
+	 */
 	mModule.load = dummyLoad;
 	mModule.start = dummyStart;
 	mModule.stop = dummyStop;

commit d889fbe12b7e9809c59cd9c3a51fa3b4c633b749
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 11 12:03:49 2010 -0500

    Add a dummy .h and construction.cpp file to be used for future
    PJSIP module development.

diff --git a/src/PJSipDummyModule.h b/src/PJSipDummyModule.h
new file mode 100644
index 0000000..6412236
--- /dev/null
+++ b/src/PJSipDummyModule.h
@@ -0,0 +1,38 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+#pragma once
+
+/**
+ * This header is intended to be used as a basis
+ * for writing PJSIP modules in Asterisk SCF.
+ */
+
+namespace AsteriskSCF
+{
+
+namespace SipChannelService
+{
+
+class PJSipDummyModule
+{
+public:
+	PJSipDummyModule(pjsip_endpoint *endpt);
+	pj_status_t load(pjsip_endpoint *endpoint);
+	pj_status_t start();
+	pj_status_t stop();
+	pj_status_t unload();
+	pj_bool_t on_rx_request(pjsip_rx_data *rdata);
+	pj_bool_t on_rx_response(pjsip_rx_data *rdata);
+	pj_status_t on_tx_request(pjsip_tx_data *tdata);
+	pj_status_t on_tx_response(pjsip_tx_data *tdata);
+	void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
+};
+
+};
+};
diff --git a/src/PJSipDummyModuleConstruction.cpp b/src/PJSipDummyModuleConstruction.cpp
new file mode 100644
index 0000000..a92284d
--- /dev/null
+++ b/src/PJSipDummyModuleConstruction.cpp
@@ -0,0 +1,80 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+#include "PJSipDummyModule.h"
+
+namespace AsteriskSCF
+{
+
+namespace SipChannelService
+{
+
+static PJSipDummyModule *dummyModule;
+
+static pj_status_t dummyLoad(pjsip_endpoint *endpoint)
+{
+	return dummyModule->load(endpoint);
+}
+
+static pj_status_t dummyStart()
+{
+	return dummyModule->unload();
+}
+
+static pj_status_t dummyStop()
+{
+	return dummyModule->stop();
+}
+
+static pj_status_t dummyUnload()
+{
+	return dummyModule->unload();
+}
+
+static pj_bool_t dummyOnRxRequest(pjsip_rx_data *rdata)
+{
+	return dummyModule->on_rx_request(rdata);
+}
+
+static pj_bool_t dummyOnRxResponse(pjsip_rx_data *rdata)
+{
+	return dummyModule->on_rx_response(rdata);
+}
+
+static pj_bool_t dummyOnTxRequest(pjsip_tx_data *tdata)
+{
+	return dummyModule->on_tx_request(tdata);
+}
+
+static pj_status_t dummyOnTxResponse(pjsip_tx_data *tdata)
+{
+	return dummyModule->on_tx_response(tdata);
+}
+
+static void dummyOnTsxState(pjsip_transaction *tsx, pjsip_event *event)
+{
+	return dummyModule->on_tsx_state(tsx, event);
+}
+
+PJSipDummyModule::PJSipDummyModule(pjsip_endpoint *endpt)
+{
+	dummyModule = this;
+	char name[] = "Dummy Module";
+	mModule.name = pj_str(name);
+	mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
+	mModule.load = dummyLoad;
+	mModule.start = dummyStart;
+	mModule.stop = dummyStop;
+	mModule.unload = dummyUnload;
+	mModule.on_rx_request = dummyOnRxRequest;
+	mModule.on_rx_response = dummyOnRxResponse;
+	mModule.on_tx_request = dummyOnTxRequest;
+	mModule.on_tx_response = dummyOnTxResponse;
+	mModule.on_tsx_state = dummyOnTsxState;
+	pjsip_endpt_register_module(endpt, &mModule);
+}

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list