Commit 25c6ae9e authored by Yann Garcia's avatar Yann Garcia
Browse files

Bug fixed in Http/Held codec

parent efbfdc03
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
 * \brief This class provides time tools such as getting current time
 */
class base_time {
  const unsigned long long its_base_time = 1072915200000L; //! Base time 01/01/2004 12:00am in millseconds
  const unsigned long long its_base_time_ms = 1072915200000L; //! Base time 01/01/2004 12:00am in millseconds
  
  static base_time* _instance;
private:
@@ -28,9 +28,11 @@ public:
  virtual ~base_time() { if (_instance != nullptr) delete _instance; };
  
public:
  inline const unsigned long long get_current_time() const;
  inline const unsigned long long get_its_base_time() const;
  inline const unsigned long long get_its_current_time() const;
  inline const unsigned long long get_current_time_ms() const;
  inline const unsigned long long get_its_base_time_ms() const;
  inline const unsigned long long get_its_current_time_ms() const;
  inline const unsigned long long get_its_current_time_us() const;
  inline const unsigned long long get_its_current_time_mod_ms() const;
}; // End of class base_time

// static functions
@@ -38,14 +40,23 @@ base_time& base_time::get_instance() {
  return (_instance != nullptr) ? *_instance : *(_instance = new base_time());
}

