Commit 3c1c54db authored by Yann Garcia's avatar Yann Garcia
Browse files

Merge Framework woth NG112

parent 3ee46626
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -29,23 +29,6 @@ public: //! \publicsection
  static const std::string& mac_dst;               //! Destination MAC address parameter name
  static const std::string& mac_bc;                //! Broadcast MAC address parameter name
  static const std::string& eth_type;              //! Ethernet type parameter name
  static const std::string& beaconing;             //! Beaconing mode parameter name
  static const std::string& station_type;
  static const std::string& country;
  static const std::string& type_of_address;
  static const std::string& ssp;                   //! SSP parameter name
  static const std::string& its_aid;               //! ITS-AID parameter name
  static const std::string& gn_payload;            //! GeoNetworking Payload parameter name
  static const std::string& gn_next_header;        //! GeoNetworking NextHeader parameter name
  static const std::string& gn_header_type;        //! GeoNetworking HeaderType parameter name
  static const std::string& gn_header_sub_type;    //! GeoNetworking HeaderSubType parameter name
  static const std::string& gn_lifetime;           //! GeoNetworking Lifetime parameter name
  static const std::string& gn_traffic_class;      //! GeoNetworking Traffic class parameter name
  static const std::string& btp_type;              //! BTP Type parameter name
  static const std::string& btp_payload;           //! BTP Payload parameter name
  static const std::string& btp_destination_port;  //! BTP DestinationPort parameter name
  static const std::string& btp_info;              //! BTP Info parameter name

  static const std::string& nic;                   //! Network Interface Card parameter name
  static const std::string& ll_address;            //! Test system GeoNetworking LL-Address parameter name
  static const std::string& latitude;              //! Test system Latitude parameter name
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ const std::string& params::uri = std::string("uri");
const std::string& params::host = std::string("host");
const std::string& params::content_type = std::string("content_type");

const std::string& params::sip_url = std::string("sip_url");
const std::string& params::sip_version = std::string("sip_version");
const std::string& params::payload = std::string("payload");

const std::string& params::codecs = std::string("codecs");

