|
reSIProcate/stack
9694
|
#include <sys/types.h>#include <iostream>#include <signal.h>#include <memory>#include "rutil/DnsUtil.hxx"#include "rutil/Inserter.hxx"#include "rutil/Logger.hxx"#include "resip/stack/DeprecatedDialog.hxx"#include "resip/stack/Helper.hxx"#include "resip/stack/SipMessage.hxx"#include "resip/stack/SipStack.hxx"#include "resip/stack/Uri.hxx"
Go to the source code of this file.
Defines | |
| #define | RESIPROCATE_SUBSYSTEM Subsystem::SIP |
Functions | |
| static void | signalHandler (int signo) |
| int | main (int argc, char *argv[]) |
Variables | |
| static bool | finished = false |
| #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 42 of file UAS.cxx.
References resip::SipStack::addTransport(), context, CritLog, finished, resip::RequestLine::getMethod(), resip::SipMessage::header(), resip::Uri::host(), resip::Log::initialize(), resip::SipMessage::isRequest(), resip::Helper::makeResponse(), resip::SipStack::process(), resip::SipStack::receive(), resip::Uri::scheme(), resip::SipStack::send(), signalHandler(), resip::TCP, resip::UDP, resip::NameAddr::uri(), resip::Uri::user(), and resip::V4.
{
#ifndef _WIN32
if ( signal( SIGPIPE, SIG_IGN) == SIG_ERR)
{
cerr << "Couldn't install signal handler for SIGPIPE" << endl;
exit(-1);
}
#endif
if ( signal( SIGINT, signalHandler ) == SIG_ERR )
{
cerr << "Couldn't install signal handler for SIGINT" << endl;
exit( -1 );
}
if ( signal( SIGTERM, signalHandler ) == SIG_ERR )
{
cerr << "Couldn't install signal handler for SIGTERM" << endl;
exit( -1 );
}
const char* logType = "cout";
const char* logLevel = "ALERT";
const char* proto = "tcp";
const char* bindAddr = "";
int seltime = 0;
#if defined(HAVE_POPT_H)
struct poptOption table[] = {
{"log-type", 'l', POPT_ARG_STRING, &logType, 0, "where to send logging messages", "syslog|cerr|cout"},
{"log-level", 'v', POPT_ARG_STRING, &logLevel, 0, "specify the default log level", "DEBUG|INFO|WARNING|ALERT"},
{ "select-time", 's', POPT_ARG_INT, &seltime, 0, "number of runs in test", 0},
{"protocol", 'p', POPT_ARG_STRING, &proto, 0, "protocol to use (tcp | udp)", 0},
{"bind", 'b', POPT_ARG_STRING, &bindAddr, 0, "interface address to bind to",0},
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
};
poptContext context = poptGetContext(NULL, argc, const_cast<const char**>(argv), table, 0);
poptGetNextOpt(context);
#endif
Log::initialize(logType, logLevel, argv[0]);
SipStack receiver;
int port = 5060;
receiver.addTransport(UDP, port, V4);
receiver.addTransport(TCP, port, V4);
NameAddr contact;
contact.uri().scheme() = "sip";
contact.uri().user() = "fluffy";
contact.uri().host() = bindAddr;
while (!finished)
{
try
{
receiver.process(seltime);
}
catch(BaseException& e)
{
CritLog(<< "Uncaught Exception: " << e);
assert(0);
}
SipMessage* request = receiver.receive();
static NameAddr contact;
if (request)
{
if(request->isRequest())
{
SipMessage response;
try
{
switch (request->header(h_RequestLine).getMethod())
{
case ACK:
break;
default:
Helper::makeResponse(response,*request,200,contact);
receiver.send(response);
break;
}
}
catch(BaseException& e)
{
CritLog(<< "Uncaught Exception: " << e );
assert(0);
}
}
delete request;
}
}
#if defined(HAVE_POPT_H)
poptFreeContext(context);
#endif
return 0;
}

| static void signalHandler | ( | int | signo | ) | [static] |
bool finished = false [static] |
Definition at line 32 of file UAS.cxx.
Referenced by main(), and signalHandler().
1.7.5.1