我需要在C++中使用Resiprocate SIP栈实现一个SIP代理。代理必须始终位于UAC和UAS之间,并简单地双向转发传入的SIP请求和响应。
根据我对SIP协议的阅读/理解,如果SIP代理想要位于UAC和UAS之间,它必须将其SIP地址注入到它正在接收的SIP消息的路由字段中。有人能告诉我如何在代理实现中添加/手动更新传入SIP消息中的路由字段吗?更确切地说,我需要知道的是我应该引用哪些头文件/类/句柄函数?我对SIP和resiprocate有点陌生,在某种程度上迷失在了它的源代码中。提前谢谢。
附注:有人可能想知道为什么我不使用resiprocate自己的代理实现。这是因为我需要简单地使用SIP堆栈API本身来开发一个满足特殊需求的轻量级原型。原型应该只是在SIP流量中充当转发器,仅此而已。
发布于 2012-10-08 22:31:00
下面的代码完成了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”"resip/stack/ParserContainer.hxx“”
https://stackoverflow.com/questions/12687299
复制相似问题