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
12c0107f
Commit
12c0107f
authored
May 30, 2017
by
filatov
Browse files
fix compilation issues(GN ongoing)
parent
9a5a38ed
Changes
15
Hide whitespace changes
Inline
Side-by-side
ccsrc/EncDec/LibItsCam_Encdec.cc
View file @
12c0107f
#include
"LibItsCam_EncdecDeclarations.hh"
#include
"CAMCodec.hh"
namespace
LibItsCam__EncdecDeclarations
{
/****************************************************
...
...
@@ -8,20 +9,7 @@ namespace LibItsCam__EncdecDeclarations {
****************************************************/
BITSTRING
fx__enc__CamReq
(
const
LibItsCam__TestSystem
::
CamReq
&
p
)
{
//set error behavior
TTCN_EncDec
::
set_error_behavior
(
TTCN_EncDec
::
ET_ALL
,
TTCN_EncDec
::
EB_WARNING
);
TTCN_Buffer
TTCN_buf
;
TTCN_buf
.
clear
();
//encode message in BER (CER variant, but can be any)
p
.
msgOut
().
encode
(
CAM__PDU__Descriptions
::
CAM_descr_
,
TTCN_buf
,
TTCN_EncDec
::
CT_BER
,
BER_ENCODE_CER
);
OCTETSTRING
encodedData
(
TTCN_buf
.
get_len
(),
TTCN_buf
.
get_data
());
//insert BER2PER recoding here!
return
oct2bit
(
encodedData
);
return
fx__enc__CAM
(
p
.
msgOut
());
}
...
...
@@ -36,4 +24,23 @@ INTEGER fx__dec__CamReq(BITSTRING& b, LibItsCam__TestSystem::CamReq& p)
return -1;
}
*/
BITSTRING
fx__enc__CAM
(
const
CAM__PDU__Descriptions
::
CAM
&
p
)
{
CAMPDUCodec
codec
;
BITSTRING
b
;
codec
.
encode
(
p
,
b
);
return
b
;
}
INTEGER
fx__dec__CAM
(
BITSTRING
&
b
,
CAM__PDU__Descriptions
::
CAM
&
p
)
{
CAMPDUCodec
codec
;
INTEGER
rc
=
codec
.
decode
(
b
,
p
);
if
(
rc
>
0
){
b
=
(
b
>>
rc
);
}
}
}
//end namespace
ccsrc/Framework/Codec.hh
View file @
12c0107f
#ifndef CODEC_H
#define CODEC_H
class
OCTETSTRING
;
template
<
typename
TPDU
>
class
Codec
{
public:
Codec
(){}
virtual
int
encode
(
const
TPDU
&
msg
,
OCTETSTRING
&
data
)
=
0
;
virtual
int
decode
(
const
OCTETSTRING
&
data
,
TPDU
&
msg
)
=
0
;
class
BITSTRING
;
template
<
typename
TPDUEnc
,
typename
TPDUDec
>
class
Codec
{
public:
virtual
int
encode
(
const
TPDUEnc
&
msg
,
OCTETSTRING
&
data
)
=
0
;
virtual
int
decode
(
const
OCTETSTRING
&
data
,
TPDUDec
&
msg
)
=
0
;
};
template
<
typename
TPDU
>
class
PERCodec
{
public:
virtual
int
encode
(
const
TPDU
&
msg
,
BITSTRING
&
bits
);
virtual
int
decode
(
const
BITSTRING
&
bits
,
TPDU
&
msg
);
};
#endif
ccsrc/Framework/Layer.hh
View file @
12c0107f
#ifndef LAYER_H
#define LAYER_H
#ifndef LAYER_H
H
#define LAYER_H
H
#include
<string>
#include
<map>
#include
<vector>
...
...
@@ -12,6 +12,8 @@ class Layer {
std
::
vector
<
Layer
*>
lowerLayers
;
public:
Layer
(){}
virtual
~
Layer
();
void
deleteLayer
();
public:
void
addUpperLayer
(
Layer
*
);
void
removeUpperLayer
(
Layer
*
);
...
...
@@ -21,13 +23,17 @@ class Layer {
protected:
void
toAllLayers
(
std
::
vector
<
Layer
*>&
layers
,
const
OCTETSTRING
&
data
,
const
Params
&
info
);
inline
void
toAllUpperLayers
(
const
OCTETSTRING
&
data
,
const
Params
&
info
)
{
toAllLayers
(
upperLayers
,
data
,
info
);
}
inline
void
toAllLowerLayers
(
const
OCTETSTRING
&
data
,
const
Params
&
info
)
{
toAllLayers
(
upperLayers
,
data
,
info
);
}
inline
void
receiveToAllLayers
(
const
OCTETSTRING
&
data
,
const
Params
&
info
)
{
toAllLayers
(
upperLayers
,
data
,
info
);
}
inline
void
sendToAllLayers
(
const
OCTETSTRING
&
data
,
const
Params
&
info
)
{
toAllLayers
(
lowerLayers
,
data
,
info
);
}
};
template
<
typename
TPort
>
class
TLayer
:
public
Layer
{
typedef
std
::
vector
<
TPort
*>
TPortList
;
typedef
typename
std
::
vector
<
TPort
*>::
iterator
TPortListIterator
;
TPortList
upperPorts
;
public:
...
...
@@ -35,27 +41,35 @@ template <typename TPort> class TLayer : public Layer {
void
addUpperPort
(
TPort
*
);
void
removeUpperPort
(
TPort
*
);
template
<
typename
T
>
void
receiveToAllPorts
(
const
T
&
m
,
const
Params
&
param
)
{
protected:
template
<
typename
TMessage
>
void
toAllUpperPorts
(
const
TMessage
&
m
,
const
Params
&
param
)
{
for
(
TPortListIterator
it
=
upperPorts
.
begin
();
it
<
upperPorts
.
end
();
++
it
){
(
*
it
)
->
receiveMsg
(
m
,
param
);
}
}
};
class
LayerFactory
{
public:
LayerFactory
(){}
virtual
Layer
*
createLayer
(
const
std
::
string
&
type
,
const
std
::
string
&
param
)
=
0
;
};
class
StackFactory
{
static
StackFactory
*
_instance
;
std
::
map
<
std
::
string
,
LayerFactory
*>
_fs
;
class
LayerStackBuilder
{
typedef
std
::
map
<
std
::
string
,
LayerFactory
*>
LayerFactoryMap
;
static
LayerStackBuilder
*
_instance
;
std
::
map
<
std
::
string
,
LayerFactory
*>
_fs
;
private:
LayerStackBuilder
();
// can not be created manually
public:
static
StackFactory
*
getInstance
();
static
LayerStackBuilder
*
GetInstance
();
static
void
RegisterLayerFactory
(
const
std
::
string
&
type
,
LayerFactory
*
f
);
public:
void
registerLayerFactory
(
const
std
::
string
&
type
,
LayerFactory
*
f
);
Layer
*
createLayerStack
(
const
char
*
);
};
#endif
\ No newline at end of file
#endif
ccsrc/Framework/Makefile
View file @
12c0107f
...
...
@@ -4,11 +4,12 @@ PROJECT = its-framework
DEBUG
=
yes
testdir
=
tests
srcdir
=
src
ccflags
+=
-std
=
c++11
alibs
=
$(PROJECT)
sources
:=
LayerFactory.c
pp
headers
:=
Codec.h Layer.h
sources
:=
LayerFactory.c
c
headers
:=
Codec.h
h
Layer.h
h
includes
:=
.
..
include
../common.mk
ccsrc/Framework/src/LayerFactory.cc
View file @
12c0107f
#include
"Layer.hh"
#include
<stdexcept>
#include
<regex>
StackFactory
*
StackFactory
::
_instance
=
NULL
;
StackFactory
*
StackFactory
::
getInstance
(){
return
_instance
?
_instance
:
_instance
=
new
StackFactory
();
LayerStackBuilder
*
LayerStackBuilder
::
_instance
=
NULL
;
// static functions
LayerStackBuilder
*
LayerStackBuilder
::
GetInstance
()
{
return
_instance
?
_instance
:
_instance
=
new
LayerStackBuilder
();
}
void
LayerStackBuilder
::
RegisterLayerFactory
(
const
std
::
string
&
type
,
LayerFactory
*
f
)
{
LayerStackBuilder
::
GetInstance
()
->
registerLayerFactory
(
type
,
f
);
}
// member functions
LayerStackBuilder
::
LayerStackBuilder
()
{
}
void
StackFactory
::
registerLayerFactory
(
const
std
::
string
&
type
,
LayerFactory
*
f
)
void
LayerStackBuilder
::
registerLayerFactory
(
const
std
::
string
&
type
,
LayerFactory
*
f
)
{
_fs
[
type
]
=
f
;
}
Layer
*
StackFactory
::
createLayerStack
(
const
char
*
s
tr
)
Layer
*
LayerStackBuilder
::
createLayerStack
(
const
char
*
s
)
{
std
::
string
type
;
std
::
string
param
;
// parse str
LayerFactory
*
f
=
_fs
[
type
];
if
(
f
){
return
f
->
createLayer
(
type
,
param
);
}
return
NULL
;
Layer
*
up
=
NULL
;
//parse str
std
::
regex
rgx
(
"(
\\
w+)(
\\
((.*?)
\\
))?(
\\
/|$)"
);
std
::
smatch
m
;
std
::
string
str
=
s
;
try
{
while
(
std
::
regex_search
(
str
,
m
,
rgx
))
{
std
::
string
mname
=
m
[
1
];
LayerFactoryMap
::
iterator
it
=
_fs
.
find
(
mname
);
if
(
it
==
_fs
.
end
()){
throw
(
std
::
logic_error
(
mname
+
": Unknown layer type"
));
}
// TODO: parse parameters
Layer
*
l
=
it
->
second
->
createLayer
(
mname
,
m
[
3
]);
if
(
NULL
==
l
){
throw
(
std
::
logic_error
(
mname
+
": Layer creation error"
));
}
l
->
addUpperLayer
(
up
);
up
=
l
;
}
}
catch
(
const
std
::
logic_error
&
e
){
if
(
up
){
up
->
deleteLayer
();
up
=
NULL
;
}
}
return
up
;
}
void
Layer
::
deleteLayer
()
{
}
ccsrc/Protocols/BTP/BTPCodec.cc
View file @
12c0107f
#include
"BTPCodec.hh"
#include
"BTPTypes.hh"
int
BTPCodec
::
encode
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
msg
,
OCTETSTRING
&
data
)
#include
<TTCN3.hh>
int
BTPCodec
::
encode
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
p
,
OCTETSTRING
&
data
)
{
return
0
;
TTCN_Buffer
b
;
p
.
header
().
encode
(
LibItsBtp__TypesAndValues
::
BtpHeader_descr_
,
b
,
TTCN_EncDec
::
CT_RAW
);
b
.
get_string
(
data
);
return
0
;
}
int
BTPCodec
::
decode
(
const
OCTETSTRING
&
data
,
LibItsBtp__TypesAndValues
::
BtpPacket
&
msg
)
int
BTPCodec
::
decode
(
const
OCTETSTRING
&
data
,
LibItsBtp__TypesAndValues
::
BtpPacket
&
p
)
{
return
0
;
TTCN_Buffer
b
(
data
);
p
.
header
().
decode
(
LibItsBtp__TypesAndValues
::
BtpHeader_descr_
,
b
,
TTCN_EncDec
::
CT_RAW
);
return
0
;
}
ccsrc/Protocols/BTP/BTPCodec.hh
View file @
12c0107f
#ifndef BTPCODEC_H
#define BTPCODEC_H
#include
"BTPTypes.hh"
#include
"Codec.hh"
class
BTPCodec
:
public
Codec
<
LibItsBtp__TypesAndValues
::
BtpPacket
>
{
namespace
LibItsBtp__TestSystem
{
class
BtpReq
;
class
BtpInd
;
}
namespace
LibItsBtp__TypesAndValues
{
class
BtpPacket
;
}
class
BTPCodec
:
public
Codec
<
LibItsBtp__TypesAndValues
::
BtpPacket
,
LibItsBtp__TypesAndValues
::
BtpPacket
>
{
public:
virtual
int
encode
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
,
OCTETSTRING
&
data
);
virtual
int
decode
(
const
OCTETSTRING
&
data
,
LibItsBtp__TypesAndValues
::
BtpPacket
&
);
virtual
int
encode
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
,
OCTETSTRING
&
data
);
virtual
int
decode
(
const
OCTETSTRING
&
data
,
LibItsBtp__TypesAndValues
::
BtpPacket
&
);
};
#endif
ccsrc/Protocols/BTP/BTPLayer.cc
View file @
12c0107f
#include
"BTPLayer.hh"
#include
"BTPTypes.hh"
void
BTPLayer
::
sendMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
m
,
const
Params
&
params
){
void
BTPLayer
::
sendMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
p
,
const
Params
&
params
){
OCTETSTRING
data
;
_codec
.
encode
(
m
,
data
);
sendData
(
data
,
P
arams
()
);
_codec
.
encode
(
p
,
data
);
sendData
(
data
,
p
arams
);
}
void
BTPLayer
::
sendData
(
const
OCTETSTRING
&
data
,
const
Params
&
params
){
...
...
@@ -14,9 +15,11 @@ void BTPLayer::receiveData(const OCTETSTRING& data, const Params& info)
{
LibItsBtp__TypesAndValues
::
BtpPacket
p
;
_codec
.
decode
(
data
,
p
);
receiveToAllPorts
(
p
,
info
);
if
(
p
.
payload
().
is_present
()){
receiveToAllLayers
(
p
.
payload
()().
rawPayload
(),
info
);
toAllUpperPorts
(
p
,
info
);
if
(
p
.
payload
().
is_present
())
{
toAllUpperLayers
(
p
.
payload
()().
rawPayload
(),
info
);
}
}
...
...
@@ -27,14 +30,12 @@ public:
virtual
Layer
*
createLayer
(
const
std
::
string
&
type
,
const
std
::
string
&
param
);
};
BTPFactory
::
BTPFactory
()
{
BTPFactory
::
BTPFactory
(){
// register factory
StackFactory
::
getInstance
()
->
r
egisterLayerFactory
(
"BTP"
,
this
);
LayerStackBuilder
::
R
egisterLayerFactory
(
"BTP"
,
this
);
}
Layer
*
BTPFactory
::
createLayer
(
const
std
::
string
&
type
,
const
std
::
string
&
param
)
{
Layer
*
BTPFactory
::
createLayer
(
const
std
::
string
&
type
,
const
std
::
string
&
param
){
return
new
BTPLayer
();
}
...
...
ccsrc/Protocols/BTP/BTPLayer.hh
View file @
12c0107f
#ifndef BTP_LAYER_H
#define BTP_LAYER_H
#include
"Layer.hh"
#include
"BTPTypes.hh"
#include
"BTPCodec.hh"
class
LibItsBtp__TestSystem
::
BtpPort
;
namespace
LibItsBtp__TypesAndValues
{
class
BtpPacket
;
}
namespace
LibItsBtp__TestSystem
{
class
BtpPort
;
}
class
BTPLayer
:
public
TLayer
<
LibItsBtp__TestSystem
::
BtpPort
>
{
BTPCodec
_codec
;
public:
inline
BTPLayer
()
:
TLayer
<
LibItsBtp__TestSystem
::
BtpPort
>
(){}
virtual
~
BTPLayer
(){}
void
sendMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
,
const
Params
&
param
);
/*
void receiveToAllPorts(const BTPA& m, const Params& param);
void receiveToAllPorts(const BTPB& m, const Params& param);
*/
virtual
void
sendData
(
const
OCTETSTRING
&
data
,
const
Params
&
params
);
virtual
void
receiveData
(
const
OCTETSTRING
&
data
,
const
Params
&
info
);
};
...
...
ccsrc/Protocols/BTP/BTPPort.cc
deleted
100755 → 0
View file @
9a5a38ed
#include
"BTPPort.hh"
#include
"BTPLayer.hh"
void
BTPPort
::
receiveMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
m
,
const
Params
&
)
{
}
void
BTPPort
::
outgoingMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
a
,
const
Params
&
info
)
{
layer
->
sendMsg
(
a
,
info
);
}
ccsrc/Protocols/BTP/BTPPort.hh
deleted
100755 → 0
View file @
9a5a38ed
#ifndef BTPPORT_H
#define BTPPORT_H
#include
"BTPLayer.hh"
class
BTPPort
{
BTPLayer
*
layer
;
public:
BTPPort
(){};
void
receiveMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
,
const
Params
&
);
void
outgoingMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
,
const
Params
&
);
};
#endif
\ No newline at end of file
ccsrc/Protocols/BTP/Makefile
deleted
100755 → 0
View file @
9a5a38ed
PROJECTROOT
=
../..
BUILDROOT
=
../../../bin
PROJECT
=
its-proto-btp
DEBUG
=
yes
testdir
=
tests
packages
=
titan
alibs
=
$(PROJECT)
sources
:=
BTPCodec.cpp BTPLayer.cpp BTPPort.cpp
headers
:=
BTPCodec.h BTPLayer.h BTPPort.h BTPTypes.h
includes
=
../../Framework
defines
=
WIN32
include
../../common.mk
ccsrc/Protocols/GeoNetworking/GeoNetworkingCodec.cc
View file @
12c0107f
...
...
@@ -4,6 +4,8 @@
#include
"GeoNetworkingCodec.hh"
#include
"loggers.hh"
#include
"GeoNetworking_Types.hh"
int
GeoNetworkingCodec
::
encode
(
const
LibItsGeoNetworking__TypesAndValues
::
GeoNetworkingPdu
&
msg
,
OCTETSTRING
&
data
)
{
loggers
::
loggers
::
log_msg
(
">>> GeoNetworkingCodec::encode: "
,
(
const
Base_Type
&
)
msg
);
...
...
ccsrc/Protocols/GeoNetworking/GeoNetworkingCodec.hh
View file @
12c0107f
#ifndef GNCODEC_H
#define GNCODEC_H
#include
"GeoNetworking_Types.hh"
#include
"Codec.hh"
class
GeoNetworkingCodec
:
public
Codec
<
LibItsGeoNetworking__TypesAndValues
::
GeoNetworkingPdu
>
{
namespace
LibItsGeoNetworking__TypesAndValues
{
class
GeoNetworkingPdu
;
}
class
GeoNetworkingCodec
:
public
Codec
<
LibItsGeoNetworking__TypesAndValues
::
GeoNetworkingPdu
,
LibItsGeoNetworking__TypesAndValues
::
GeoNetworkingPdu
>
{
unsigned
int
_plLength_position
;
...
...
ccsrc/common.mk
View file @
12c0107f
...
...
@@ -169,11 +169,11 @@ $(cobjects): $(objdir)/%.o: %.c
$(cppobjects)
:
$(objdir)/%.o: %.cpp
@
mkdir
-p
$(
dir
$@
)
$(GPP)
$(cflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
$(GPP)
$(cflags)
$(ccflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
$(ccobjects)
:
$(objdir)/%.o: %.cc
@
mkdir
-p
$(
dir
$@
)
$(GPP)
$(cflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
$(GPP)
$(cflags)
$(ccflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
clean
:
rm
-rf
$(alibnames)
$(solibnames)
$(binnames)
$(testbins)
$(objects)
...
...
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