void params::convert(params& p_param, const std::string p_parameters) {
+23 −9
Original line number Diff line number Diff line
@@ -80,11 +80,12 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
      response.statuscode() = std::stoi(m[3].str().c_str());
      response.statustext() = CHARSTRING(m[4].str().c_str());
      LibItsHttp__TypesAndValues::HeaderLines headers;
      decode_headers(decoding_buffer, headers);
      std::string content_type;
      decode_headers(decoding_buffer, headers, content_type);
      response.header() = headers;
      loggers::get_instance().log_to_hexa("Before decoding Body: ", decoding_buffer);
      LibItsHttp__MessageBodyTypes::HttpMessageBody body;
      if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
      if (decode_body(decoding_buffer, body, content_type) == -1) {
        response.body().set_to_omit();
      } else {
        response.body() = OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody>(body);
@@ -104,11 +105,12 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
      request.version__major() = std::stoi(m[3].str().c_str());
      request.version__minor() = std::stoi(m[4].str().c_str());
      LibItsHttp__TypesAndValues::HeaderLines headers;
      decode_headers(decoding_buffer, headers);
      std::string content_type;
      decode_headers(decoding_buffer, headers, content_type);
      request.header() = headers;
      OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody> body;
      body.set_to_omit();
      if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
      if (decode_body(decoding_buffer, body, content_type) == -1) {
        request.body().set_to_omit();
      } else {
        request.body() = body;
@@ -156,7 +158,7 @@ int http_codec::encode_request(const LibItsHttp__TypesAndValues::Request& p_requ
        if (v.size_of() > 0) {
          loggers::get_instance().log_msg("http_codec::encode_request: Processing value ", v[0]);
          if (std::string(static_cast<const char*>(header.header__name())).compare("Content-Type") == 0) { // Store it for HTTP body payload encoding
            loggers::get_instance().log("http_codec::encode_request: Storing Content-Yype");
            loggers::get_instance().log("http_codec::encode_request: Storing Content-Type");
            int j = 0;
            while (j < v.size_of()) {
              content_type += v[j++];
@@ -312,7 +314,7 @@ int http_codec::encode_response (const LibItsHttp__TypesAndValues::Response& p_r
  return 0;
}

int http_codec::decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers) {
int http_codec::decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers, std::string& p_content_type) {
  loggers::get_instance().log(">>> http_codec::decode_headers");
  loggers::get_instance().log_to_hexa("http_codec::decode_headers", decoding_buffer);

@@ -328,6 +330,14 @@ int http_codec::decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAn
            return -1;
          }
          headers[i++] = header;
          if (std::string(static_cast<const char*>(header.header__name())).compare("Content-Type") == 0) {
            if (header.header__value().is_present() != 0) {
              const PreGenRecordOf::PREGEN__RECORD__OF__CHARSTRING& l = static_cast<const PreGenRecordOf::PREGEN__RECORD__OF__CHARSTRING&>(*header.header__value().get_opt_value());
              p_content_type = static_cast<const char*>(l[0]);
            } else {
              p_content_type = "";
            }
          }
        }
        break;
      case 1:
@@ -472,7 +482,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
  OCTETSTRING s(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos());
  loggers::get_instance().log_msg("http_codec::decode_body: raw body=", s);
  
  // Align the payload length with the specified Content-lenght value
  // Align the payload length with the specified Content-Lenght value
  loggers::get_instance().log("http_codec::decode_body: _dc.length=%d - body length=%d", _dc.length, s.lengthof());
  OCTETSTRING body;
  if (_dc.length != 0) {
@@ -496,6 +506,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
    }
  }
  loggers::get_instance().log("http_codec::decode_body: counter=%d", counter);
  loggers::get_instance().log("http_codec::decode_body: body length=%d", body.lengthof());
  body = OCTETSTRING(body.lengthof() - counter, static_cast<const unsigned char*>(body));
  if (_dc.chunked){
    counter = 0;
@@ -593,7 +604,10 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
       loggers::get_instance().log("http_codec::decode_body: Find xml message");
       LibItsHttp__XmlMessageBodyTypes::XmlBody xml_body;
       // 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["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:geopriv:held\"") != std::string::npos) {
       if (
           (p["decode_str"].find("=\"urn:ietf:params:xml:ns:geopriv:held\"") != std::string::npos) ||
           (p["decode_str"].find("=\"urn:ietf:params:xml:ns:pidf\"") != std::string::npos)
           ) {
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:geopriv:held'");
         if (_codecs["held"].get() != nullptr) {
           loggers::get_instance().log("http_codec::decode_body: Call 'held_codec'");
@@ -609,7 +623,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
           xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
         }
         message_body.xml__body() = xml_body;
       } else if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:lost1\"") != std::string::npos) {
       } else if (p["decode_str"].find("=\"urn:ietf:params:xml:ns:lost1\"") != std::string::npos) {
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:lost1'");
         if (_codecs["lost"].get() != nullptr) {
           loggers::get_instance().log("http_codec::decode_body: Call 'lost_codec'");
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ private:
  int encode_response (const LibItsHttp__TypesAndValues::Response& p_response, TTCN_Buffer& p_encoding_buffer);
  int encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody& p_message_body, OCTETSTRING& p_encoding_buffer, const std::string& p_content_type);

  int decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers);
  int decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers, std::string& p_content_type);
  int decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValues::HeaderLine& header);
  int decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body, const std::string& p_content_type);
  int get_line(TTCN_Buffer& buffer, CHARSTRING& to, const bool concatenate_header_lines = false);
+2 −2
Original line number Diff line number Diff line
@@ -171,9 +171,9 @@ void* pcap_offline_layer::thread() {
      if(lh.ts.tv_sec|lh.ts.tv_usec){
        long diff = timeval_diff(pkt_header->ts, lh.ts);
        if(diff > 0) {
//          fprintf(stderr,"<<< pcap_offline_layer::run: Wait %d msec", diff);
          loggers::get_instance().log("<<< pcap_offline_layer::run: Wait %d msec", diff);
          std::this_thread::sleep_for(std::chrono::milliseconds(diff));
//          fprintf(stderr,"<<< pcap_offline_layer::run: Wait done");
          loggers::get_instance().log("<<< pcap_offline_layer::run: Wait done");
        }
      }
    }
Loading