[reSIProcate] Outbound Proxy
Hi,
I have finished building User Agent with resiprocate. Now I want to try
out Proxy.
Can anybody tell me how to set the outbound proxy. I have done it but it
is not able to send to the request.
I am attaching the code also.
if Somebody can help me i will be very thankful. Its very urgent.
Thanks in advance.
With Regards
Santosh
#include "iostream.h"
#include "resiprocate/Helper.hxx"
#include "resiprocate/SipMessage.hxx"
#include "resiprocate/Uri.hxx"
#include "resiprocate/SipStack.hxx"
#include "resiprocate/DeprecatedDialog.hxx"
#include "resiprocate/os/Logger.hxx"
#include "resiprocate/os/ThreadIf.hxx"
#include "resiprocate/SdpContents.hxx"
using namespace resip;
using namespace std;
class SipProxy
{
private:
SipStack sipStack;
public:
SipProxy();
void buildFdSet(FdSet& fdset);
void process(FdSet& fdset);
void processRequest( SipMessage* );
void processResponse( SipMessage* );
};
SipProxy::SipProxy()
{
sipStack.addTransport(UDP,5070);
}
void SipProxy::buildFdSet(FdSet& fdset)
{
sipStack.buildFdSet(fdset);
}
void SipProxy::process(FdSet& fdset)
{
sipStack.process(fdset);
SipMessage *received_message = sipStack.receive();
if(received_message)
{
if(received_message->isRequest())
{
processRequest(received_message);
}
else
if(received_message->isResponse())
{
processResponse(received_message);
}
}
}
void SipProxy::processRequest(SipMessage *request_received)
{
if( request_received->header(h_RequestLine).method() == INVITE )
{
Uri new_uri;
Uri received_uri =
request_received->header(h_RequestLine).uri();
Data username = received_uri.user();
Data hostname = received_uri.host();
if(username=="sipphone" && hostname == "idealabs.com")
{
request_received->header(h_RequestLine).uri().host() =
"192.168.1.10";
}
--request_received->header(h_MaxForwards).value();
Via via;
via.sentHost() = "192.168.1.201";
via.sentPort() = 5070;
via.transport() = "UDP";
request_received->header(h_Vias).push_back(via);
cout<<"The New Request is: "<<endl;
cout<<*request_received;
sipStack.send(*request_received);
cout<<"Request SEnt";
}
}
void SipProxy::processResponse(SipMessage *response_received)
{
sipStack.send(*response_received);
}
int main(int argc, char *argv[])
{
SipProxy sipProxy;
while (true)
{
FdSet fdset;
sipProxy.buildFdSet(fdset);
fdset.selectMilliSeconds(0);
sipProxy.process(fdset);
}
return 1;
}