const unsigned long long base_time::get_current_time() const {
const unsigned long long base_time::get_current_time_ms() const {
  return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}

const unsigned long long base_time::get_its_base_time() const {
  return base_time::its_base_time;
const unsigned long long base_time::get_its_base_time_ms() const {
  return base_time::its_base_time_ms;
}

const unsigned long long base_time::get_its_current_time() const {
  return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time;
const unsigned long long base_time::get_its_current_time_ms() const {
  return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time_ms;
}

const unsigned long long base_time::get_its_current_time_us() const {
  return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time_ms * 1000;
}

const unsigned long long base_time::get_its_current_time_mod_ms() const {
  return (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time_ms) % 65536;
}
+113 −5
Original line number Diff line number Diff line
@@ -182,6 +182,14 @@ int sip_codec_headers::encode_headers(const LibSip__SIPTypesAndValues::MessageHe
    }
  }

  // GeolocationRouting
  if (p_msg_header.geolocationRouting().is_present()) {
    if (encode_geolocation_routing_header(p_msg_header.geolocationRouting(), &p_sip_message) == -1) {
      loggers::get_instance().warning("sip_codec_headers::encode_headers: Failed to encode GeolocationRouting header");
      return -1;
    }
  }

  // MaxForwards
  if (p_msg_header.maxForwards().is_present()) {
    if (encode_max_forwards_header(p_msg_header.maxForwards(), &p_sip_message) == -1) {
@@ -444,7 +452,14 @@ void sip_codec_headers::decode_headers(const osip_message_t* p_sip_message, LibS
    p_headers.geolocation().set_to_omit();
  }

  LibSip__SIPTypesAndValues::GeolocationRouting geolocation_routing_header;
  decode_geolocation_routing_header(p_sip_message, geolocation_routing_header);
  if (geolocation_routing_header.is_value()) {
    p_headers.geolocationRouting() = geolocation_routing_header;
  } else {
    p_headers.geolocationRouting().set_to_omit();
  }

  p_headers.historyInfo().set_to_omit();
  p_headers.infoPackage().set_to_omit();
  p_headers.inReplyTo().set_to_omit();
@@ -1129,11 +1144,51 @@ int sip_codec_headers::encode_geolocation_header(const OPTIONAL<LibSip__SIPTypes
      i += 1;
    } while (i < l.lengthof());
  }
  loggers::get_instance().log("sip_codec_headers::encode_geolocation_header: %s", value.c_str());
  ::osip_message_set_header((osip_message_t *)*p_sip_message,(const char *)"Geolocation", value.c_str());

  return 0;
}

int sip_codec_headers::encode_geolocation_routing_header(const OPTIONAL<LibSip__SIPTypesAndValues::GeolocationRouting>& p_geolocation_routing, osip_message_t** p_sip_message) {
  loggers::get_instance().log(">>> sip_codec_headers::encode_geolocation_routing_header");

  if (!p_geolocation_routing.is_present()) {
    return 0;
  }
  const LibSip__SIPTypesAndValues::GeolocationRouting& geolocation_routing = static_cast<const LibSip__SIPTypesAndValues::GeolocationRouting&>(*p_geolocation_routing.get_opt_value());
  std::string value;
  if (geolocation_routing.state() == LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__YES__E) {
    value = "yes";
  } else if (geolocation_routing.state() == LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__NO__E) {
    value = "no";
  } else {
    value = "other";
  }
  loggers::get_instance().log("sip_codec_headers::encode_geolocation_routing_header: state: %s", value.c_str());
  // genericValue
  const OPTIONAL<LibSip__Common::GenericParam>& generic_value = geolocation_routing.genericValue();
  if (generic_value.is_present()) {
    const LibSip__Common::GenericParam& g = static_cast<const LibSip__Common::GenericParam&>(*geolocation_routing.genericValue().get_opt_value());
    value += ";";
    value += static_cast<const char*>(g.id());
    if (g.paramValue().is_present()) {
      value += "=";
      const LibSip__Common::GenValue& v = static_cast<const LibSip__Common::GenValue&>(*g.paramValue().get_opt_value());
      if (v.ischosen(LibSip__Common::GenValue::ALT_tokenOrHost)) {
        value += static_cast<const char*>(v.tokenOrHost());
      } else {
        value += static_cast<const char*>(v.quotedString());
      }
    }
  }
  
  loggers::get_instance().log("sip_codec_headers::encode_geolocation_routing_header: %s", value.c_str());
  ::osip_message_set_header((osip_message_t *)*p_sip_message,(const char *)"Geolocation-Routing", value.c_str());

  return 0;
}

int sip_codec_headers::encode_max_forwards_header(const OPTIONAL<LibSip__SIPTypesAndValues::MaxForwards>& p_max_forwards, osip_message_t** p_sip_message) {
  loggers::get_instance().log(">>> sip_codec_headers::encode_max_forwards_header");

@@ -2464,6 +2519,59 @@ void sip_codec_headers::decode_geolocation_header(const osip_message_t* p_sip_me
  }
} // End of method decode_geolocation_header

void sip_codec_headers::decode_geolocation_routing_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::GeolocationRouting& p_geolocation_routing_header)
{
  loggers::get_instance().log("sip_codec_headers::decode_geolocation_routing_header");

  // Sanity checks
  osip_header_t *dest = nullptr;
  ::osip_message_header_get_byname(p_sip_message, (const char *)"geolocation-routing", 0, &dest); // TODO Create osip_message_[g|s]et_geolocation_routing
  if (dest == nullptr) {
    loggers::get_instance().warning("sip_codec_headers::decode_geolocation_routing_header: Not found");
    return;
  }
  loggers::get_instance().log("sip_codec_headers::decode_geolocation_routing_header: hname='%s' : hvalue='%s'\n", dest->hname, dest->hvalue);

  // FieldName
  p_geolocation_routing_header.fieldName() = LibSip__SIPTypesAndValues::FieldName(LibSip__SIPTypesAndValues::FieldName::str_to_enum("GEOLOCATION_ROUTING_E"));
  std::string str(dest->hvalue);
  size_t pos = str.find(";");
  if (pos == std::string::npos) {
    if (str.compare("yes") == 0) {
      p_geolocation_routing_header.state() = LibSip__SIPTypesAndValues::GeolocationRoutingState(LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__YES__E);
    } else if (str.compare("no") == 0) {
      p_geolocation_routing_header.state() = LibSip__SIPTypesAndValues::GeolocationRoutingState(LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__NO__E);
    } else {
      p_geolocation_routing_header.state() = LibSip__SIPTypesAndValues::GeolocationRoutingState(LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__OTHER__E);
    }
    p_geolocation_routing_header.genericValue().set_to_omit();
  } else {
    std::string s = str.substr(0, pos - 1);
    loggers::get_instance().log("sip_codec_headers::decode_geolocation_routing_header: s='%s'\n", s.c_str());
    if (s.compare("yes") == 0) {
      p_geolocation_routing_header.state() = LibSip__SIPTypesAndValues::GeolocationRoutingState(LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__YES__E);
    } else if (s.compare("no") == 0) {
      p_geolocation_routing_header.state() = LibSip__SIPTypesAndValues::GeolocationRoutingState(LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__NO__E);
    } else {
      p_geolocation_routing_header.state() = LibSip__SIPTypesAndValues::GeolocationRoutingState(LibSip__SIPTypesAndValues::GeolocationRoutingState::GEOLOCATION__ROUTING__OTHER__E);
    }
    str = str.substr(pos + 1);
    LibSip__Common::GenericParam p;
    pos = str.find("=");
    if (pos != std::string::npos) {
      p.id() = CHARSTRING(str.substr(0, pos - 1).c_str());
      LibSip__Common::GenValue v;
      v.quotedString() = CHARSTRING(str.substr(pos + 1).c_str());
      p.paramValue() = OPTIONAL<LibSip__Common::GenValue>(v);
    } else {
      p.id() = CHARSTRING(str.c_str());
      p.paramValue().set_to_omit();
    }
    loggers::get_instance().log("sip_codec_headers::decode_geolocation_routing_header: genericValue='%s'\n", str.c_str());
    p_geolocation_routing_header.genericValue() = OPTIONAL<LibSip__Common::GenericParam>(p);
  }
}

void sip_codec_headers::decode_max_forwards_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::MaxForwards& p_max_forwards_header)
{
  loggers::get_instance().log("sip_codec_headers::decode_max_forwards_header");
+4 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ namespace LibSip__SIPTypesAndValues {
  class ContentType;
  class CSeq;
  class From;
  class Geolocation;
  class GeolocationRouting;
  class HostPort;
  class MessageHeader;
  class PreGenRecordOf;
@@ -52,6 +54,7 @@ public:
  virtual int encode_c_seq_header(const LibSip__SIPTypesAndValues::CSeq& p_c_seq, osip_cseq_t** p_c_seq_header);
  virtual int encode_from_header(const LibSip__SIPTypesAndValues::From& p_from, osip_from_t** p_from_header);
  virtual int encode_geolocation_header(const OPTIONAL<LibSip__SIPTypesAndValues::Geolocation>& p_geolocation, osip_message_t** p_sip_message);
  virtual int encode_geolocation_routing_header(const OPTIONAL<LibSip__SIPTypesAndValues::GeolocationRouting>& p_geolocation, osip_message_t** p_sip_message);
  virtual int encode_max_forwards_header(const OPTIONAL<LibSip__SIPTypesAndValues::MaxForwards>& p_max_forwards, osip_message_t** p_sip_message);
  virtual int encode_min_se_header(const OPTIONAL<LibSip__SIPTypesAndValues::MinSE>& p_min_se, osip_message_t** p_sip_message);
  virtual int encode_p_access_network_info_header(const OPTIONAL<LibSip__SIPTypesAndValues::PAccessNetworkInfo>& p_p_access_network_info_header, osip_message_t** p_sip_message);
@@ -86,6 +89,7 @@ public:
  virtual void decode_contact_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Contact& p_contact_header);
  virtual void decode_from_header(const osip_from_t* p_sip_from, LibSip__SIPTypesAndValues::From& p_from_header);
  virtual void decode_geolocation_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Geolocation& p_geolocation_header);
  virtual void decode_geolocation_routing_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::GeolocationRouting& p_geolocation_routing_header);
  virtual void decode_max_forwards_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::MaxForwards& p_max_forwards_header);
  virtual void decode_min_se_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::MinSE& p_min_se_header);
  virtual void decode_p_access_network_info_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::PAccessNetworkInfo& p_p_access_network_info_header);
