Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
61608430
Commit
61608430
authored
Feb 26, 2018
by
garciay
Browse files
STF538: Certificate TPs implementation
parent
406aa8ff
Changes
8
Hide whitespace changes
Inline
Side-by-side
ccsrc/Ports/LibIts_ports/RSUsSimulator_ports/ConfigRsuSimulatorCodec.cc
View file @
61608430
#include
<string>
//#include <typeinfo>
#include
"ConfigRsuSimulatorCodec.hh"
#include
"loggers.hh"
#include
"ItsRSUsSimulator_TestSystem.hh"
int
ConfigRsuSimulatorCodec
::
encode
(
const
Record_Type
&
msg
,
OCTETSTRING
&
data
)
{
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorCodec::encode: "
,
(
const
Base_Type
&
)
msg
);
TTCN_EncDec
::
clear_error
();
TTCN_Buffer
encoding_buffer
;
encode_
(
msg
,
*
msg
.
get_descriptor
(),
encoding_buffer
);
data
=
OCTETSTRING
(
encoding_buffer
.
get_len
(),
encoding_buffer
.
get_data
());
loggers
::
get_instance
().
log_msg
(
"<<< ConfigRsuSimulatorCodec::encode: data="
,
data
);
return
0
;
}
int
ConfigRsuSimulatorCodec
::
encode_
(
const
Base_Type
&
type
,
const
TTCN_Typedescriptor_t
&
field_descriptor
,
TTCN_Buffer
&
encoding_buffer
)
{
loggers
::
get_instance
().
log
(
">>> ConfigRsuSimulatorCodec::encode_: processing %s/%s"
,
type
.
get_descriptor
()
->
name
,
field_descriptor
.
name
);
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorCodec::encode_: "
,
type
);
if
(
dynamic_cast
<
const
Record_Type
*>
(
&
type
)
!=
NULL
)
{
const
Record_Type
&
r
=
(
const
Record_Type
&
)
type
;
loggers
::
get_instance
().
log
(
"ConfigRsuSimulatorCodec::encode_: processing Record_Type %s"
,
r
.
get_descriptor
()
->
name
);
for
(
int
i
=
0
;
i
<
r
.
get_count
();
i
++
)
{
loggers
::
get_instance
().
log
(
"ConfigRsuSimulatorCodec::encode_: processing %s/%s/%s - %d (1 ==> use dynamic_cast<const OPTIONAL<...>) - %d"
,
r
.
fld_name
(
i
),
r
.
fld_descr
(
i
)
->
name
,
r
.
get_at
(
i
)
->
get_descriptor
()
->
name
,
r
.
get_at
(
i
)
->
is_optional
(),
r
.
get_at
(
i
)
->
is_present
());
if
(
r
.
get_at
(
i
)
->
is_present
())
{
if
(
encode_
(
*
r
.
get_at
(
i
),
*
r
.
fld_descr
(
i
),
encoding_buffer
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"ConfigRsuSimulatorCodec::encode_: -1 result code returned"
);
return
-
1
;
}
}
}
// End of 'for' statement
}
else
{
loggers
::
get_instance
().
log
(
"ConfigRsuSimulatorCodec::encode_ (else): processing type %s/%s"
,
type
.
get_descriptor
()
->
name
,
field_descriptor
.
name
);
type
.
encode
(
field_descriptor
,
encoding_buffer
,
TTCN_EncDec
::
CT_RAW
);
}
loggers
::
get_instance
().
log_to_hexa
(
"<<<ConfigRsuSimulatorCodec::encode_: encoding_buffer="
,
encoding_buffer
);
return
0
;
}
int
ConfigRsuSimulatorCodec
::
decode
(
const
OCTETSTRING
&
data
,
Record_Type
&
msg
,
Params
*
params
)
{
TTCN_EncDec
::
clear_error
();
TTCN_Buffer
decoding_buffer
(
data
);
_params
=
params
;
loggers
::
get_instance
().
log_to_hexa
(
">>> ConfigRsuSimulatorCodec::decode: decoding_buffer="
,
decoding_buffer
);
// decode_(msg, *msg.get_descriptor(), decoding_buffer);
loggers
::
get_instance
().
log_msg
(
"<<< ConfigRsuSimulatorCodec::decode: "
,
(
const
Base_Type
&
)
msg
);
return
0
;
}
ccsrc/Ports/LibIts_ports/RSUsSimulator_ports/ConfigRsuSimulatorCodec.hh
View file @
61608430
#pragma once
#include
"Codec.hh"
#include
"Params.hh"
class
Record_Type
;
class
Base_Type
;
class
TTCN_Typedescriptor_t
;
class
TTCN_Buffer
;
namespace
ItsRSUsSimulator__TestSystem
{
class
CfInitialize
;
}
class
ConfigRsuSimulatorCodec
:
public
Codec
<
Record_Type
,
Record_Type
>
{
int
encode_
(
const
Base_Type
&
type
,
const
TTCN_Typedescriptor_t
&
field_descriptor
,
TTCN_Buffer
&
encoding_buffer
);
public:
ConfigRsuSimulatorCodec
()
:
Codec
<
Record_Type
,
Record_Type
>
()
{
};
virtual
~
ConfigRsuSimulatorCodec
()
{
};
virtual
int
encode
(
const
Record_Type
&
,
OCTETSTRING
&
data
);
virtual
int
decode
(
const
OCTETSTRING
&
data
,
Record_Type
&
,
Params
*
params
=
NULL
);
};
// End of class ConfigRsuSimulatorCodec
ccsrc/Ports/LibIts_ports/RSUsSimulator_ports/ConfigRsuSimulatorLayer.cc
View file @
61608430
#include
"ConfigRsuSimulatorLayerFactory.hh"
#include
"loggers.hh"
#include
"ItsRSUsSimulator_TestSystem.hh"
ConfigRsuSimulatorLayer
::
ConfigRsuSimulatorLayer
(
const
std
::
string
&
p_type
,
const
std
::
string
&
param
)
:
TLayer
<
ItsRSUsSimulator__TestSystem
::
ConfigRsuSimulatorPort
>
(
p_type
),
_params
(),
_codec
()
{
loggers
::
get_instance
().
log
(
">>> ConfigRsuSimulatorLayer::ConfigRsuSimulatorLayer: %s, %s"
,
to_string
().
c_str
(),
param
.
c_str
());
// Setup parameters
Params
::
convert
(
_params
,
param
);
}
void
ConfigRsuSimulatorLayer
::
sendMsg
(
const
ItsRSUsSimulator__TestSystem
::
CfInitialize
&
send_par
,
Params
&
params
){
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorLayer::sendMsg: "
,
send_par
);
// Encode ConfigRsuSimulator PDU
OCTETSTRING
data
;
if
(
_codec
.
encode
(
static_cast
<
const
Record_Type
&>
(
send_par
),
data
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"ConfigRsuSimulatorLayer::sendMsg: Encoding failure"
);
return
;
}
sendData
(
data
,
_params
);
}
void
ConfigRsuSimulatorLayer
::
sendData
(
OCTETSTRING
&
data
,
Params
&
params
)
{
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorLayer::sendData: "
,
data
);
sendToAllLayers
(
data
,
params
);
}
void
ConfigRsuSimulatorLayer
::
receiveData
(
OCTETSTRING
&
data
,
Params
&
params
)
{
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorLayer::receiveData: "
,
data
);
// Sanity check
if
(
*
(
static_cast
<
const
unsigned
char
*>
(
data
)
+
1
)
!=
0x02
)
{
// Check that received packet has CA message id - See ETSI TS 102 894
// Not a ConfigRsuSimulator message, discard it
loggers
::
get_instance
().
warning
(
"ConfigRsuSimulatorLayer::receiveData: Wrong message id: 0x%02x"
,
*
(
static_cast
<
const
unsigned
char
*>
(
data
)
+
1
));
return
;
}
// Decode the payload
BOOLEAN
p
;
/*_codec.decode(data, p);
if (!p.msgIn().is_bound()) {
// Discard it
return;
}*/
// else, continue
// Pass it to the ports if amy
toAllUpperPorts
(
p
,
params
);
}
ConfigRsuSimulatorLayerFactory
ConfigRsuSimulatorLayerFactory
::
_f
;
ccsrc/Ports/LibIts_ports/RSUsSimulator_ports/ConfigRsuSimulatorLayer.hh
View file @
61608430
/*!
* \file ConfigRsuSimulatorLayer.hh
* \brief Header file for ITS Configuration port protocol layer.
* \author ETSI STF525
* \copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
* \version 0.1
*/
#pragma once
#include
"TLayer.hh"
#include
"ConfigRsuSimulatorCodec.hh"
namespace
ItsRSUsSimulator__TestSystem
{
class
ConfigRsuSimulatorPort
;
class
CfInitialize
;
}
class
ConfigRsuSimulatorLayer
:
public
TLayer
<
ItsRSUsSimulator__TestSystem
::
ConfigRsuSimulatorPort
>
{
Params
_params
;
ConfigRsuSimulatorCodec
_codec
;
public:
ConfigRsuSimulatorLayer
()
:
TLayer
<
ItsRSUsSimulator__TestSystem
::
ConfigRsuSimulatorPort
>
(),
_params
(),
_codec
()
{};
ConfigRsuSimulatorLayer
(
const
std
::
string
&
p_type
,
const
std
::
string
&
param
);
virtual
~
ConfigRsuSimulatorLayer
()
{};
void
sendMsg
(
const
ItsRSUsSimulator__TestSystem
::
CfInitialize
&
,
Params
&
params
);
virtual
void
sendData
(
OCTETSTRING
&
data
,
Params
&
params
);
virtual
void
receiveData
(
OCTETSTRING
&
data
,
Params
&
info
);
};
// End of class CAMLayer
ccsrc/Ports/LibIts_ports/RSUsSimulator_ports/ConfigRsuSimulatorPort.cc
View file @
61608430
#include
"ConfigRsuSimulatorPort.hh"
//
#include "ConfigRsuSimulatorLayerFactory.hh"
#include
"ConfigRsuSimulatorLayerFactory.hh"
#include
"loggers.hh"
namespace
ItsRSUsSimulator__TestSystem
{
...
...
@@ -54,11 +54,11 @@ namespace ItsRSUsSimulator__TestSystem {
// Setup parameters
Params
::
convert
(
_layer_params
,
it
->
second
);
// TODO This _layer_params seems to be useless
// Create layer
/*
_layer = LayerStackBuilder::GetInstance()->createLayerStack(it->second.c_str());
_layer
=
LayerStackBuilder
::
GetInstance
()
->
createLayerStack
(
it
->
second
.
c_str
());
if
(
static_cast
<
ConfigRsuSimulatorLayer
*>
(
_layer
)
==
nullptr
)
{
loggers
::
get_instance
().
error
(
"ConfigRsuSimulatorPort::user_map: Invalid stack configuration: %s"
,
it
->
second
.
c_str
());
}
static_cast<ConfigRsuSimulatorL
q
yer*>(_layer)->addUpperPort(this);
*/
static_cast
<
ConfigRsuSimulatorL
a
yer
*>
(
_layer
)
->
addUpperPort
(
this
);
}
else
{
loggers
::
get_instance
().
error
(
"ConfigRsuSimulatorPort::user_map: No layers defined in configuration file"
);
...
...
@@ -111,6 +111,16 @@ namespace ItsRSUsSimulator__TestSystem {
}
void
ConfigRsuSimulatorPort
::
receiveMsg
(
const
BOOLEAN
&
p_ind
,
const
Params
&
p_params
)
{
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorPort::receive_msg: "
,
p_ind
);
// Sanity check
if
(
!
p_ind
.
is_bound
())
{
return
;
}
//incoming_message(p_ind);
}
void
ConfigRsuSimulatorPort
::
receiveMsg
(
const
LibItsGeoNetworking__TypesAndValues
::
UtGnInitialize
&
p_ind
,
const
Params
&
p_params
)
{
loggers
::
get_instance
().
log_msg
(
">>> ConfigRsuSimulatorPort::receive_msg: "
,
p_ind
);
// Sanity check
...
...
ccsrc/Ports/LibIts_ports/RSUsSimulator_ports/ConfigRsuSimulatorPort.hh
View file @
61608430
...
...
@@ -18,6 +18,7 @@ namespace ItsRSUsSimulator__TestSystem {
~
ConfigRsuSimulatorPort
();
void
set_parameter
(
const
char
*
parameter_name
,
const
char
*
parameter_value
);
void
receiveMsg
(
const
BOOLEAN
&
p_ind
,
const
Params
&
p_params
);
void
receiveMsg
(
const
LibItsGeoNetworking__TypesAndValues
::
UtGnInitialize
&
p_ind
,
const
Params
&
p_params
);
/*void send(const CfInitialize& send_par, const COMPONENT& destination_component);
...
...
ccsrc/Protocols/UDP/UdpLayer.hh
View file @
61608430
...
...
@@ -24,12 +24,11 @@
u_short check;
u_int saddr;
u_int daddr;
/
*
The options start here.
*/
/
/
The options start here.
};*/
#else
#include
<linux/ip.h>
#include
<linux/udp.h>
#endif
#include
"TLayer.hh"
#include
"Params.hh"
...
...
ccsrc/Protocols/UpperTester/UpperTesterGnLayer.cc
View file @
61608430
...
...
@@ -15,7 +15,7 @@ void UpperTesterGnLayer::sendMsg(const LibItsGeoNetworking__TypesAndValues::UtGn
// Encode UpperTester PDU
OCTETSTRING
data
;
_codec
.
encode
(
(
const
Record_Type
&
)
send_par
,
data
);
_codec
.
encode
(
static_cast
<
const
Record_Type
&>
(
send_par
)
,
data
);
// Update parameters
Params
par
(
params
);
// FIXME Review all const Param& in method declarations
sendData
(
data
,
params
);
...
...
@@ -27,7 +27,7 @@ void UpperTesterGnLayer::sendMsg(const LibItsGeoNetworking__TypesAndValues::UtGn
// Encode UpperTester PDU
OCTETSTRING
data
;
_codec
.
encode
(
(
const
Record_Type
&
)
send_par
,
data
);
_codec
.
encode
(
static_cast
<
const
Record_Type
&>
(
send_par
)
,
data
);
// Update parameters
Params
par
(
params
);
// FIXME Review all const Param& in method declarations
sendData
(
data
,
params
);
...
...
@@ -39,7 +39,7 @@ void UpperTesterGnLayer::sendMsg(const LibItsGeoNetworking__TypesAndValues::UtGn
// Encode UpperTester PDU
OCTETSTRING
data
;
_codec
.
encode
((
const
Record_Type
&
)
send_par
,
data
);
_codec
.
encode
((
const
Record_Type
&
)
send_par
,
data
);
// Update parameters
Params
par
(
params
);
// FIXME Review all const Param& in method declarations
sendData
(
data
,
params
);
...
...
@@ -51,7 +51,7 @@ void UpperTesterGnLayer::sendMsg(const LibItsGeoNetworking__TypesAndValues::UtAu
// Encode UpperTester PDU
OCTETSTRING
data
;
_codec
.
encode
((
const
Record_Type
&
)
send_par
,
data
);
_codec
.
encode
((
const
Record_Type
&
)
send_par
,
data
);
// Update parameters
Params
par
(
params
);
// FIXME Review all const Param& in method declarations
sendData
(
data
,
params
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment