首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Resiprocate SIP堆栈转发SIP请求/响应

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

Stack Overflow用户
提问于 2012-10-02 16:58:00
回答 1查看 1.2K关注 0票数 1

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

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-08 22:31:00

下面的代码完成了else块中的工作。

代码语言:javascript
运行
复制
  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“”

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12687299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档