reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
repro.cxx
Go to the documentation of this file.
1
2#if defined(HAVE_CONFIG_H)
3 #include "config.h"
4#endif
5
6#include <signal.h>
8#include "rutil/Socket.hxx"
9#include "rutil/Log.hxx"
10#include "rutil/Logger.hxx"
11
13
14#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
15
16using namespace repro;
17using namespace resip;
18using namespace std;
19
20/*
21 Extending Repro by adding custom processors to the chain is as easy as overriding one of the
22 ReproRunner class virtual methods:
23 virtual void addProcessor(repro::ProcessorChain& chain, std::unique_ptr<repro::Processor> processor);
24 virtual void makeRequestProcessorChain(repro::ProcessorChain& chain);
25 virtual void makeResponseProcessorChain(repro::ProcessorChain& chain);
26 virtual void makeTargetProcessorChain(repro::ProcessorChain& chain);
27
28 Override the makeXXXProcessorChain methods to add processors to the beginning or end of any chain,
29 or override the addProcessor method, and you can examine the name of the processor being
30 added and add your own process either before or after the correct processor.
31
32 WARNING: Be careful when checking for names of optional processors. Depending on
33 the configuration some processors may not be enabled.
34
35 Create an instance of your overridden ReproRunner class and call run to start everything
36 up.
37
38 Example:
39
40 class MyCustomProcessor : public Processor
41 {
42 public:
43 MyCustomProcessor(ProxyConfig& config) : Processor("MyCustomProcessor") {}
44 virtual ~MyCustomProcessor() {}
45
46 virtual processor_action_t process(RequestContext &context)
47 {
48 DebugLog(<< "Monkey handling request: " << *this << "; reqcontext = " << context);
49
50 ...Do something interesting here....
51
52 return Processor::Continue;
53 }
54 }
55 };
56
57 class MyReproRunner : public ReproRunner
58 {
59 public:
60 MyReproRunner() {}
61 virtual ~MyReproRunner() {}
62
63 protected:
64 virtual void addProcessor(repro::ProcessorChain& chain, std::unique_ptr<repro::Processor> processor)
65 {
66 if(processor->getName() == "LocationServer")
67 {
68 // Add MyCustomProcessor before LocationServer
69 addProcessor(chain, std::unique_ptr<Processor>(new MyCustomProcessor(*mProxyConfig)));
70 }
71 ReproRunner::addProcessor(chain, processor); // call base class implementation
72 }
73 };
74
75 There is also generic storage available for custom Processor at three different
76 scope levels via a KeyValueStore:
77 -Global Proxy Scope - Proxy::getKeyValueStore
78 -Request Scope - RequestContext::getKeyValueStore
79 -Target Scope - Target::getKeyValueStore
80 Before this storage can be used you must statically allocate a storage key.
81 See mFromTrustedNodeKey use in the IsTrustedNode class for an example.
82
83*/
84
85int
86main(int argc, char** argv)
87{
88 // Initialize network
90
91#if defined(WIN32) && defined(_DEBUG) && defined(LEAK_CHECK)
92 { FindMemoryLeaks fml;
93#endif
94
96 if(!repro.run(argc, argv))
97 {
98 cerr << "Failed to start repro, exiting..." << endl;
99 exit(-1);
100 }
101
102 repro.mainLoop();
103
104 repro.shutdown();
105
106#if defined(WIN32) && defined(_DEBUG) && defined(LEAK_CHECK)
107 }
108#endif
109 return 0;
110}
111
112
113/* ====================================================================
114 * The Vovida Software License, Version 1.0
115 *
116 * Copyright (c) 2000-2005
117 *
118 * Redistribution and use in source and binary forms, with or without
119 * modification, are permitted provided that the following conditions
120 * are met:
121 *
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions and the following disclaimer.
124 *
125 * 2. Redistributions in binary form must reproduce the above copyright
126 * notice, this list of conditions and the following disclaimer in
127 * the documentation and/or other materials provided with the
128 * distribution.
129 *
130 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
131 * and "Vovida Open Communication Application Library (VOCAL)" must
132 * not be used to endorse or promote products derived from this
133 * software without prior written permission. For written
134 * permission, please contact vocal@vovida.org.
135 *
136 * 4. Products derived from this software may not be called "VOCAL", nor
137 * may "VOCAL" appear in their name, without prior written
138 * permission of Vovida Networks, Inc.
139 *
140 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
141 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
142 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
143 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
144 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
145 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
146 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
147 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
148 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
149 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
150 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
151 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
152 * DAMAGE.
153 *
154 * ====================================================================
155 *
156 * This software consists of voluntary contributions made by Vovida
157 * Networks, Inc. and many individuals on behalf of Vovida Networks,
158 * Inc. For more information on Vovida Networks, Inc., please see
159 * <http://www.vovida.org/>.
160 *
161 */
162/*
163 * vi: set shiftwidth=3 expandtab:
164 */
Handles cross-platform sockets compatibility.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
void initNetwork()
set up network - does nothing in unix but needed for windows
Definition Socket.cxx:83
int main(int argc, char **argv)
Definition repro.cxx:86