+165 −0
Original line number Diff line number Diff line
[MODULE_PARAMETERS]
# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.

# IUT roles
LibNg112_Pics.PICS_LIS_IUT  := false;
LibNg112_Pics.PICS_ECRF_IUT := false;
LibNg112_Pics.PICS_ESRP_IUT := false;
LibNg112_Pics.PICS_PSAP_IUT := true;

LibCommon_Time.PX_TAC := 30.0
LibCommon_Sync.PX_TSYNC_TIME_LIMIT := 30.0;
LibCommon_Sync.PX_TSHUT_DOWN_TIME_LIMIT := 30.0;

LibItsHttp_Pics.PICS_HEADER_HOST := "lis.gridgears.io" # Used for LIS
#LibItsHttp_Pics.PICS_HEADER_HOST := "ecrf.gridgears.io" # Used for ECRF

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

#LibNg112_Pics.PICS_HTTP_GET_REQUEST := false
#LibNg112_Pics.PICS_HTTP_POST_REQUEST := false

# LIS SIP
LibSip_PIXITS.PX_SIP_REGISTRATION := true;
#LibSip_PIXITS.PX_SEED             := true;

LibNg112_Pixits.PX_IMS_SUT_UE_IPADDR         := "10.100.60.1" # UE IP address to exchange SIP messages - connection point for PCSCF

