Commit bea78502 authored by Yann Garcia's avatar Yann Garcia
Browse files

Implement ESRP skeleton

parent c8dcec8a
Loading
Loading
Loading
Loading
+26 −9
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
      response.header() = headers;
      loggers::get_instance().log_to_hexa("Before decoding Body: ", decoding_buffer);
      LibItsHttp__MessageBodyTypes::HttpMessageBody body;
      if (decode_body(decoding_buffer, body) == -1) {
      if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
        response.body().set_to_omit();
      } else {
        response.body() = OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody>(body);
@@ -106,7 +106,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
      request.header() = headers;
      OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody> body;
      body.set_to_omit();
      if (decode_body(decoding_buffer, body) == -1) {
      if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
        request.body().set_to_omit();
      } else {
        request.body() = body;
@@ -389,11 +389,13 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
    } else {
      std::map<std::string, std::unique_ptr<codec<Record_Type, Record_Type> > >::const_iterator it;
      bool processed = false;
      loggers::get_instance().log("http_codec::encode_body: # of codecs=%d - %p", _codecs.size(), this);
      if (p_content_type.find("x-its") != std::string::npos) {
        loggers::get_instance().log("http_codec::encode_body: Find x-its");
        it = _codecs.find("http_its"); // TODO Use params
        if (it != _codecs.cend()) {
          loggers::get_instance().log("http_codec::encode_body: Call 'http_etsi_ieee1609dot2_codec'");
          _codecs["http_its"]->encode((Record_Type&)binary_body, p_encoding_buffer); // TODO Use params
          _codecs["http_its"]->encode((Record_Type&)binary_body.ieee1609dot2__data(), p_encoding_buffer); // TODO Use params
          processed = true;
        }
      } // TODO Add new HTTP message codec here
@@ -446,10 +448,10 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
  return 0;
}

int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body) {
int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body, const std::string& p_content_type) {
  loggers::get_instance().log(">>> http_codec::decode_body");
  loggers::get_instance().log_to_hexa("http_codec::decode_body", decoding_buffer);
  loggers::get_instance().log("http_codec::decode_body: # of codecs=%d", _codecs.size());
  loggers::get_instance().log("http_codec::decode_body: Content-Type=%s", p_content_type.c_str());

  // Sanity check
  if (decoding_buffer.get_len() - decoding_buffer.get_pos() <= 0) {
@@ -496,9 +498,24 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
  loggers::get_instance().log("http_codec::decode_body: Binary mode: %x", _dc.is_binary);
  LibItsHttp__MessageBodyTypes::HttpMessageBody v;
  if (_dc.is_binary == 0x01) {
    LibItsHttp__BinaryMessageBodyTypes::BinaryBody bb;
    bb.raw() = body;
    message_body.binary__body() = bb;
    LibItsHttp__BinaryMessageBodyTypes::BinaryBody binary_body;
    bool processed = false;
    // TODO To be refined adding a string identifier to check which codec to use. E.g. held_code.id() returns "xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">"
    if (p_content_type.find("x-its") != std::string::npos) {
      loggers::get_instance().log("http_codec::decode_body: Find 'x-its'");
      if (_codecs["http_its"].get() != nullptr) {
        loggers::get_instance().log("http_codec::decode_body: Call 'http_etsi_ieee1609dot2_codec'");
        if (_codecs["http_its"]->decode(body, binary_body.ieee1609dot2__data()) == 0) {
        message_body.binary__body() = binary_body;
        processed = true;
      }
      delete codec;
    } // TODO Add new HTTP message codec here
    if (!processed) {
      loggers::get_instance().warning("http_codec::decode_body: Unsupported HTTP codec, use raw field as default");
      binary_body.raw() = body;
      message_body.binary__body() = binary_body;
    }
  } else {
    // Convert into string
    params p;
@@ -525,7 +542,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
         }
         message_body.xml__body() = xml_body;
       } else if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:lost1\">") != std::string::npos) {
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:lost1'");
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:loat1'");
         if (_codecs["lost"].get() != nullptr) {
           loggers::get_instance().log("http_codec::decode_body: Call 'lost_codec'");
           if (_codecs["lost"]->decode(body, (Record_Type&)xml_body, &p) == -1) {
+1 −1
Original line number Diff line number Diff line
@@ -936,7 +936,7 @@ Expected behaviour
                    xmlMessage containing
                        version indicating value "1.0",
                        element "listServices" inNamespace "urn:ietf:params:xml:ns:lost1" containing
                            element "service" indicating value "urn:service:sos"
                            element "service" indicating value o
                        ;
                    ;
                ;
+87 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ module AtsNg112_TestCases {
  import from LibItsHttp_TestSystem all;
  
  // LibSip
  import from LibSip_SIPTypesAndValues all;
  import from LibSip_Templates all;
  import from LibSip_Interface all;
  
  // LibNg112
@@ -1850,4 +1852,89 @@ module AtsNg112_TestCases {
    
  } // End of group ecrf_role
  
  group esrp_role {
    
    /**
     * @desc "IUT successfully forwards an incoming SIP INVITE to the correct downstream element, based on the ECRF response" 
     */
    testcase TC_ESRP_SIP_INVITE_BV_01() runs on HttpSipComponent system TestAdapter {
        // Local variables
        var HttpComponent v_ecrf;
        var SipComponent v_psap;
        var CSeq v_cSeq_s := valueof(m_cSeq(1, "INVITE"));
        
        // Test control
        if (not(PICS_ESRP_IUT) or (not PICS_HTTP_POST_REQUEST) or (not PICS_SERVICE_LOST) or not(PICS_E_SIP_URN1) or not(PICS_L_FIS_GEO1)) {
          log("*** " & testcasename() & ": PICS_ESRP_IUT and PICS_HTTP_POST_REQUEST and PICS_SERVICE_LOST and PICS_E_SIP_URN1 and PICS_L_FIS_GEO1 required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        f_cf_02_up(v_ecrf, v_psap);
        
        // Test adapter configuration
        
        // Preamble
        
        // Test Body
        v_ecrf.start(f_TC_ESRP_SIP_INVITE_BV_01_ecrf());
        v_psap.start(f_TC_ESRP_SIP_INVITE_BV_01_psap(v_cSeq_s));
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
        
        // Postamble
        f_cf_02_down(v_ecrf, v_psap);
      
    } // End of testcase TC_ESRP_SIP_INVITE_BV_01
    
    group f_TC_ESRP_SIP_INVITE_BV_01 {
      
      function f_TC_ESRP_SIP_INVITE_BV_01_ecrf() runs on HttpComponent {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;
        
        // Test control
        
        // Test component configuration
        
        // Test adapter configuration
        
        // Preamble
        f_init_default_headers_list(v_headers);
        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
        
        // test body
        
        // Postamble
        
      } // End of function f_TC_ESRP_SIP_INVITE_BV_01_ecrf
      
      function f_TC_ESRP_SIP_INVITE_BV_01_psap(
                                               in CSeq p_cSeq_s
                                               ) runs on SipComponent {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;
        
        // Test control
        
        // Test component configuration
        
        // Test adapter configuration
        
        // Preamble
        f_incCSeq(p_cSeq_s);
        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
        
        // test body
        
        // Postamble
        
      } // End of function f_TC_ESRP_SIP_INVITE_BV_01_psap
      
    } // End of group f_TC_ESRP_SIP_INVITE_BV_01 
    
  } // End of group esrp_role
  
} // End of module AtsNg112_TestCases 
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ module AtsNg112_TestControl {
          if (PICS_L_FIS_GEO1) { execute(TC_ECRF_HTTP_POST_BV_11()); }
        }
      }
      if (PICS_ESRP_IUT) {
        if (PICS_HTTP_POST_REQUEST and PICS_SERVICE_LOST and PICS_E_SIP_URN1) {
          if (PICS_L_FIS_GEO1) { execute(TC_ESRP_SIP_INVITE_BV_01()); }
        }
      }
    } // End of 'control' statement
    
} // End of module AtsNg112_TestControl 
+47 −1
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@ module LibNg112_Functions {
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
    
    // LibSip
    import from LibSip_SIPTypesAndValues all;
    import from LibSip_Interface all;
    
    // LibHttp
    import from LibItsHttp_TypesAndValues all;
    import from LibItsHttp_Templates all;
@@ -31,6 +35,20 @@ module LibNg112_Functions {
          
      } // End of function f_cf_01_http_up
      
      function f_cf_02_up(
                          out HttpComponent p_ecrf,
                          out SipComponent p_psap
                          ) runs on HttpSipComponent {
        p_ecrf := HttpComponent.create alive;
        p_psap := SipComponent.create alive;
        
        connect(p_ecrf:syncPort, self:syncPort);
        connect(p_psap:syncPort, self:syncPort);
        map(p_ecrf:httpPort, system:httpPort);
        map(p_psap:SIPP, system:SIPP);
        
      } // End of function f_cf_02_up
      
      /**
       * @desc Default handling cf01 de-initialisation.
       */
@@ -57,8 +75,36 @@ module LibNg112_Functions {
          deactivate;
      } // End of function f_cf_01_http_down
      
      function f_cf_02_down(
                            inout HttpComponent p_ecrf,
                            inout SipComponent p_psap
                            ) runs on HttpSipComponent {
        
        disconnect(p_ecrf:syncPort, self:syncPort);
        disconnect(p_psap:syncPort, self:syncPort);
        unmap(p_ecrf:httpPort, system:httpPort);
        unmap(p_psap:SIPP, system:SIPP);
        
        p_ecrf.done;
        p_psap.done;
        
        deactivate;
      } // End of function f_cf_02_down
      
    } // End of group postambles
    
    /**
     * @desc f_IncCSeq returns an input parameter incremented by 1000
     * reason is to run the next testcase with a higher CSeq value
     */
    function f_incCSeq(
                       inout CSeq loc_CSeq
    ) {
      loc_CSeq.seqNumber := loc_CSeq.seqNumber + 1000;
      return
    } // End of function f_incCSeq
    

    group altsteps {

      altstep a_default_requests() runs on HttpComponent {
Loading