|
reSIProcate/stack
9694
|
#include <sys/types.h>#include <iostream>#include <memory>#include "rutil/DnsUtil.hxx"#include "rutil/Inserter.hxx"#include "rutil/Logger.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 | |
| int | main (int argc, char *argv[]) |
| #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
Definition at line 23 of file testDtlsTransport.cxx.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 27 of file testDtlsTransport.cxx.
References resip::SipStack::addTransport(), resip::Message::brief(), resip::SipStack::buildFdSet(), resip::Log::Cout, resip::DTLS, resip::Data::Empty, resip::Log::Info, InfoLog, resip::Log::initialize(), resip::SipMessage::isRequest(), resip::Helper::makeRequest(), resip::Helper::makeResponse(), resip::SipStack::process(), resip::SipStack::receive(), resip::FdSet::selectMilliSeconds(), resip::SipStack::send(), resip::StunDisabled, resip::NameAddr::uri(), resip::Uri::user(), and resip::V4.
{
Log::initialize(Log::Cout, Log::Info ,"testDtlsTransport");
#ifdef USE_DTLS
Security* serverSecurity = new Security();
SipStack serverStack(serverSecurity);
serverStack.addTransport(DTLS, 15060, V4, StunDisabled, Data::Empty, "127.0.0.1");
SipStack clientStack(serverSecurity);
clientStack.addTransport(DTLS, 25060, V4);
NameAddr target("sip:bob@127.0.0.1:15060;transport=dtls");
NameAddr from("sip:alice@127.0.0.1");
NameAddr contact;
contact.uri().user() = "alice";
SipMessage * msg = Helper::makeRequest(target, from, contact, INVITE);
clientStack.send(*msg);
delete msg;
while(true)
{
{
FdSet fdset;
serverStack.buildFdSet(fdset);
fdset.selectMilliSeconds(50);
serverStack.process(fdset);
}
SipMessage* msg = serverStack.receive();
if (msg && msg->isRequest())
{
SipMessage* resp = Helper::makeResponse(*msg, 400);
serverStack.send(*resp);
InfoLog( << "Generated 400 to: " << msg->brief());
delete resp;
}
delete msg;
{
FdSet fdset;
clientStack.buildFdSet(fdset);
fdset.selectMilliSeconds(50);
clientStack.process(fdset);
}
msg = clientStack.receive();
if (msg)
{
InfoLog( << "Got from server: " << msg->brief());
break;
}
}
#endif
return 0;
}

1.7.5.1