LibNg112_Pixits.PX_IMS_TS_UE1_IPADDR         := "10.100.60.2" # Local UE address used for From header
LibNg112_Pixits.PX_IMS_SUT_UE1_BEARER_IPADDR := "10.100.60.1" # Local UE address used for SDP connection attrubute

#LibNg112_Pics.PICS_S_SIP_TCP1                 := true       # Set to true when using SIP over TCP ==> change SIP ports configuration
#LibNg112_Pics.PICS_S_SIP_UDP1                 := false
#LibSip_PIXITS.PX_SIP_TRANSPORT                := "TCP"     # Transport is TCP
#LibNg112_Pixits.PX_IMS_TS_UE1_PORT            := 5052  # SIP over TCP port
LibNg112_Pixits.PX_IMS_SUT_UE1_PUBLIC_USER     := "8007"
LibNg112_Pixits.PX_IMS_SUT_UE1_HOME_DOMAIN     := "huawei.com"
LibNg112_Pixits.PX_IMS_SUT_UE1_REGISTRAR       := "huawei.com"
LibNg112_Pixits.PX_IMS_SUT_UE1_PUBLIC_USER     := "8007"
LibNg112_Pixits.PX_IMS_SUT_UE1_PRIVAT_USERNAME := "8007";
LibNg112_Pixits.PX_IMS_SUT_UE1_PRIVAT_PASSWD   := "Huawei@123"

[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).

LogFile := "../logs/%e.%h-%r.%s"
FileMask := LOG_ALL | USER | DEBUG | MATCHING
ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING
#FileMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP
#ConsoleMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP
LogSourceInfo := Stack
LogEntityName:= Yes
LogEventTypes:= Yes
#TimeStampFormat := DateTime

