|
reSIProcate/stack
9694
|
#include "resip/stack/SipStack.hxx"#include "resip/stack/Transport.hxx"#include "resip/stack/Uri.hxx"#include "rutil/Logger.hxx"#include "rutil/DataStream.hxx"#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>
Go to the source code of this file.
Defines | |
| #define | RESIPROCATE_SUBSYSTEM Subsystem::APP |
| #define | CRLF "\r\n" |
Functions | |
| int | main (int argc, char *argv[]) |
Variables | |
| char * | registerMessage = "Content-Length: 0" CRLF CRLF |
| char * | inviteMessage = "Content-Length: 0" CRLF CRLF |
| #define CRLF "\r\n" |
Definition at line 17 of file testSipStackInvite.cxx.
| #define RESIPROCATE_SUBSYSTEM Subsystem::APP |
Definition at line 16 of file testSipStackInvite.cxx.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 43 of file testSipStackInvite.cxx.
References resip::SipStack::addTransport(), resip::SipStack::buildFdSet(), resip::Log::Cout, resip::Log::Debug, DebugLog, errno, resip::SipMessage::header(), InfoLog, resip::Log::initialize(), inviteMessage, resip::RequestLine::method(), resip::SipStack::process(), resip::SipStack::receive(), resip::FdSet::select(), sendto(), resip::UDP, resip::RequestLine::uri(), and resip::Uri::user().
{
char* message = inviteMessage;
Log::initialize(Log::Cout, Log::Debug, argv[0]);
InfoLog( << "Starting up, making stack");
SipStack *theStack = new SipStack();
theStack->addTransport(UDP, 5060);
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
// create address to send to
struct sockaddr_in sa;
sa.sin_family = PF_INET;
sa.sin_addr.s_addr = inet_addr("127.0.0.1");
sa.sin_port = htons(5060);
DebugLog(<<"size="<<strlen(message) << endl << "message= " << endl << message );
// send the test message to the stack
int err = sendto(fd, message, strlen(message), 0, (struct sockaddr*) & sa, sizeof(sa));
DebugLog(<<"errno="<<errno);
assert (err == strlen(message));
int count=0;
while (1)
{
FdSet fdReadSet;
theStack->buildFdSet(fdReadSet);
fdReadSet.select(1000);
theStack->process(fdReadSet);
SipMessage* sipMessage = theStack->receive();
if (sipMessage)
{
count++;
assert (count == 1);
// InfoLog( << "got message " << *sipMessage);
cout << "to header is " << sipMessage->header(h_To) << endl;
cout << "to user is " << sipMessage->header(h_To).uri().user() << endl;
cout << "cseq sequence is " << sipMessage->header(h_CSeq).sequence() << endl;
cout << "cseq method is " << sipMessage->header(h_CSeq).method() << endl;
cout << "contact header is " << sipMessage->header(h_Contacts).front() << endl;
cout << "contact uri " << sipMessage->header(h_Contacts).front().uri().user() << endl;
cout << "request line " << sipMessage->header(h_RequestLine) << endl;
cout << "request line uri user" << sipMessage->header(h_RequestLine).uri().user() << endl;
}
usleep(20);
}
return 0;
}

| char* inviteMessage = "Content-Length: 0" CRLF CRLF |
Definition at line 31 of file testSipStackInvite.cxx.
Referenced by main().
| char* registerMessage = "Content-Length: 0" CRLF CRLF |
Definition at line 19 of file testSipStackInvite.cxx.
1.7.5.1