2012-10-02 53 views
1

我需要使用Resiprocate SIP堆棧在C++中進行SIP代理實現。代理服務器必須始終位於UAC和UAS之間,並簡單地雙向轉發傳入的SIP請求和響應。使用Resiprocate SIP堆棧轉發SIP請求/響應

根據我對SIP協議的理解,如果SIP代理想要坐在UAC和UAS之間,它必須將其SIP地址注入到正在接收的SIP消息的路由字段中。任何人都可以告訴我如何在我的代理實現中添加/處理傳入SIP消息中的路由字段?更確切地說,我需要知道的是我應該參考哪些頭文件/類/句柄函數?我對SIP很陌生,往往在源代碼中迷失方向。提前致謝。

P.S:人們可能想知道爲什麼我不使用resiprocate自己的代理實現。這是因爲我需要通過簡單地使用SIP堆棧API本身來開發特殊需求的輕量級原型。原型應該只是作爲SIP流量中的轉發者,無非就是如此。

回答

1

下面是在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 /堆棧/ Helper.hxx」 「resip /堆棧/ SipMessage.hxx」 「resip /堆棧/ Uri.hxx」 「resip /堆棧/SipStack.hxx「 」rutil/Logger.hxx「 」rutil/ThreadIf.hxx「 」resip/stack/ParserContainer.hxx「