Commit 0bcbb651 authored by YannGarcia's avatar YannGarcia
Browse files

Validate TC_PSAP_SIP_INVITE_BV_02 with SIPp

parent b38622b8
Loading
Loading
Loading
Loading
+28 −15
Original line number Diff line number Diff line
#include <iomanip>

#include "LibSip_SIPTypesAndValues.hh"
#include "LibSip_Common.hh"

@@ -299,13 +301,16 @@ int sip_codec_headers::encode_headers(const LibSip__SIPTypesAndValues::MessageHe
      loggers::get_instance().warning("sip_codec_headers::encode_headers: Failed to encode WwwAuthenticate header");
      return -1;
    }
    loggers::get_instance().log("3333");
    //std::string s("Digest realm=\"testrealm@host.com\", nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"");
    ::osip_www_authenticate_to_str(www_authenticate_header, &hvalue);
    loggers::get_instance().log("sip_codec_headers::encode_headers: WwwAuthenticate:%s", hvalue);
    if (::osip_message_set_www_authenticate(p_sip_message, hvalue) != OSIP_SUCCESS) {
      loggers::get_instance().warning("sip_codec_headers::encode_headers: Failed to set WwwAuthenticate header in sip_message");
      return -1;
    }
    //int result = ::osip_message_set_www_authenticate(p_sip_message, s.c_str());//hvalue);
    //loggers::get_instance().log("sip_codec_headers::encode_headers: osip_message_set_www_authenticate return code:%d", result);
    osip_free(hvalue);
  }
  
  // TODO continue
