Commit ea8568a4 authored by jehan's avatar jehan

add redirect module

parent b29b6ae3
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<?fileVersion 4.0.0?>
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1420834493">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1420834493" moduleId="org.eclipse.cdt.core.settings" name="Default">
......@@ -14,19 +16,29 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" description="" id="0.1420834493" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<configuration artifactName="flexisip" buildProperties="" description="" id="0.1420834493" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1420834493." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1924768929" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1924768929.1593353802" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1170596990" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.363146905" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.2018244938" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1819055721" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc}/opt/include&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1467072799" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1959051998" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.780313476" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc}/opt/include&quot;"/>
<listOptionValue builtIn="false" value="/Volumes/Macintosh_HD/Users/jehanmonnier/workspaces/workspace-flexisip/opt/include"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.220648004" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.41673160" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1920684259" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc}/opt/include&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.685973751" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
......@@ -62,4 +74,11 @@
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/flexisip"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
</cproject>
......@@ -58,7 +58,8 @@ thesources= \
eventlogs/eventlogs.cc eventlogs/eventlogs.hh \
contact-masquerader.cc contact-masquerader.hh \
uac-register.cc uac-register.hh \
$(GITVERSION_FILE)
$(GITVERSION_FILE) \
module-redirect.cc
if BUILD_SNMP
......
......@@ -302,6 +302,7 @@ Agent::Agent(su_root_t* root):mBaseConfigListener(NULL), mTerminating(false){
#ifdef HAVE_DATEHANDLER
mModules.push_back(ModuleFactory::get()->createModuleInstance(this, "DateHandler"));
#endif
mModules.push_back(ModuleFactory::get()->createModuleInstance(this, "Redirect"));
mModules.push_back(ModuleFactory::get()->createModuleInstance(this, "GatewayAdapter"));
mModules.push_back(ModuleFactory::get()->createModuleInstance(this, "Registrar"));
mModules.push_back(ModuleFactory::get()->createModuleInstance(this, "StatisticsCollector"));
......
......@@ -23,7 +23,6 @@
#include "event.hh"
#include "agent.hh"
#include <string>
#include <boost/concept_check.hpp>
class ContactMasquerader {
Agent *mAgent;
......
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2014 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "module.hh"
#include "agent.hh"
#include "log/logmanager.hh"
#include "sofia-sip/sip_status.h"
using namespace ::std;
class ModuleRedirect: public Module, ModuleToolbox {
private:
static ModuleInfo<ModuleRedirect> sInfo;
sip_contact_t* mContact;
su_home_t mHome;
void onDeclare(GenericStruct *module_config) {
ConfigItemDescriptor configs[] = {
{ String, "contact", "A contact where to redirect requests. ex: <sip:127.0.0.1:5065>;expires=100", "" },
config_item_end
};
module_config->get<ConfigBoolean>("enabled")->setDefault("false");
module_config->addChildrenValues(configs);
}
bool isValidNextConfig(const ConfigValue &cv) {
GenericStruct *module_config=dynamic_cast<GenericStruct*>(cv.getParent());
if (!module_config->get<ConfigBoolean>("enabled")->readNext()) return true;
if (cv.getName() == "contact") {
sip_contact_t* contact=sip_contact_make(&mHome,cv.getName().c_str());
if (!contact) {
SLOGE<< this->getModuleName() << ": wrong destination contact for redirection [" <<cv.getName() <<"]";
return false;
} else {
su_free(&mHome, contact);
}
}
return true;
}
void onLoad(const GenericStruct *mc) {
mContact = sip_contact_make(&mHome,mc->get<ConfigString>("contact")->read().c_str());
SLOGI << this->getModuleName() << ": redirect contact is ["<< mc->get<ConfigString>("contact")->read().c_str() <<"]";
}
void onUnload() {
}
void onRequest(shared_ptr<RequestSipEvent> &ev) {
ev->reply(SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT(sip_contact_dup(&mHome,mContact)), SIPTAG_SERVER_STR(getAgent()->getServerString()), TAG_END());
}
void onResponse(std::shared_ptr<ResponseSipEvent> &ev){};
public:
ModuleRedirect(Agent *ag) : Module(ag) {
su_home_init(&mHome);
}
~ModuleRedirect() {
}
};
ModuleInfo<ModuleRedirect> ModuleRedirect::sInfo("Redirect",
"This module redirect sip request with a 302 move temporarily."
,ModuleInfoBase::ModuleOid::Redirect);
......@@ -78,7 +78,8 @@ class ModuleInfoBase {
LoadBalancer=180,
MediaRelay=210,
Transcoder=240,
Forward=270
Forward=270,
Redirect=290
};
protected:
ModuleInfoBase(const char *modname, const char *help, enum ModuleOid oid) : mName(modname), mHelp(help),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment