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
cb1840e1
Commit
cb1840e1
authored
May 03, 2017
by
filatov
Browse files
Add makefiles for tests, use real BTP packets
parent
2948d1dd
Changes
11
Hide whitespace changes
Inline
Side-by-side
ccsrc/Framework/Layer.h
View file @
cb1840e1
...
...
@@ -27,18 +27,19 @@ class Layer {
template
<
typename
TPort
>
class
TLayer
:
public
Layer
{
typedef
std
::
vector
<
TPort
*>
TPortList
;
typedef
typename
std
::
vector
<
TPort
*>::
iterator
TPortListIterator
;
TPortList
upperPorts
;
public:
TLayer
(){}
void
addUpperPort
(
TPort
*
);
void
removeUpperPort
(
TPort
*
);
/*
template <typename
Msg
> void receiveToAllPorts(
Msg*
m, const Param& param) {
for(TPortList
::i
terator it=upperPorts.begin(); it<upperPorts.end(); ++it){
template
<
typename
T
>
void
receiveToAllPorts
(
const
T
&
m
,
const
Param
s
&
param
)
{
for
(
TPortList
I
terator
it
=
upperPorts
.
begin
();
it
<
upperPorts
.
end
();
++
it
){
(
*
it
)
->
receiveMsg
(
m
,
param
);
}
}
*/
};
class
LayerFactory
{
...
...
ccsrc/Framework/Makefile
0 → 100755
View file @
cb1840e1
PROJECTROOT
=
..
BUILDROOT
=
../../bin
PROJECT
=
its-framework
DEBUG
=
yes
testdir
=
tests
srcdir
=
src
alibs
=
$(PROJECT)
sources
:=
LayerFactory.cpp
headers
:=
Codec.h Layer.h
includes
:=
.
..
include
../common.mk
ccsrc/Protocols/BTP/BTPCodec.cpp
View file @
cb1840e1
#include
"BTPCodec.h"
int
BTP
A
Codec
::
encode
(
const
BTPA
&
msg
,
OCTETSTRING
&
data
)
int
BTPCodec
::
encode
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
msg
,
OCTETSTRING
&
data
)
{
return
0
;
}
int
BTPACodec
::
decode
(
const
OCTETSTRING
&
data
,
BTPA
&
msg
)
{
return
0
;
}
int
BTPBCodec
::
encode
(
const
BTPB
&
msg
,
OCTETSTRING
&
data
)
{
return
0
;
}
int
BTPBCodec
::
decode
(
const
OCTETSTRING
&
data
,
BTPB
&
msg
)
int
BTPCodec
::
decode
(
const
OCTETSTRING
&
data
,
LibItsBtp__TypesAndValues
::
BtpPacket
&
msg
)
{
return
0
;
}
ccsrc/Protocols/BTP/BTPCodec.h
View file @
cb1840e1
...
...
@@ -3,14 +3,10 @@
#include
"BTPTypes.h"
#include
"Codec.h"
class
BTPACodec
:
public
Codec
<
BTPA
>
{
virtual
int
encode
(
const
BTPA
&
msg
,
OCTETSTRING
&
data
);
virtual
int
decode
(
const
OCTETSTRING
&
data
,
BTPA
&
msg
);
};
class
BTPBCodec
:
public
Codec
<
BTPB
>
{
virtual
int
encode
(
const
BTPB
&
msg
,
OCTETSTRING
&
data
);
virtual
int
decode
(
const
OCTETSTRING
&
data
,
BTPB
&
msg
);
class
BTPCodec
:
public
Codec
<
LibItsBtp__TypesAndValues
::
BtpPacket
>
{
public:
virtual
int
encode
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
,
OCTETSTRING
&
data
);
virtual
int
decode
(
const
OCTETSTRING
&
data
,
LibItsBtp__TypesAndValues
::
BtpPacket
&
);
};
#endif
ccsrc/Protocols/BTP/BTPLayer.cpp
View file @
cb1840e1
#include
"BTPLayer.h"
#include
"BTPPort.h"
void
BTPLayer
::
sendMsg
(
const
BTPA
&
m
,
const
Params
&
params
){
void
BTPLayer
::
sendMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
m
,
const
Params
&
params
){
OCTETSTRING
data
;
_
a
.
encode
(
m
,
data
);
_
codec
.
encode
(
m
,
data
);
sendData
(
data
,
Params
());
}
void
BTPLayer
::
sendMsg
(
const
BTPB
&
m
,
const
Params
&
params
){
OCTETSTRING
data
;
_b
.
encode
(
m
,
data
);
sendData
(
data
,
Params
());
}
void
BTPLayer
::
sendData
(
const
OCTETSTRING
&
data
,
const
Params
&
params
){
sendToAllLayers
(
data
,
params
);
}
void
BTPLayer
::
receiveData
(
const
OCTETSTRING
&
data
,
const
Params
&
info
)
{
BTPB
b
;
BTPA
a
;
receiveToAllPorts
(
a
,
Params
());
receiveToAllPorts
(
b
,
Params
());
receiveToAllLayers
(
data
,
Params
());
//a.payload shall be sent!
LibItsBtp__TypesAndValues
::
BtpPacket
p
;
_codec
.
decode
(
data
,
p
);
receiveToAllPorts
(
p
,
info
);
if
(
p
.
payload
().
is_present
()){
receiveToAllLayers
(
p
.
payload
()().
rawPayload
(),
info
);
}
}
class
BTPFactory
:
public
LayerFactory
{
...
...
@@ -33,8 +30,8 @@ public:
BTPFactory
::
BTPFactory
()
{
StackFactory
::
getInstance
()
->
registerLayerFactory
(
"BTP"
,
this
);
// register factory
StackFactory
::
getInstance
()
->
registerLayerFactory
(
"BTP"
,
this
);
}
Layer
*
BTPFactory
::
createLayer
(
const
std
::
string
&
type
,
const
std
::
string
&
param
)
...
...
ccsrc/Protocols/BTP/BTPLayer.h
View file @
cb1840e1
...
...
@@ -6,16 +6,16 @@
class
BTPPort
;
class
BTPLayer
:
public
TLayer
<
BTPPort
>
{
BTPACodec
*
_a
;
BTPBCodec
*
_b
;
BTPCodec
_codec
;
public:
BTPLayer
()
:
TLayer
<
BTPPort
>
(){}
;
v
oid
sendMsg
(
const
BTPA
&
,
const
Params
&
param
);
void
sendMsg
(
const
BTPB
&
,
const
Params
&
param
);
inline
BTPLayer
()
:
TLayer
<
BTPPort
>
(){}
v
irtual
~
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.cpp
View file @
cb1840e1
#include
"BTPPort.h"
#include
"BTPLayer.h"
void
BTPPort
::
receiveMsg
(
const
BTPA
&
m
)
{
void
BTPPort
::
receiveMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
m
,
const
Params
&
)
{
}
void
BTPPort
::
receiveMsg
(
const
BTPB
&
m
)
{
}
void
BTPPort
::
outgoingMsg
(
const
BTPA
&
a
)
{
layer
->
sendMsg
(
a
);
}
void
BTPPort
::
outgoingMsg
(
const
BTPB
&
b
)
{
layer
->
sendMsg
(
b
);
void
BTPPort
::
outgoingMsg
(
const
LibItsBtp__TypesAndValues
::
BtpPacket
&
a
,
const
Params
&
info
)
{
layer
->
sendMsg
(
a
,
info
);
}
ccsrc/Protocols/BTP/BTPPort.h
View file @
cb1840e1
#ifndef BTPPORT_H
#define BTPPORT_H
#include
"BTPTypes.h"
class
BTPLayer
;
#include
"BTPLayer.h"
class
BTPPort
{
BTPLayer
*
layer
;
public:
BTPPort
(){};
void
receiveMsg
(
const
BTPA
&
);
void
receiveMsg
(
const
BTPB
&
);
void
outgoingMsg
(
const
BTPA
&
);
void
outgoingMsg
(
const
BTPB
&
);
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/BTPTypes.h
View file @
cb1840e1
#ifndef BTPTYPES_H
#define BTPTYPES_H
class
BTPA
{};
class
BTPB
{};
#include
"LibItsBtp_TypesAndValues.hh"
#endif
ccsrc/Protocols/BTP/Makefile
0 → 100755
View file @
cb1840e1
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/common.mk
0 → 100755
View file @
cb1840e1
export
LANG
=
en_US
ALL_CONFIGURATIONS
:=
POSIX WIN32
.PHONY
:
all clean tests docs cleandocs distr DUMMY
# Configurations
TITAN_HOME
=
C:/Eclipse/Titan
OPENSSL_WIN32
=
C:/OpenSSL/Win32
CSHAREDDIR
?=
cshared
CXMLDIR
?=
cxml
ifeq
($(ARCH),)
ARCH
=
$(
shell
gcc
-dumpmachine
)
GCC
:=
gcc
GPP
:=
g++
else
GCC
:=
$(
addprefix
$(
addsuffix
-,
$(ARCH)
)
, gcc
)
GPP
:=
$(
addprefix
$(
addsuffix
-,
$(ARCH)
)
, g++
)
endif
ifneq
($(findstring w32,$(ARCH)),)
packages
:=
$(
filter-out
readline threads,
$(packages)
)
CFG
+=
WIN32
else
CFG
+=
POSIX
ifeq
($(findstring cygwin,$(ARCH)),)
cflags
+=
-fPIC
endif
endif
cflags
+=
-Wall
ifeq
($(DEBUG),)
DEBUG
=
no
endif
ifeq
($(DEBUG),yes)
cflags
+=
-g
-O0
defines
+=
DEBUG
dsuffix
=
-d
else
defines
+=
NDEBUG
cflags
+=
-O2
endif
ifneq
($(filter readline, $(packages)),)
defines
+=
USE_READLINE
libs
+=
-lreadline
endif
ifneq
($(filter dmalloc, $(packages)),)
defines
+=
DMALLOC DMALLOC_FUNC_CHECK
libs
+=
-ldmalloc
dsuffix
=
-dmalloc
endif
ifneq
($(filter thread, $(packages)),)
defines
+=
USE_THREADS
libs
+=
-lpthread
endif
ifneq
($(filter profile, $(packages)),)
cflags
+=
-pg
endif
ifneq
($(filter openssl, $(packages)),)
ifneq
($(findstring mingw32,$(ARCH)),)
includes
+=
$(OPENSSL_WIN32)
/include
libs
+=
$(OPENSSL_WIN32)
/lib/MinGW/libeay32.a
$(OPENSSL_WIN32)
/lib/MinGW/ssleay32.a
else
libs
+=
-lssl
-lcrypto
endif
endif
ifneq
($(filter cxml, $(packages)),)
predirs
+=
$(CXMLDIR)
includes
+=
$(CXMLDIR)
endif
ifneq
($(filter cshared, $(packages)),)
predirs
+=
$(CSHAREDDIR)
includes
+=
$(CSHAREDDIR)
endif
ifneq
($(filter titan, $(packages)),)
includes
+=
$(TITAN_HOME)
/include
$(BUILDROOT)
endif
ifeq
($(testdir), )
testdir
:=
tests
endif
includes
+=
$(
foreach
cfg,
$(CFG)
,
$
(
includes-
$(cfg)
))
defines
+=
$(
foreach
cfg,
$(CFG)
,
$
(
defines-
$(cfg)
))
libs
+=
$(
foreach
cfg,
$(CFG)
,
$
(
libs-
$(cfg)
))
sources
+=
$(
foreach
cfg,
$(CFG)
,
$
(
sources-
$(cfg)
))
headers
+=
$(
foreach
cfg,
$(CFG)
,
$
(
headers-
$(cfg)
))
tests
+=
$(
foreach
cfg,
$(CFG)
,
$
(
tests-
$(cfg)
))
distfiles
+=
$(
foreach
cfg,
$(CFG)
,
$
(
distfiles-
$(cfg)
))
predirs
+=
$(
foreach
cfg,
$(CFG)
,
$
(
predirs-
$(cfg)
))
postdirs
+=
$(
foreach
cfg,
$(CFG)
,
$
(
postdirs-
$(cfg)
))
tests
:=
$(
addprefix
$(
addsuffix
/,
$(testdir)
)
,
$(tests)
)
sources
:=
$(
addprefix
$(
addsuffix
/,
$(srcdir)
)
,
$(sources)
)
headers
:=
$(
addprefix
$(
addsuffix
/,
$(incdir)
)
,
$(headers)
)
cflags
+=
$(
addprefix
-I
,
$(includes)
)
$(
addprefix
-D
,
$(defines)
)
csources
:=
$(
filter
%.c,
$(sources)
)
cppsources
:=
$(
filter
%.cpp,
$(sources)
)
ccsources
:=
$(
filter
%.cc,
$(sources)
)
othsources
:=
$(
filter-out
$(csources)
$(cppsources)
$(ccsources)
,
$(sources)
)
ifeq
($(BUILDROOT),)
BUILDROOT
=
.
endif
outdir
:=
$(BUILDROOT)
/
$(ARCH)$(dsuffix)
objdir
:=
$(outdir)
/
$(PROJECT)
testbins
:=
$(
patsubst
%.c,
$(outdir)
/%,
$(tests)
)
dirs
:=
$(objdir)
$(outdir)
/tests
cobjects
:=
$(
patsubst
%.c,
$(objdir)
/%.o,
$(csources)
)
cppobjects
:=
$(
patsubst
%.cpp,
$(objdir)
/%.o,
$(cppsources)
)
ccobjects
:=
$(
patsubst
%.cc,
$(objdir)
/%.o,
$(ccsources)
)
objects
:=
$(cobjects)
$(cppobjects)
$(ccobjects)
alibnames
:=
$(
patsubst
%,
$(outdir)
/lib%.a,
$(alibs)
)
solibnames
:=
$(
patsubst
%,
$(outdir)
/lib%.so,
$(solibs)
)
binnames
:=
$(
patsubst
%,
$(outdir)
/%,
$(bins)
)
ldflags
+=
$(
patsubst
%,
-L
%,
$(outdir)
$(libdirs)
)
ifneq
($(filter cxml, $(packages)),)
libs
+=
$(outdir)
/libcxml.a
endif
ifneq
($(filter cshared, $(packages)),)
libs
+=
$(outdir)
/libcshared.a
endif
all
:
$(dirs) $(predirs) $(alibnames) $(solibnames) $(binnames) $(postdirs)
tests
:
all $(testbins)
$(predirs) $(postdirs)
:
DUMMY
$(MAKE)
-C
$@
BUILDROOT
=
$(
realpath
$(BUILDROOT)
)
DEBUG
=
$(DEBUG)
$(alibnames)
:
$(outdir)/lib%.a : $(objects)
ar rcs
$@
$^
$(solibnames)
:
$(outdir)/lib%.so : $(objects)
$(GCC)
$(cflags)
-shared
$(ldflags)
-o
$@
$^
$(csharedlib)
$(libs)
$(binnames)
:
$(outdir)/% : $(objects)
$(GCC)
$(cflags)
$(ldflags)
-o
$@
$^
$(csharedlib)
$(libs)
$(testbins)
:
$(alibnames)
$(testbins)
:
$(outdir)/tests/% : tests/%.c
$(GCC)
$(cflags)
-o
$@
$<
$(alibnames)
$(libs)
$(dirs)
:
mkdir
-p
$@
$(cobjects)
:
$(objdir)/%.o: %.c
@
mkdir
-p
$(
dir
$@
)
$(GCC)
$(cflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
$(cppobjects)
:
$(objdir)/%.o: %.cpp
@
mkdir
-p
$(
dir
$@
)
$(GPP)
$(cflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
$(ccobjects)
:
$(objdir)/%.o: %.cc
@
mkdir
-p
$(
dir
$@
)
$(GPP)
$(cflags)
-o
$@
-MMD
-MF
$(objdir)
/
$*
.d
-c
$<
clean
:
rm
-rf
$(alibnames)
$(solibnames)
$(binnames)
$(testbins)
$(objects)
distfiles
+=
$(
wildcard
Makefile
$(DOXYFILE)
)
dist
:
-
rm
-rf
$(PROJECT)
$(PROJECT)
-
$(
shell
date
-u
'+%Y%m%d'
)
.tar.gz
mkdir
$(PROJECT)
cp
--parents
$(sources)
$(headers)
$(distfiles)
$(
addprefix
tests/,
$(tests)
)
$(PROJECT)
tar
-zcvf
$(PROJECT)
-
$(
shell
date
-u
'+%Y%m%d'
)
.tar.gz
$(PROJECT)
rm
-rf
$(PROJECT)
# tar -zcvf $(PROJECT)-$(shell date -u '+%Y%m%d').tar.gz $(sources) $(headers) $(distfiles) $(addprefix tests/, $(tests))
ifneq
(,$(DOXYFILE))
docs
:
$(DOXYFILE)
doxygen
$(DOXYFILE)
cleandocs
:
rm
-rf
doc/html
endif
include
$(wildcard $(addsuffix /*.d, $(objdir)))
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