Commit 6345e24f authored by garciay's avatar garciay
Browse files

Minor bug fixed in include file naming

Continue tests on codecs
parent bd17c801
......@@ -29,10 +29,10 @@ BITSTRING fx__enc__DenmReq(const LibItsDenm__TestSystem::DenmReq& p)
* @param value to encode
* @return encoded value
****************************************************/
/* function not needed yet, decvalue() is not used in TTCN-3 code
//function not needed yet, decvalue() is not used in TTCN-3 code
INTEGER fx__dec__DenmReq(BITSTRING& b, LibItsDenm__TestSystem::DenmReq& p)
{
return -1
return -1;
}
*/
} //end namespace
#include "LibItsEvcsn_encdecDeclarations.hh"
#include "LibItsEvcsn_EncdecDeclarations.hh"
namespace LibItsEvcsn__EncdecDeclarations {
/****************************************************
......
#include "LibItsGeoNetworking_encdecDeclarations.hh"
#include "LibItsGeoNetworking_EncdecDeclarations.hh"
#include "GeoNetworkingCodec.hh"
#include "loggers.hh"
......
......@@ -11,65 +11,58 @@
namespace LibItsBtp__TestSystem {
BtpPort::BtpPort(const char *par_port_name)
: BtpPort_BASE(par_port_name)
{
BtpPort::BtpPort(const char *par_port_name) :
BtpPort_BASE(par_port_name) {
}
BtpPort::~BtpPort()
{
BtpPort::~BtpPort() {
}
void BtpPort::set_parameter(const char * /*parameter_name*/,
const char * /*parameter_value*/)
{
const char * /*parameter_value*/) {
}
/*void BtpPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
boolean is_writable, boolean is_error) {}*/
void BtpPort::Handle_Fd_Event_Error(int /*fd*/)
{
void BtpPort::Handle_Fd_Event_Error(int /*fd*/) {
}
void BtpPort::Handle_Fd_Event_Writable(int /*fd*/)
{
void BtpPort::Handle_Fd_Event_Writable(int /*fd*/) {
}
void BtpPort::Handle_Fd_Event_Readable(int /*fd*/)
{
void BtpPort::Handle_Fd_Event_Readable(int /*fd*/) {
}
/*void BtpPort::Handle_Timeout(double time_since_last_call) {}*/
void BtpPort::user_map(const char * /*system_port*/)
{
void BtpPort::user_map(const char * /*system_port*/) {
}
void BtpPort::user_unmap(const char * /*system_port*/)
{
void BtpPort::user_unmap(const char * /*system_port*/) {
}
void BtpPort::user_start()
{
void BtpPort::user_start() {
}
void BtpPort::user_stop()
{
void BtpPort::user_stop() {
}
void BtpPort::outgoing_send(const BtpReq& /*send_par*/)
{
void BtpPort::outgoing_send(const BtpReq& /*send_par*/) {
}
void BtpPort::receiveMsg(const LibItsBtp__TypesAndValues::BtpPacket&, const Params&) {
}
......
......@@ -12,9 +12,12 @@
#include "LibItsBtp_TestSystem.hh"
#include "BTPLayer.h"
namespace LibItsBtp__TestSystem {
class BtpPort : public BtpPort_BASE {
BTPLayer * layer;
public:
BtpPort(const char *par_port_name = NULL);
~BtpPort();
......@@ -37,6 +40,8 @@ protected:
void user_stop();
void outgoing_send(const BtpReq& send_par);
void receiveMsg (const LibItsBtp__TypesAndValues::BtpPacket&, const Params&);
};
} /* end of namespace */
......
#include <string>
#include <typeinfo>
#include "GeoNetworkingCodec.hh"
#include "loggers.hh"
int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu& msg, OCTETSTRING& data)
{
TTCN_Buffer encoding_buffer;
loggers::loggers::log("GeoNetworkingCodec::encode");
for(int i = 0; i < msg.get_count(); i++) {
loggers::loggers::log("GeoNetworkingCodec::encode: processing %s\n", msg.fld_name(i));
msg.encode(*msg.fld_descr(i), encoding_buffer, TTCN_EncDec::CT_RAW);
loggers::loggers::log_to_hexa(&encoding_buffer);
}
loggers::loggers::log_msg("GeoNetworkingCodec::encode: ", (const Base_Type&)msg);
TTCN_Buffer encoding_buffer;
encode_(msg, encoding_buffer);
data = OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data());
return 0;
}
int GeoNetworkingCodec::decode (const OCTETSTRING& data, LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu& msg)
{
loggers::loggers::log("fx__enc__GeoNetworkingReq");
loggers::loggers::log("GeoNetworkingCodec::decode");
return 0;
}
int GeoNetworkingCodec::encode_ (const Base_Type& type, TTCN_Buffer& encoding_buffer)
{
loggers::loggers::log(">>> GeoNetworkingCodec::encode_: processing %s", type.get_descriptor()->name);
loggers::loggers::log_msg("GeoNetworkingCodec::encode_: ", type);
if (dynamic_cast<const Record_Type *>(&type) != NULL) {
const Record_Type& r = (const Record_Type &)type;
loggers::loggers::log("GeoNetworkingCodec::encode_: processing Record_Type %s", r.get_descriptor()->name);
for(int i = 0; i < r.get_count(); i++) {
loggers::loggers::log("GeoNetworkingCodec::encode_: processing %s - %d (1 ==> use dynamic_cast<const OPTIONAL<...>)", r.fld_name(i), r.get_at(i)->is_optional());
if (encode_(*r.get_at(i), encoding_buffer) == -1) {
return -1;
}
} // End of 'for' statement
} else if (std::string(type.get_descriptor()->name).compare("@LibItsGeoNetworking_TypesAndValues.ExtendedHeader") == 0) {
const OPTIONAL<LibItsGeoNetworking__TypesAndValues::ExtendedHeader> &v = dynamic_cast<const OPTIONAL<LibItsGeoNetworking__TypesAndValues::ExtendedHeader> &>(type);
const LibItsGeoNetworking__TypesAndValues::ExtendedHeader& u = static_cast<const LibItsGeoNetworking__TypesAndValues::ExtendedHeader &>(*v.get_opt_value());
int result = -1;
switch (u.get_selection()) {
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::UNBOUND_VALUE:
TTCN_error("Invalid selection in unbound union");
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_geoUnicastHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.geoUnicastHeader().get_descriptor()->name);
result = encode_(u.geoUnicastHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_tsbHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.tsbHeader().get_descriptor()->name);
result = encode_(u.tsbHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_shbHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.shbHeader().get_descriptor()->name);
result = encode_(u.shbHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_geoBroadcastHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.geoBroadcastHeader().get_descriptor()->name);
result = encode_(u.geoBroadcastHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_geoAnycastHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.geoAnycastHeader().get_descriptor()->name);
result = encode_(u.geoAnycastHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_beaconHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.beaconHeader().get_descriptor()->name);
result = encode_(u.beaconHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_anyHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.anyHeader().get_descriptor()->name);
result = encode_(u.anyHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_lsRequestHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.lsRequestHeader().get_descriptor()->name);
result = encode_(u.lsRequestHeader(), encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::ExtendedHeader::ALT_lsReplyHeader:
loggers::loggers::log("GeoNetworkingCodec::encode_: processing type %s", u.lsReplyHeader().get_descriptor()->name);
result = encode_(u.lsReplyHeader(), encoding_buffer);
break;
default: TTCN_error("Invalid selection in union is_bound");
} // End of 'switch' statement
if (result == -1) {
return -1;
}
} else {
loggers::loggers::log("GeoNetworkingCodec::encode_ (else): processing type %s", type.get_descriptor()->name);
type.encode(*type.get_descriptor(), encoding_buffer, TTCN_EncDec::CT_RAW);
}
loggers::loggers::log_to_hexa("GeoNetworkingCodec::encode_: encoding_buffer=", encoding_buffer);
return 0;
}
......@@ -4,6 +4,7 @@
#include "Codec.h"
class GeoNetworkingCodec : public Codec<LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu> {
int encode_ (const Base_Type& type, TTCN_Buffer& encoding_buffer);
public:
virtual int encode (const LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu&, OCTETSTRING& data);
virtual int decode (const OCTETSTRING& data, LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu&);
......
......@@ -2,5 +2,6 @@
#define GNTYPES_H
#include "LibItsGeoNetworking_TypesAndValues.hh"
#include "LibItsGeoNetworking_TestSystem.hh"
#endif
#pragma once
#include <TTCN3.hh>
namespace loggers {
class loggers {
public:
inline static void log_to_hexa(const char *prompt, const TTCN_Buffer & buffer);
inline static void log_to_hexa(const char *prompt, const OCTETSTRING& msg);
inline static void log_msg(const char *prompt, const Base_Type& type);
inline static void log(const char *fmt, ...);
inline static void error(const char *fmt, ...);
};
void loggers::log_to_hexa(const char *prompt, const TTCN_Buffer & buffer)
{
TTCN_Logger::begin_event(TTCN_DEBUG);
TTCN_Logger::log_event_str(prompt);
buffer.log();
TTCN_Logger::end_event();
// TTCN_Logger::begin_event(TTCN_DEBUG);
// int len = buffer->get_read_len();
// const unsigned char* ptr = buffer->get_read_data();
// for(int i = buffer->get_pos(); i < len; i++)
// {
// TTCN_Logger::log_event(" %02X", ptr[i]);
// }
// TTCN_Logger::end_event();
}
void loggers::log_to_hexa(const char *prompt, const OCTETSTRING& msg)
{
TTCN_Logger::begin_event(TTCN_DEBUG);
TTCN_Logger::log_event_str(prompt);
TTCN_Logger::log_event("Size: %d,\nMsg: ",msg.lengthof());
for(int i=0; i<msg.lengthof(); i++)
TTCN_Logger::log_event(" %02x", ((const unsigned char*)msg)[i]);
TTCN_Logger::log_event("\n");
TTCN_Logger::end_event();
}
void loggers::log_msg(const char *prompt, const Base_Type& type)
{
TTCN_Logger::begin_event(TTCN_DEBUG);
TTCN_Logger::log_event_str(prompt);
type.log();
TTCN_Logger::end_event();
}
void loggers::log(const char *fmt, ...)
{
TTCN_Logger::begin_event(TTCN_DEBUG);
va_list args;
va_start(args, fmt);
TTCN_Logger::log_event_va_list(fmt, args);
va_end(args);
TTCN_Logger::end_event();
}
void loggers::error(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
TTCN_error(fmt, args);
va_end(args);
}
}
using namespace loggers;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment