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

Debugging sctp_offline_layer

parent 3233becf
Loading
Loading
Loading
Loading
+22 −2
Changes for ccsrc/Protocols/Sctp/sctp_offline_layer.cc: 22 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ sctp_offline_layer::sctp_offline_layer(const std::string& p_type, const std::str
  : layer(p_type), _params(), _time_key("sctp_offline_layer::Handle_Fd_Event_Readable") {
  loggers::get_instance().log(">>> sctp_offline_layer::sctp_offline_layer: '%s', %s", p_type.c_str(), param.c_str());
  params::convert(_params, param);
  _fragments = OCTETSTRING(0, nullptr);

  _o_params.insert(std::pair<std::string, std::string>(std::string("timestamp"), std::string()));

@@ -89,10 +90,11 @@ void sctp_offline_layer::receive_data(OCTETSTRING &p_data, params &p_params) {
    OCTETSTRING next_chunk(0, nullptr);
    process_chunk(chunk, p_params, payload, next_chunk);
    if (payload.lengthof() == 0) {
      // No user message (control chunk, or a fragment kept for reassembly): go on with the next chunks
      loggers::get_instance().log("sctp_offline_layer::receive_data: Empty payload, skip it");
      return;
    }
    } else {
      receive_to_all_layers(payload, p_params);
    }
    chunk = next_chunk;
  } while (chunk.lengthof() > 0);

@@ -152,6 +154,24 @@ void sctp_offline_layer::process_chunk(const OCTETSTRING& p_chunk, params &p_par
        } else {
          p_next_chunk = OCTETSTRING(0, nullptr);
        }
        // Fragmented user message (RFC 9260 clause 3.3.1): B (0x02) on the first fragment, E (0x01) on the last one,
        // both on an unfragmented message. Fragments are kept until the last one, then the whole message is delivered
        const uint8_t flags = static_cast<const uint8_t*>(p_chunk)[1] & 0x03;
        if (flags != 0x03) {
          if (flags & 0x02) {
            _fragments = p_payload;
          } else {
            _fragments = _fragments + p_payload;
          }
          if (flags & 0x01) {
            p_payload  = _fragments;
            _fragments = OCTETSTRING(0, nullptr);
            loggers::get_instance().log("sctp_offline_layer::process_chunk: Reassembled user message: %d bytes", p_payload.lengthof());
          } else {
            loggers::get_instance().log("sctp_offline_layer::process_chunk: Fragment kept (flags %02x), %d bytes so far", flags, _fragments.lengthof());
            p_payload = OCTETSTRING(0, nullptr);
          }
        }
      }
      break;
    case 0x01: // INIT chunk
+1
Changes for ccsrc/Protocols/Sctp/sctp_offline_layer.hh: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ class sctp_offline_layer : public layer {

  params      _o_params;
  OCTETSTRING _o_data;
  OCTETSTRING _fragments; //! User message being reassembled from DATA chunk fragments (B/E flags, RFC 9260 clause 3.3.1)

  std::string _time_key;