@@ -1705,60 +1710,68 @@ int sip_codec_headers::encode_www_authenticate_header(const LibSip__SIPTypesAndV
  ::osip_www_authenticate_init(p_www_authenticate_header);
  const LibSip__SIPTypesAndValues::Challenge& c = p_www_authenticate.challenge();
  if (c.ischosen(LibSip__SIPTypesAndValues::Challenge::ALT_digestCln)) {
    osip_www_authenticate_set_auth_type(*p_www_authenticate_header, (char*)::strdup("Digest"));
    const LibSip__Common::CommaParam__List& l = c.digestCln();
    for (int i = 0; i < l.lengthof(); i++) {
      const LibSip__Common::GenericParam& p = l[i];
      if (std::string(static_cast<const char*>(p.id())).compare("Digest") == 0) {
        osip_www_authenticate_set_auth_type(*p_www_authenticate_header, (char*)static_cast<const char*>(p.id()));
      } else if (std::string(static_cast<const char*>(p.id())).compare("realm") == 0) {
      if (std::string(static_cast<const char*>(p.id())).compare("realm") == 0) {
        if (p.paramValue().is_present()) {
          const LibSip__Common::GenValue& g = static_cast<const LibSip__Common::GenValue&>(*p.paramValue().get_opt_value());
          if (g.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
            ::osip_www_authenticate_set_realm(*p_www_authenticate_header, (char*)static_cast<const char*>(g.tokenOrHost()));
            ::osip_www_authenticate_set_realm(*p_www_authenticate_header, (char*)::strdup(static_cast<const char*>(g.tokenOrHost())));
          } else {
            ::osip_www_authenticate_set_realm(*p_www_authenticate_header, (char*)static_cast<const char*>(g.quotedString()));
            std::stringstream ss;
            ss << std::quoted(static_cast<const char*>(g.quotedString()));
            ::osip_www_authenticate_set_realm(*p_www_authenticate_header, (char*)::strdup(ss.str().c_str()));
          }
        }
      } else if (std::string(static_cast<const char*>(p.id())).compare("nonce") == 0) {
        if (p.paramValue().is_present()) {
          const LibSip__Common::GenValue& g = static_cast<const LibSip__Common::GenValue&>(*p.paramValue().get_opt_value());
          if (g.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
            ::osip_www_authenticate_set_realm(*p_www_authenticate_header, (char*)static_cast<const char*>(g.tokenOrHost()));
            ::osip_www_authenticate_set_nonce(*p_www_authenticate_header, (char*)::strdup(static_cast<const char*>(g.tokenOrHost())));
          } else {
            ::osip_www_authenticate_set_realm(*p_www_authenticate_header, (char*)static_cast<const char*>(g.quotedString()));
            std::stringstream ss;
            ss << std::quoted(static_cast<const char*>(g.quotedString()));
            ::osip_www_authenticate_set_nonce(*p_www_authenticate_header, (char*)::strdup(ss.str().c_str()));
          }
        }
      } else if (std::string(static_cast<const char*>(p.id())).compare("stale") == 0) {
        if (p.paramValue().is_present()) {
          const LibSip__Common::GenValue& g = static_cast<const LibSip__Common::GenValue&>(*p.paramValue().get_opt_value());
          if (g.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
            ::osip_www_authenticate_set_stale(*p_www_authenticate_header, (char*)static_cast<const char*>(g.tokenOrHost()));
            ::osip_www_authenticate_set_stale(*p_www_authenticate_header, (char*)::strdup(static_cast<const char*>(g.tokenOrHost())));
          } else {
            ::osip_www_authenticate_set_stale(*p_www_authenticate_header, (char*)static_cast<const char*>(g.quotedString()));
            std::stringstream ss;
            ss << std::quoted(static_cast<const char*>(g.quotedString()));
            ::osip_www_authenticate_set_stale(*p_www_authenticate_header, (char*)::strdup(ss.str().c_str()));
          }
        }
      } else if (std::string(static_cast<const char*>(p.id())).compare("algorithm") == 0) {
        if (p.paramValue().is_present()) {
          const LibSip__Common::GenValue& g = static_cast<const LibSip__Common::GenValue&>(*p.paramValue().get_opt_value());
          std::stringstream ss;
          if (g.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
            ::osip_www_authenticate_set_algorithm(*p_www_authenticate_header, (char*)static_cast<const char*>(g.tokenOrHost()));
            ss << std::quoted(static_cast<const char*>(g.tokenOrHost()));
          } else {
            ::osip_www_authenticate_set_algorithm(*p_www_authenticate_header, (char*)static_cast<const char*>(g.quotedString()));
            ss << std::quoted(static_cast<const char*>(g.quotedString()));
          }
          ::osip_www_authenticate_set_algorithm(*p_www_authenticate_header, (char*)::strdup(ss.str().c_str()));
        }
      } else if (std::string(static_cast<const char*>(p.id())).compare("qop") == 0) {
        if (p.paramValue().is_present()) {
          const LibSip__Common::GenValue& g = static_cast<const LibSip__Common::GenValue&>(*p.paramValue().get_opt_value());
          std::stringstream ss;
          if (g.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
            ::osip_www_authenticate_set_qop_options(*p_www_authenticate_header, (char*)static_cast<const char*>(g.tokenOrHost()));
            ss << std::quoted(static_cast<const char*>(g.tokenOrHost()));
          } else {
            ::osip_www_authenticate_set_qop_options(*p_www_authenticate_header, (char*)static_cast<const char*>(g.quotedString()));
            ss << std::quoted(static_cast<const char*>(g.quotedString()));
          }
          ::osip_www_authenticate_set_qop_options(*p_www_authenticate_header, (char*)::strdup(ss.str().c_str()));
        }
      } else {
        loggers::get_instance().warning("sip_codec_headers::encode_www_authenticate_header: Unimplemented param '%s'", static_cast<const char*>(p.id()));
      }
      
    } // End of 'for'statement
  } else {
    const LibSip__SIPTypesAndValues::OtherAuth& l = c.otherChallenge();
+1 −1
Original line number Diff line number Diff line
echo "Simulate PSAP Caller side (UAS)"
rm *.log
sipp -t u1 -trace_msg -m 1 -sf PsapCaller.xml 127.0.0.1:5060
 No newline at end of file
sipp -t u1 -trace_msg -trace_err -m 1 -sf PsapCaller.xml 127.0.0.1:5060
+2 −1
Original line number Diff line number Diff line
echo "Simulate PSAP Caller side (UAS)"
sipp -t u1 -trace_msg -m 1 -sf PsapCaller.xml 127.0.0.1:5061
rm *.log
sipp -t u1 -trace_msg -trace_err -m 1 -sf PsapCaller_register.xml -oocsf PsapCaller.xml 127.0.0.1:5061
+1 −65
Original line number Diff line number Diff line
@@ -19,56 +19,10 @@
<!--                 Sipp default 'uas' scenario.                       -->
<!--                                                                    -->

<scenario name="Basic UAS responder">
<scenario name="TC_PSAP_SIP_INVITE_BV_02_OUT_OF_CALL">
  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
  <!-- are saved and used for following messages sent. Useful to test   -->
  <!-- against stateful SIP proxies/B2BUAs.                             -->

  <send retrans="500">
    <![CDATA[

      REGISTER sip:[remote_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
      To: caller <sip:[service]@127.0.0.1:5080>
      Call-ID: [call_id]
      CSeq: 1 REGISTER
      Contact: sip:sipp@[local_ip]:[local_port]
      Max-Forwards: 70
      Expires: 1800
      User-Agent: SIPp/Linux
      Route: <sip:[local_ip]:[local_port]>;lr
      Content-Length: 0

    ]]>
  </send>

  <recv response="401" auth="true">
  </recv>

  <send retrans="500">
    <![CDATA[

      REGISTER sip:[remote_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
      To: caller <sip:[service]@127.0.0.1:5080>
      Call-ID: [call_id]
      CSeq: 2 REGISTER
      Contact: sip:sipp@[local_ip]:[local_port]
      Max-Forwards: 70
      Expires: 1800
      User-Agent: SIPp/Linux
      Content-Length: 0

    ]]>
  </send>

  <recv response="200" rtd="true">
  </recv>

  <pause milliseconds="1"/>

  <recv request="INVITE" crlf="true" rrs="true">
  </recv>

@@ -159,24 +113,6 @@

  <pause milliseconds="4000"/>

  <recv request="BYE">
  </recv>

  <send>
    <![CDATA[

      SIP/2.0 200 OK
      [last_Via:]
      [last_From:]
      [last_To:]
      [last_Call-ID:]
      [last_CSeq:]
      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
      Content-Length: 0

    ]]>
  </send>

  <!-- definition of the response time repartition table (unit is ms)   -->
  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

+94 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<!-- This program is free software; you can redistribute it and/or      -->
<!-- modify it under the terms of the GNU General Public License as     -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version.                    -->
<!--                                                                    -->
<!-- This program is distributed in the hope that it will be useful,    -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->
<!-- GNU General Public License for more details.                       -->
<!--                                                                    -->
<!-- You should have received a copy of the GNU General Public License  -->
<!-- along with this program; if not, write to the                      -->
<!-- Free Software Foundation, Inc.,                                    -->
<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->
<!--                                                                    -->
<!--                 Sipp default 'uas' scenario.                       -->
<!--                                                                    -->

<scenario name="TC_PSAP_SIP_INVITE_BV_02_REGISTER">
  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
  <!-- are saved and used for following messages sent. Useful to test   -->
  <!-- against stateful SIP proxies/B2BUAs.                             -->

  <send retrans="500">
    <![CDATA[

      REGISTER sip:[remote_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
      To: caller <sip:[service]@127.0.0.1:5080>
      Call-ID: [call_id]
      CSeq: 1 REGISTER
      Contact: sip:sipp@[local_ip]:[local_port]
      Max-Forwards: 70
      Expires: 1800
      User-Agent: SIPp/Linux
      Content-Length: 0

    ]]>
  </send>

  <recv response="401" auth="true">
  </recv>

  <send retrans="500">
    <![CDATA[

      REGISTER sip:[remote_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
      To: caller <sip:[service]@127.0.0.1:5080>
      Call-ID: [call_id]
      CSeq: 2 REGISTER
      Contact: sip:sipp@[local_ip]:[local_port]
      Max-Forwards: 70
      Expires: 1800
      User-Agent: SIPp/Linux
      Content-Length: 0
    ]]>
  </send>

  <recv response="200" rtd="true">
  </recv>

  <pause milliseconds="12000"/>

  <recv request="BYE">
  </recv>

  <send>
    <![CDATA[

      SIP/2.0 200 OK
      [last_Via:]
      [last_From:]
      [last_To:]
      [last_Call-ID:]
      [last_CSeq:]
      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
      Content-Length: 0

    ]]>
  </send>

  <!-- definition of the response time repartition table (unit is ms)   -->
  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

  <!-- definition of the call length repartition table (unit is ms)     -->
  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>
Loading