[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.

# LIS/ECRF
system.httpPort.params := "HTTP(codecs=lost:lost_codec;held:held_codec)/TCP(debug=1,server=lis.gridgears.io,use_ssl=1)"

# SIP/PSAP
Caller.SIPP.params := "SIP/UDP(dst_ip=10.100.2.61,dst_port=5060,src_port=5060)"
CallTaker.SIPP.params := "SIP/UDP(dst_ip=10.100.2.61,dst_port=5060,src_port=5061)"

[DEFINE]
# In this section you can create macro definitions,
# that can be used in other configuration file sections except [INCLUDE] and [ORDERED_INCLUDE].

[INCLUDE]
# To use configuration settings given in other configuration files,
# the configuration files just need to be listed in this section, with their full or relative pathnames.

[ORDERED_INCLUDE]
# To use configuration settings given in other configuration files,
# the configuration files just need to be listed in this section, with their full or relative pathnames.

[EXTERNAL_COMMANDS]
# This section can define external commands (shell scripts) to be executed by the ETS
# whenever a control part or test case is started or terminated.

#BeginTestCase := ""
#EndTestCase := ""
#BeginControlPart := ""
#EndControlPart := ""

[EXECUTE]
# In this section you can specify what parts of your test suite you want to execute.
AtsNg112_TestControl.control

# "IUT successfully responds with a Point when it receives a HTTP POST location request without location type"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_01
# "IUT successfully responds with a Circle when it receives a HTTP POST location request without location type"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_02
# "IUT successfully responds with a reference when it receives a HTTP POST location request with location type locationURI and exact attribute"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_03
# "IUT successfully responds with a reference and geodetic location when it receives a HTTP POST location request with location types locationURI and geodetic and exact attribute"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_04
# "IUT successfully responds with an error response when it receives a HTTP POST location request for an unknown device"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_05
# "IUT successfully responds with a CIVIC address when it receives a HTTP POST location request without location type"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_06
# "IUT successfully responds with an error response when it receives a HTTP POST location request with an unknown location type"
#AtsNg112_TestCases.TC_LIS_HTTP_POST_BV_07
# "IUT successfully returns the location when a locationURI is dereferenced"
#AtsNg112_TestCases.TC_LIS_HTTP_GET_BV_01
# "IUT returns HTTP error 404 if it does not support HTTP GET method"
#AtsNg112_TestCases.TC_LIS_HTTP_GET_BV_02
# "IUT successfully responds with a service URI for a Point in the service boundary"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_01
# "IUT successfully responds with a service URI for a Circle in the service boundary"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_02
# "IUT successfully responds with an error response for an unknown Service URN in the service boundary"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_03
# "IUT successfully responds with an error response for an unrecognized location profile"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_04
# "IUT successfully responds with service boundary by value if requested"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_05
# "IUT successfully responds with service URI for a Circle that intersects service boundary"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_06
# "IUT successfully responds with a service URI for a Circle that intersects multiple service boundaries"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_07
# "IUT successfully responds with a service URI for a Circle in the service boundary with multiple services"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_08
# "IUT successfully responds with configured service types for a ListServices request"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_09
# "IUT successfully responds with configured service types for a ListServicesByLocation request"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_10
# "IUT successfully responds with configured service types for a ListServices request without service element"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_11
# "IUT successfully responds with configured service types for a ListServicesByLocation request without service element"
#AtsNg112_TestCases.TC_ECRF_HTTP_POST_BV_12
# "IUT successfully forwards an incoming SIP INVITE to the correct downstream element, based on the ECRF response"
#AtsNg112_TestCases.TC_ESRP_SIP_INVITE_BV_01
# "IUT successfully handles SIP INVITE with service urn and ULAW via UDP"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_01
# "IUT successfully handles SIP INVITE with service urn and ULAW via UDP"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_02
# "IUT successfully handles SIP INVITE with service urn via TCP"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_03
# "IUT successfully handles SIP INVITE with SDP and PIDF-LO content"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_04
# "IUT successfully handles SIP INVITE without service URN"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_05
# "IUT successfully handles an incoming SIP BYE"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_06
# "IUT successfully handles an incoming SIP MESSAGE"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_07
# "IUT successfully handles an incoming SIP OPTION"
#AtsNg112_TestCases.TC_PSAP_SIP_INVITE_BV_08

[GROUPS]
# In this section you can specify groups of hosts. These groups can be used inside the
# [COMPONENTS] section to restrict the creation of certain PTCs to a given set of hosts.

[COMPONENTS]
# This section consists of rules restricting the location of created PTCs.

[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
KillTimer := 10.0
LocalAddress := 127.0.0.1
TCPPort := 12000
NumHCs := 1
+140 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading