Loading ccsrc/Framework/Codec.hh +5 −2 Original line number Diff line number Diff line Loading @@ -10,11 +10,14 @@ class BITSTRING; template<typename TPDUEnc, typename TPDUDec> class Codec { protected: Params* _params; public: Codec() { loggers::get_instance().log("Codec::Codec"); }; Codec() : _params(NULL) { loggers::get_instance().log("Codec::Codec"); }; virtual ~Codec() { loggers::get_instance().log("Codec::~Codec"); }; virtual int encode(const TPDUEnc& msg, OCTETSTRING& data) = 0; virtual int decode(const OCTETSTRING& data, TPDUDec& msg, Params* param = NULL) = 0; virtual int decode(const OCTETSTRING& data, TPDUDec& msg, Params* params = NULL) = 0; }; template<typename TPDU> class PERCodec Loading ccsrc/Framework/Params.hh +8 −1 Original line number Diff line number Diff line Loading @@ -10,15 +10,22 @@ public: static const std::string& ssp; static const std::string& its_aid; static const std::string& gn_payload; static const std::string& gn_next_header; static const std::string& gn_header_type; static const std::string& gn_header_sub_type; static const std::string& gn_lifetime; static const std::string& gn_traffic_class; static const std::string& btp_type; static const std::string& btp_payload; static const std::vector<unsigned char>& mac_address; static const std::string& btp_destination_port; static const std::string& btp_info; Params() : std::map<std::string, std::string>() {}; Params(const Params& p_params) : std::map<std::string, std::string>(p_params.begin(), p_params.end()) {}; virtual ~Params() {}; void log(); void reset(); static void convert(Params& p_param, const std::string p_parameters); }; ccsrc/Framework/src/Params.cc +37 −24 Original line number Diff line number Diff line Loading @@ -9,9 +9,15 @@ const std::string& Params::mac_dst = std::string("mac_dst"); const std::string& Params::its_aid = std::string("its_aid"); const std::string& Params::ssp = std::string("ssp"); const std::string& Params::gn_payload = std::string("gn_payload"); const std::string& Params::gn_next_header = std::string("gnNextHeader"); const std::string& Params::gn_header_type = std::string("gnHeaderType"); const std::string& Params::gn_header_sub_type = std::string("gnHeaderSubtype"); const std::string& Params::gn_lifetime = std::string("gnLifetime"); const std::string& Params::gn_traffic_class = std::string("gnTrafficClass"); const std::string& Params::btp_type = std::string("btp_type"); const std::string& Params::btp_payload = std::string("btp_payload"); const std::vector<unsigned char>& Params::mac_address({0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}); const std::string& Params::btp_destination_port = std::string("btpDestinationPort"); const std::string& Params::btp_info = std::string("btpInfo"); void Params::convert(Params& p_param, const std::string p_parameters) { //loggers::get_instance().log(">>> Params::convert: '%s'", p_parameters.c_str()); Loading Loading @@ -41,3 +47,10 @@ void Params::log() { loggers::get_instance().log("\t(%s, %s)", it->first.c_str(), it->second.c_str()); } // End of 'for' statement } void Params::reset() { loggers::get_instance().log("Params::reset"); for (iterator it = begin(); it != end(); ++it) { it->second.clear(); } // End of 'for' statement } ccsrc/Protocols/BTP/BTPCodec.cc +13 −4 Original line number Diff line number Diff line Loading @@ -63,11 +63,11 @@ int BTPCodec::encode_ (const Base_Type& type, const TTCN_Typedescriptor_t& field return 0; } int BTPCodec::decode (const OCTETSTRING& data, LibItsBtp__TypesAndValues::BtpPacket& msg, Params* param) int BTPCodec::decode (const OCTETSTRING& data, LibItsBtp__TypesAndValues::BtpPacket& msg, Params* params) { TTCN_EncDec::clear_error(); TTCN_Buffer decoding_buffer(data); _param = param; _params = params; loggers::get_instance().log_to_hexa(">>> BTPCodec::decode: decoding_buffer=", decoding_buffer); decode_(msg, LibItsBtp__TypesAndValues::BtpPacket_descr_, decoding_buffer); Loading Loading @@ -112,8 +112,17 @@ int BTPCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& field_descr LibItsBtp__TypesAndValues::BtpHeader& b = static_cast<LibItsBtp__TypesAndValues::BtpHeader&>(type); if (_type == BTPCodec::btpA) { decode_(b.btpAHeader(), *b.btpAHeader().get_descriptor(), decoding_buffer); if (_params != NULL) { (*_params)[Params::btp_type] = std::string("btpA"); (*_params)[Params::btp_destination_port] = static_cast<int>(b.btpAHeader().destinationPort()); } } else if (_type == BTPCodec::btpB) { decode_(b.btpBHeader(), *b.btpBHeader().get_descriptor(), decoding_buffer); if (_params != NULL) { (*_params)[Params::btp_type] = std::string("btpB"); (*_params)[Params::btp_destination_port] = static_cast<int>(b.btpBHeader().destinationPort()); (*_params)[Params::btp_info] = static_cast<int>(b.btpBHeader().destinationPortInfo()); } } else { loggers::get_instance().error("BTPCodec::decode_: Invalid BTP type"); // Cannot be reached } Loading @@ -124,8 +133,8 @@ int BTPCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& field_descr // Decode BtpRawPayload data structure OCTETSTRING os(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos()); loggers::get_instance().log_msg("BTPCodec::decode_: s=", os); if (_param != NULL) { (*_param)[Params::btp_payload] = std::string(static_cast<const char *>(oct2str(os))); if (_params != NULL) { (*_params)[Params::btp_payload] = std::string(static_cast<const char *>(oct2str(os))); } dynamic_cast<OCTETSTRING &>(type) = os; } else { Loading ccsrc/Protocols/BTP/BTPLayer.cc +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ void BTPLayer::receiveData(OCTETSTRING& data, Params& params) _codec.decode(data, p.msgIn(), ¶ms); // Pass the BTP raw payload to the upper layers if any std::map<std::string, std::string>::const_iterator it = params.find(Params::btp_payload); Params::const_iterator it = params.find(Params::btp_payload); if (it != params.cend()) { loggers::get_instance().log("BTPLayer::receiveData: btp_payload=%s", it->second.c_str()); OCTETSTRING os(str2oct(CHARSTRING(it->second.c_str()))); Loading Loading
ccsrc/Framework/Codec.hh +5 −2 Original line number Diff line number Diff line Loading @@ -10,11 +10,14 @@ class BITSTRING; template<typename TPDUEnc, typename TPDUDec> class Codec { protected: Params* _params; public: Codec() { loggers::get_instance().log("Codec::Codec"); }; Codec() : _params(NULL) { loggers::get_instance().log("Codec::Codec"); }; virtual ~Codec() { loggers::get_instance().log("Codec::~Codec"); }; virtual int encode(const TPDUEnc& msg, OCTETSTRING& data) = 0; virtual int decode(const OCTETSTRING& data, TPDUDec& msg, Params* param = NULL) = 0; virtual int decode(const OCTETSTRING& data, TPDUDec& msg, Params* params = NULL) = 0; }; template<typename TPDU> class PERCodec Loading
ccsrc/Framework/Params.hh +8 −1 Original line number Diff line number Diff line Loading @@ -10,15 +10,22 @@ public: static const std::string& ssp; static const std::string& its_aid; static const std::string& gn_payload; static const std::string& gn_next_header; static const std::string& gn_header_type; static const std::string& gn_header_sub_type; static const std::string& gn_lifetime; static const std::string& gn_traffic_class; static const std::string& btp_type; static const std::string& btp_payload; static const std::vector<unsigned char>& mac_address; static const std::string& btp_destination_port; static const std::string& btp_info; Params() : std::map<std::string, std::string>() {}; Params(const Params& p_params) : std::map<std::string, std::string>(p_params.begin(), p_params.end()) {}; virtual ~Params() {}; void log(); void reset(); static void convert(Params& p_param, const std::string p_parameters); };
ccsrc/Framework/src/Params.cc +37 −24 Original line number Diff line number Diff line Loading @@ -9,9 +9,15 @@ const std::string& Params::mac_dst = std::string("mac_dst"); const std::string& Params::its_aid = std::string("its_aid"); const std::string& Params::ssp = std::string("ssp"); const std::string& Params::gn_payload = std::string("gn_payload"); const std::string& Params::gn_next_header = std::string("gnNextHeader"); const std::string& Params::gn_header_type = std::string("gnHeaderType"); const std::string& Params::gn_header_sub_type = std::string("gnHeaderSubtype"); const std::string& Params::gn_lifetime = std::string("gnLifetime"); const std::string& Params::gn_traffic_class = std::string("gnTrafficClass"); const std::string& Params::btp_type = std::string("btp_type"); const std::string& Params::btp_payload = std::string("btp_payload"); const std::vector<unsigned char>& Params::mac_address({0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}); const std::string& Params::btp_destination_port = std::string("btpDestinationPort"); const std::string& Params::btp_info = std::string("btpInfo"); void Params::convert(Params& p_param, const std::string p_parameters) { //loggers::get_instance().log(">>> Params::convert: '%s'", p_parameters.c_str()); Loading Loading @@ -41,3 +47,10 @@ void Params::log() { loggers::get_instance().log("\t(%s, %s)", it->first.c_str(), it->second.c_str()); } // End of 'for' statement } void Params::reset() { loggers::get_instance().log("Params::reset"); for (iterator it = begin(); it != end(); ++it) { it->second.clear(); } // End of 'for' statement }
ccsrc/Protocols/BTP/BTPCodec.cc +13 −4 Original line number Diff line number Diff line Loading @@ -63,11 +63,11 @@ int BTPCodec::encode_ (const Base_Type& type, const TTCN_Typedescriptor_t& field return 0; } int BTPCodec::decode (const OCTETSTRING& data, LibItsBtp__TypesAndValues::BtpPacket& msg, Params* param) int BTPCodec::decode (const OCTETSTRING& data, LibItsBtp__TypesAndValues::BtpPacket& msg, Params* params) { TTCN_EncDec::clear_error(); TTCN_Buffer decoding_buffer(data); _param = param; _params = params; loggers::get_instance().log_to_hexa(">>> BTPCodec::decode: decoding_buffer=", decoding_buffer); decode_(msg, LibItsBtp__TypesAndValues::BtpPacket_descr_, decoding_buffer); Loading Loading @@ -112,8 +112,17 @@ int BTPCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& field_descr LibItsBtp__TypesAndValues::BtpHeader& b = static_cast<LibItsBtp__TypesAndValues::BtpHeader&>(type); if (_type == BTPCodec::btpA) { decode_(b.btpAHeader(), *b.btpAHeader().get_descriptor(), decoding_buffer); if (_params != NULL) { (*_params)[Params::btp_type] = std::string("btpA"); (*_params)[Params::btp_destination_port] = static_cast<int>(b.btpAHeader().destinationPort()); } } else if (_type == BTPCodec::btpB) { decode_(b.btpBHeader(), *b.btpBHeader().get_descriptor(), decoding_buffer); if (_params != NULL) { (*_params)[Params::btp_type] = std::string("btpB"); (*_params)[Params::btp_destination_port] = static_cast<int>(b.btpBHeader().destinationPort()); (*_params)[Params::btp_info] = static_cast<int>(b.btpBHeader().destinationPortInfo()); } } else { loggers::get_instance().error("BTPCodec::decode_: Invalid BTP type"); // Cannot be reached } Loading @@ -124,8 +133,8 @@ int BTPCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& field_descr // Decode BtpRawPayload data structure OCTETSTRING os(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos()); loggers::get_instance().log_msg("BTPCodec::decode_: s=", os); if (_param != NULL) { (*_param)[Params::btp_payload] = std::string(static_cast<const char *>(oct2str(os))); if (_params != NULL) { (*_params)[Params::btp_payload] = std::string(static_cast<const char *>(oct2str(os))); } dynamic_cast<OCTETSTRING &>(type) = os; } else { Loading
ccsrc/Protocols/BTP/BTPLayer.cc +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ void BTPLayer::receiveData(OCTETSTRING& data, Params& params) _codec.decode(data, p.msgIn(), ¶ms); // Pass the BTP raw payload to the upper layers if any std::map<std::string, std::string>::const_iterator it = params.find(Params::btp_payload); Params::const_iterator it = params.find(Params::btp_payload); if (it != params.cend()) { loggers::get_instance().log("BTPLayer::receiveData: btp_payload=%s", it->second.c_str()); OCTETSTRING os(str2oct(CHARSTRING(it->second.c_str()))); Loading