Commit e8ac7278 authored by garciay's avatar garciay
Browse files

Enhance SIP codec

parent 54080beb
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -9,7 +9,5 @@ cd "$(dirname "$0")"

run_dir="$(pwd)"

cd docker

./build-container.sh
./run-container.sh "${run_dir}"
+33 −21
Original line number Diff line number Diff line
@@ -168,10 +168,20 @@ int sip_codec_request::encode_request_headers(const LibSip__SIPTypesAndValues::M
  ::osip_via_to_str(via_header, &hvalue);
  loggers::get_instance().log("sip_codec_request::encode_request_headers: Via:%s", hvalue);
  ::osip_message_set_via(p_sip_message, hvalue);
  //  ::osip_via_free(via_header);
  ::osip_via_free(via_header);
  osip_free(hvalue);

  // Decode Optional fields
  osip_cseq_t* cseq_header = nullptr;
  if (encode_c_seq_header(p_msg_header.cSeq(), &cseq_header) == -1) {
    loggers::get_instance().warning("sip_codec_request::encode_request_headers: Faile to encode CSeq header");
    return -1;
  }
  ::osip_cseq_to_str(cseq_header, &hvalue);
  loggers::get_instance().log("sip_codec_request::encode_request_headers: Cseq:%s", hvalue);
  ::osip_message_set_cseq(p_sip_message, hvalue);
  ::osip_cseq_free(cseq_header);
  osip_free(hvalue);

  // MaxForwards
  if (encode_max_forwards_header(p_msg_header.maxForwards(), &p_sip_message) == -1) {
@@ -277,6 +287,18 @@ void sip_codec_request::encode_host_port(const LibSip__SIPTypesAndValues::HostPo
  loggers::get_instance().log("sip_codec_request::encode_port_port: port:'%s'", p_port.c_str());
} // End of method encode_host_port

int sip_codec_request::encode_c_seq_header(const LibSip__SIPTypesAndValues::CSeq& p_c_seq, osip_cseq_t** p_c_seq_header)
{
  loggers::get_instance().log(">>> sip_codec_request::encode_c_seq_header");

  ::osip_cseq_init(p_c_seq_header);
  ::osip_cseq_set_number(*p_c_seq_header, (char*)::strdup(std::to_string(static_cast<const int>(p_c_seq.seqNumber())).c_str()));
  ::osip_cseq_set_method(*p_c_seq_header, (char*)::strdup(static_cast<const char*>(p_c_seq.method())));
  
  return 0;
} // End of method encode_c_seq_header


int sip_codec_request::encode_from_header(const LibSip__SIPTypesAndValues::From& p_from, osip_from_t** p_from_header) {
  loggers::get_instance().log(">>> sip_codec_request::encode_from_header");
  
@@ -295,9 +317,9 @@ int sip_codec_request::encode_from_header(const LibSip__SIPTypesAndValues::From&
    if (addr.displayName().is_present()) {
      const LibSip__SIPTypesAndValues::DisplayName& n = static_cast<const LibSip__SIPTypesAndValues::DisplayName&>(addr.displayName());
      if (n.ischosen(LibSip__SIPTypesAndValues::DisplayName::ALT_token)) {
        ::osip_from_set_displayname(*p_from_header, (char*)static_cast<const char*>(static_cast<CHARSTRING>(n.token())));
        ::osip_from_set_displayname(*p_from_header, (char*)::strdup(static_cast<const char*>(static_cast<CHARSTRING>(n.token()))));
      } else if (n.ischosen(LibSip__SIPTypesAndValues::DisplayName::ALT_quotedString)) {
        ::osip_from_set_displayname(*p_from_header, (char*)static_cast<const char*>(static_cast<CHARSTRING>(n.quotedString())));
        ::osip_from_set_displayname(*p_from_header, (char*)::strdup(static_cast<const char*>(static_cast<CHARSTRING>(n.quotedString()))));
      } else {
        loggers::get_instance().warning("sip_codec_request::encode_from_header: Failed to encode DisplayName");
        ::osip_from_free(*p_from_header);
@@ -377,9 +399,9 @@ int sip_codec_request::encode_to_header(const LibSip__SIPTypesAndValues::To& p_t
    if (addr.displayName().is_present()) {
      const LibSip__SIPTypesAndValues::DisplayName& n = static_cast<const LibSip__SIPTypesAndValues::DisplayName&>(addr.displayName());
      if (n.ischosen(LibSip__SIPTypesAndValues::DisplayName::ALT_token)) {
        ::osip_to_set_displayname(*p_to_header, (char*)static_cast<const char*>(static_cast<CHARSTRING>(n.token())));
        ::osip_to_set_displayname(*p_to_header, (char*)::strdup(static_cast<const char*>(static_cast<CHARSTRING>(n.token()))));
      } else if (n.ischosen(LibSip__SIPTypesAndValues::DisplayName::ALT_quotedString)) {
        ::osip_to_set_displayname(*p_to_header, (char*)static_cast<const char*>(static_cast<CHARSTRING>(n.quotedString())));
        ::osip_to_set_displayname(*p_to_header, (char*)::strdup(static_cast<const char*>(static_cast<CHARSTRING>(n.quotedString()))));
      } else {
        loggers::get_instance().warning("sip_codec_request::encode_to_header: Failed to encode DisplayName");
        ::osip_to_free(*p_to_header);
@@ -403,12 +425,7 @@ int sip_codec_request::encode_to_header(const LibSip__SIPTypesAndValues::To& p_t
    return -1;
  }
  if (p_to.toParams().is_present()) {
    const LibSip__Common::SemicolonParam__List& l = static_cast<const LibSip__Common::SemicolonParam__List>(p_to.toParams());
    // TODO encode_semi_colon_params(l, );
    loggers::get_instance().warning("sip_codec_request::encode_to_header: Failed to encode SemicolonParam__List");
    ::osip_to_free(*p_to_header);
    *p_to_header = nullptr;
    return -1;
    encode_semi_colon_params(static_cast<const LibSip__Common::SemicolonParam__List>(p_to.toParams()), &(*p_to_header)->gen_params);
  }
  
  return 0;
@@ -423,9 +440,9 @@ int sip_codec_request::encode_via_header(const LibSip__SIPTypesAndValues::Via& p
    const LibSip__SIPTypesAndValues::ViaBody v = l[i];
    loggers::get_instance().log_msg("sip_codec_request::encode_via_header: Processing ", v);

    ::via_set_protocol(*p_via_header, (char*)static_cast<const char *>(v.sentProtocol().protocolName()));
    ::via_set_version(*p_via_header, (char*)static_cast<const char *>(v.sentProtocol().protocolVersion()));
    ::via_set_comment(*p_via_header, (char*)static_cast<const char *>(v.sentProtocol().transport()));
    ::via_set_protocol(*p_via_header, (char*)::strdup(static_cast<const char *>(v.sentProtocol().protocolName())));
    ::via_set_version(*p_via_header, (char*)::strdup(static_cast<const char *>(v.sentProtocol().protocolVersion())));
    ::via_set_comment(*p_via_header, (char*)::strdup(static_cast<const char *>(v.sentProtocol().transport())));
    std::string host;
    std::string port;
    encode_host_port(v.sentBy(), host, port);
@@ -437,12 +454,7 @@ int sip_codec_request::encode_via_header(const LibSip__SIPTypesAndValues::Via& p
    }
    
    if (v.viaParams().is_present()) {
      const LibSip__Common::SemicolonParam__List& params = static_cast<LibSip__Common::SemicolonParam__List>(v.viaParams());
      // TODO encode_semi_colon_params(l, );
      loggers::get_instance().warning("sip_codec_request::encode_via_header: Failed to encode SemicolonParam__List");
      ::osip_via_free(*p_via_header);
      *p_via_header = nullptr;
      return -1;
      encode_semi_colon_params(static_cast<const LibSip__Common::SemicolonParam__List>(v.viaParams()), &(*p_via_header)->via_params);
    }
  } // End of 'for' statement
  
@@ -714,7 +726,7 @@ int sip_codec_request::encode_semi_colon_params(const LibSip__Common::SemicolonP
        loggers::get_instance().log_msg("sip_codec_request::encode_semi_colon_params: v: ", v);
        if (v.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
          loggers::get_instance().log_msg("sip_codec_request::encode_semi_colon_params: tokenOrHost: ", v.tokenOrHost());
          ::osip_generic_param_add(p_sip_list, (char*)static_cast<const char*>(param.id()), (char*)static_cast<const char*>(v.tokenOrHost()));
          ::osip_generic_param_add(p_sip_list, (char*)::strdup(static_cast<const char*>(param.id())), (char*)::strdup(static_cast<const char*>(v.tokenOrHost())));
        } else {
          loggers::get_instance().log_msg("sip_codec_request::encode_semi_colon_params: quotedString: ", v.quotedString());
          ::osip_generic_param_add(p_sip_list, (char*)static_cast<const char*>(param.id()), (char*)static_cast<const char*>(v.quotedString()));
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ private: //! \todo Move this section into a sip_codec_helper class, need to deco
  int encode_request_headers(const LibSip__SIPTypesAndValues::MessageHeader& p_msg_header, osip_message_t* p_sip_message);
  int encode_request_message_body(const LibSip__MessageBodyTypes::MessageBody& p_message_body, osip_message_t* p_sip_message);
  int encode_request_payload(const LibSip__SIPTypesAndValues::Payload& p_payload, osip_message_t* p_sip_message);
  int encode_c_seq_header(const LibSip__SIPTypesAndValues::CSeq& p_c_seq, osip_cseq_t** p_c_seq_header);
  int encode_from_header(const LibSip__SIPTypesAndValues::From& p_from, osip_from_t** p_from_header);
  int encode_max_forwards_header(const  OPTIONAL<LibSip__SIPTypesAndValues::MaxForwards>& p_max_forwards, osip_message_t** p_sip_message);
  int encode_supported_header(const  OPTIONAL<LibSip__SIPTypesAndValues::Supported>& p_supported, osip_message_t** p_sip_message);
+12 −8
Original line number Diff line number Diff line
@@ -3,18 +3,21 @@

LibCommon_Time.PX_TAC := 30.0

#LibItsHttp_Pics.PICS_HEADER_HOST := "location-information-service.azurewebsites.net"
LibItsHttp_Pics.PICS_HEADER_HOST := "ecrf-service.azurewebsites.net"
LibItsHttp_Pics.PICS_HEADER_HOST := "e4iutdpic5.execute-api.eu-central-1.amazonaws.com"
#LibItsHttp_Pics.PICS_HEADER_HOST := "ecrf-service.azurewebsites.net"
#LibItsHttp_Pics.PICS_HEADER_HOST := "ptsv2.com"

LibNg112_Pics.PICS_LIS_URI := "/Prod";
#LibNg112_Pics.PICS_ECRF_URI := "/api/lost";

LibItsHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/held+xml;charset=utf-8";
LibItsHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/lost+xml;charset=utf-8";
#LibItsHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/lost+xml;charset=utf-8";

#LibNg112_Pics.PICS_HTTP_GET_REQUEST := false

#LibNg112_Pixits.PX_DEVICE_URI_TEL := "<uri>+331234567890</uri>" # Position location
LibNg112_Pixits.PX_DEVICE_URI_TEL := "<uri>+331234567890</uri>" # Position location
#LibNg112_Pixits.PX_DEVICE_URI_TEL := "<uri>+331234567891</uri>" # Circle location
LibNg112_Pixits.PX_DEVICE_URI_TEL := "<uri>+331234567892</uri>" # Civic location
#LibNg112_Pixits.PX_DEVICE_URI_TEL := "<uri>+331234567892</uri>" # Civic location
LibNg112_Pixits.PX_DEVICE_NUMBER_POINT := { 43.616891, 7.053179 }
LibNg112_Pixits.PX_CIRCLE_POS := { 43.617174, 7.05275 }
LibNg112_Pixits.PX_CIRCLE_RADIUS := 15.000
@@ -36,7 +39,8 @@ LogEventTypes:= Yes
[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
#system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debug=1,server=location-information-service.azurewebsites.net,port=80,use_ssl=0)"
system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debug=1,server=ecrf-service.azurewebsites.net,port=80,use_ssl=0)"
system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debug=1,server=e4iutdpic5.execute-api.eu-central-1.amazonaws.com,use_ssl=1)"
#system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debug=1,server=www.googl.com,use_ssl=1)"
#system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debug=1,server=ptsv2.com,port=80,use_ssl=0)"

#system.SIPP.params := "SIP/UDP(dst_ip=192.168.1.250,dst_port=5060,src_ip=192.168.1.253,src_port=5060)/ETH(mac_src=080027d2b658,mac_dst=90fd61e61902,eth_type=0800)/PCAP(mac_src=080027d2b658,nic=eth1,filter=and udp port 12345)"
@@ -64,7 +68,7 @@ system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debu

[EXECUTE]
# In this section you can specify what parts of your test suite you want to execute.
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_01
AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_01
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_02
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_03
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_04
@@ -72,7 +76,7 @@ system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debu
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_06
#AtsNg112_TestCases.TC_LIS_HTTP_GET_BV_01
#AtsNg112_TestCases.TC_LIS_HTTP_GET_BV_02
AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_01
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_01

[GROUPS]
# In this section you can specify groups of hosts. These groups can be used inside the
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ module TestCodec_Register {
            if (match(v_enc_msg, v_raw_message)) {
              setverdict(pass, "Encoding match");
            } else {
              setverdict(pass, "Encoding mismatch");
              setverdict(fail, "Encoding mismatch");
            }
          } else {
            setverdict(fail, "Decoding mismatch");
+14 −14

File changed.

Contains only whitespace changes.

Loading