使用Resiprocate SIP堆栈转发SIP请求/响应

Forwarding SIP requests/responses using Resiprocate SIP stack

本文关键字:SIP 响应 请求 堆栈 Resiprocate 使用 转发      更新时间:2023-10-16

我需要使用Resiprocate SIP堆栈在C++中实现SIP代理。代理必须始终位于UAC和UAS之间,并简单地双向转发传入的SIP请求和响应。

根据我对SIP协议的阅读/理解,如果SIP代理想要位于UAC和UAS之间,它必须将其SIP地址注入到它正在接收的SIP消息的路由字段中。有人能告诉我如何在代理实现中添加/手动填充传入SIP消息中的路由字段吗?更确切地说,我需要知道的是我应该引用哪些头文件/类/句柄函数?我对SIP和resiprocate有点陌生,在某种程度上迷失了它的源代码。提前谢谢。

第页。S: 人们可能会想,为什么我不使用resiprocate自己的代理实现。这是因为我需要简单地使用SIP堆栈API本身来开发一个轻量级原型以满足特殊需求。原型应该只是充当SIP流量中的转发器,仅此而已。

Following在else块中完成任务。

void insertRouteField(SipMessage * received)
{
ErrLog ( << "***********************************n");
NameAddr& to = received->header(h_To);
ErrLog ( << "To Field: " << to.uri().toString());
NameAddr& from = received->header(h_From);
ErrLog ( << "From Field: " << from.uri().toString() );
ParserContainer<NameAddr>& rRoutes = received->header(h_RecordRoutes);
if(!rRoutes.empty())
{
NameAddr& frontRRoute = rRoutes.front();
ErrLog ( << "rRoutes: " << frontRRoute.uri().toString());
ErrLog ( << "***********************************n");
}
else
{
NameAddr route;
route.uri().scheme() = "sip";
route.uri().user() = "proxy";
route.uri().host() = SipStack::getHostname();
route.uri().port() = 5070;
route.uri().param(p_transport) = Tuple::toData(mTransport);
rRoutes.push_front(route);
NameAddr& frontRRoute = rRoutes.front();
ErrLog ( << "rRoute: " << frontRRoute.uri().toString());
ErrLog ( << "***********************************");
} 
}

您可能想要查看的标题文件:"resip/stack/Helper.hxx"resip/stack/SipMessage.hxx"resip/stack/Uri.hxx"resip/stack/SipStack.hxx"rutil/Logger.hxx"rutil/ThreadIf.hxx"resp/stack/PaserContainer.hxx">