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
999abd07
Commit
999abd07
authored
Sep 14, 2018
by
Denis Filatov
Browse files
Merge branch 'STF525' of
https://forge.etsi.org/gitlab/ITS/ITS
into STF525
parents
1489a789
9b425776
Changes
12
Hide whitespace changes
Inline
Side-by-side
ccsrc/EncDec/LibItsHttp_Encdec.cc
View file @
999abd07
...
...
@@ -7,14 +7,22 @@
namespace
LibItsHttp__EncdecDeclarations
{
BITSTRING
fx__enc__http__message
(
const
LibItsHttp__TypesAndValues
::
HttpMessage
&
p
)
{
return
BITSTRING
();
}
INTEGER
fx__dec__http__message
(
BITSTRING
&
pdu
,
LibItsHttp__TypesAndValues
::
HttpMessage
&
p
)
{
loggers
::
get_instance
().
log_msg
(
">>> fx__dec__http__response: "
,
pdu
);
BITSTRING
fx__enc__http__message
(
const
LibItsHttp__TypesAndValues
::
HttpMessage
&
p
)
{
loggers
::
get_instance
().
log_msg
(
">>> fx__enc__http__message: "
,
(
const
Base_Type
&
)
p
);
OCTETSTRING
os
=
bit2oct
(
pdu
)
;
http_codec
codec
;
codec
.
d
ecode
(
os
,
p
);
OCTETSTRING
os
;
http_codec
codec
;
codec
.
e
n
code
(
p
,
os
);
return
0
;
}
return
oct2bit
(
os
);
}
INTEGER
fx__dec__http__message
(
BITSTRING
&
pdu
,
LibItsHttp__TypesAndValues
::
HttpMessage
&
p
)
{
loggers
::
get_instance
().
log_msg
(
">>> fx__dec__http__message: "
,
pdu
);
OCTETSTRING
os
=
bit2oct
(
pdu
);
http_codec
codec
;
codec
.
decode
(
os
,
p
);
return
0
;
}
}
// End of namespace LibItsHttp__EncdecDeclarations
ccsrc/Protocols/Http/http_codec.cc
View file @
999abd07
...
...
@@ -15,6 +15,7 @@
int
http_codec
::
encode
(
const
LibItsHttp__TypesAndValues
::
HttpMessage
&
msg
,
OCTETSTRING
&
data
)
{
loggers
::
get_instance
().
log_msg
(
">>> http_codec::encode: "
,
(
const
Base_Type
&
)
msg
);
loggers
::
get_instance
().
log
(
">>> http_codec::encode: %p"
,
this
);
TTCN_EncDec
::
clear_error
();
TTCN_Buffer
encoding_buffer
;
...
...
@@ -124,27 +125,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
int
http_codec
::
encode_request
(
const
LibItsHttp__TypesAndValues
::
Request
&
p_request
,
TTCN_Buffer
&
p_encoding_buffer
)
{
loggers
::
get_instance
().
log_msg
(
">>> http_codec::encode_request: "
,
(
const
Base_Type
&
)
p_request
);
const
OPTIONAL
<
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
>&
v
=
p_request
.
body
();
OCTETSTRING
os
;
if
(
v
.
ispresent
())
{
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
body
=
static_cast
<
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&>
(
*
v
.
get_opt_value
());
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_request: body: "
,
body
);
if
(
encode_body
(
body
,
os
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_codec::encode_request: Failed to encode HTTP body"
);
_ec
.
length
=
0
;
_ec
.
is_content_length_present
=
0x00
;
}
else
{
_ec
.
length
=
os
.
lengthof
();
_ec
.
is_content_length_present
=
0x01
;
}
loggers
::
get_instance
().
log
(
"http_codec::encode_request: length=%d"
,
_ec
.
length
);
}
else
{
loggers
::
get_instance
().
log
(
"http_codec::encode_request: HTTP body field not present"
);
_ec
.
length
=
0
;
_ec
.
is_content_length_present
=
0x00
;
}
// Encode generic part
p_encoding_buffer
.
put_cs
(
p_request
.
method
());
p_encoding_buffer
.
put_c
(
' '
);
...
...
@@ -154,41 +135,74 @@ int http_codec::encode_request(const LibItsHttp__TypesAndValues::Request& p_requ
p_encoding_buffer
.
put_c
(
'.'
);
p_encoding_buffer
.
put_cs
(
int2str
(
p_request
.
version__minor
()));
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
// Encode headers
// Encode headers excepeted the Content-length
const
LibItsHttp__TypesAndValues
::
HeaderLines
&
headers
=
p_request
.
header
();
std
::
string
content_type
;
for
(
int
i
=
0
;
i
<
headers
.
size_of
();
i
++
)
{
const
LibItsHttp__TypesAndValues
::
HeaderLine
&
header
=
headers
[
i
];
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_request: Processing header "
,
header
.
header__name
());
p_encoding_buffer
.
put_cs
(
header
.
header__name
());
p_encoding_buffer
.
put_cs
(
": "
);
if
(
std
::
string
(
static_cast
<
const
char
*>
(
header
.
header__name
())).
compare
(
"Content-length"
)
==
0
)
{
if
(
_ec
.
length
!=
0
)
{
p_encoding_buffer
.
put_cs
(
int2str
(
_ec
.
length
+
2
/*Stand for the last CRLF*/
));
_ec
.
is_content_length_present
=
0x01
;
}
else
{
p_encoding_buffer
.
put_cs
(
"0"
);
_ec
.
is_content_length_present
=
0x00
;
}
loggers
::
get_instance
().
log
(
"http_codec::encode_request: Content-length: %d - %x"
,
_ec
.
length
,
_ec
.
is_content_length_present
);
if
(
std
::
string
(
static_cast
<
const
char
*>
(
header
.
header__name
())).
compare
(
"Content-length"
)
==
0
)
{
// Skip it, processed later
continue
;
}
else
{
const
OPTIONAL
<
LibItsHttp__TypesAndValues
::
charstring__list
>&
o
=
header
.
header__value
();
if
(
o
.
ispresent
())
{
const
LibItsHttp__TypesAndValues
::
charstring__list
&
v
=
dynamic_cast
<
const
OPTIONAL
<
LibItsHttp__TypesAndValues
::
charstring__list
>
&>
(
o
);
if
(
v
.
size_of
()
>
0
)
{
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_request: Processing value "
,
v
[
0
]);
if
(
std
::
string
(
static_cast
<
const
char
*>
(
header
.
header__name
())).
compare
(
"Content-type"
)
==
0
)
{
// Store it for HTTP body payload encoding
loggers
::
get_instance
().
log
(
"http_codec::encode_request: Storing Content-type"
);
int
j
=
0
;
while
(
j
<
v
.
size_of
())
{
content_type
+=
v
[
j
++
];
}
// End of 'while' statement
}
p_encoding_buffer
.
put_cs
(
v
[
0
]);
int
j
=
1
;
while
(
j
<
v
.
size_of
())
{
p_encoding_buffer
.
put_cs
(
", "
);
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_request: Processing value "
,
v
[
j
]);
p_encoding_buffer
.
put_cs
(
v
[
j
]);
j
+=
1
;
p_encoding_buffer
.
put_cs
(
", "
);
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_request: Processing value "
,
v
[
j
]);
p_encoding_buffer
.
put_cs
(
v
[
j
++
]);
}
// End of 'while' statement
}
}
// else, do not include it
}
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
}
// End of 'for' statement
// Encode message body
const
OPTIONAL
<
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
>&
v
=
p_request
.
body
();
OCTETSTRING
os
;
if
(
v
.
ispresent
())
{
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
body
=
static_cast
<
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&>
(
*
v
.
get_opt_value
());
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_request: body: "
,
body
);
if
(
encode_body
(
body
,
os
,
content_type
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_codec::encode_request: Failed to encode HTTP body"
);
_ec
.
length
=
0
;
_ec
.
is_content_length_present
=
0x00
;
}
else
{
_ec
.
length
=
os
.
lengthof
();
_ec
.
is_content_length_present
=
0x01
;
}
loggers
::
get_instance
().
log
(
"http_codec::encode_request: length=%d"
,
_ec
.
length
);
}
else
{
loggers
::
get_instance
().
log
(
"http_codec::encode_request: HTTP body field not present"
);
_ec
.
length
=
0
;
_ec
.
is_content_length_present
=
0x00
;
}
// Encode Content-length header
if
(
_ec
.
length
!=
0
)
{
p_encoding_buffer
.
put_cs
(
int2str
(
_ec
.
length
+
2
/*Stand for the last CRLF*/
));
_ec
.
is_content_length_present
=
0x01
;
}
else
{
p_encoding_buffer
.
put_cs
(
"0"
);
_ec
.
is_content_length_present
=
0x00
;
}
loggers
::
get_instance
().
log
(
"http_codec::encode_request: Content-length: %d - %x"
,
_ec
.
length
,
_ec
.
is_content_length_present
);
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
if
(
_ec
.
is_content_length_present
==
0x01
)
{
...
...
@@ -203,16 +217,6 @@ int http_codec::encode_request(const LibItsHttp__TypesAndValues::Request& p_requ
int
http_codec
::
encode_response
(
const
LibItsHttp__TypesAndValues
::
Response
&
p_response
,
TTCN_Buffer
&
p_encoding_buffer
)
{
loggers
::
get_instance
().
log_msg
(
">>> http_codec::encode_response: "
,
(
const
Base_Type
&
)
p_response
);
const
OPTIONAL
<
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
>&
v
=
p_response
.
body
();
OCTETSTRING
os
;
if
(
v
.
ispresent
())
{
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
body
=
static_cast
<
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&>
(
*
v
.
get_opt_value
());
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_response: body: "
,
body
);
if
(
encode_body
(
body
,
os
)
==
-
1
)
{
_ec
.
length
=
0
;
}
}
// Encode generic part
p_encoding_buffer
.
put_cs
(
"HTTP/"
);
p_encoding_buffer
.
put_cs
(
int2str
(
p_response
.
version__major
()));
...
...
@@ -225,26 +229,29 @@ int http_codec::encode_response (const LibItsHttp__TypesAndValues::Response& p_r
p_encoding_buffer
.
put_cs
(
p_response
.
statustext
());
}
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
// Encode headers
// Encode headers excepeted the Content-length
const
LibItsHttp__TypesAndValues
::
HeaderLines
&
headers
=
p_response
.
header
();
std
::
string
content_type
;
for
(
int
i
=
0
;
i
<
headers
.
size_of
();
i
++
)
{
const
LibItsHttp__TypesAndValues
::
HeaderLine
&
header
=
headers
[
i
];
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_response: Processing header "
,
header
.
header__name
());
p_encoding_buffer
.
put_cs
(
header
.
header__name
());
p_encoding_buffer
.
put_cs
(
": "
);
if
(
std
::
string
(
static_cast
<
const
char
*>
(
header
.
header__name
())).
compare
(
"Content-Length"
)
==
0
)
{
if
(
_ec
.
length
!=
0
)
{
p_encoding_buffer
.
put_cs
(
int2str
(
_ec
.
length
+
2
/*Stand for the last CRLF*/
));
}
else
{
p_encoding_buffer
.
put_cs
(
"0"
);
}
_ec
.
is_content_length_present
=
0x01
;
continue
;
}
else
{
const
OPTIONAL
<
LibItsHttp__TypesAndValues
::
charstring__list
>&
o
=
header
.
header__value
();
if
(
o
.
ispresent
())
{
const
LibItsHttp__TypesAndValues
::
charstring__list
&
v
=
dynamic_cast
<
const
OPTIONAL
<
LibItsHttp__TypesAndValues
::
charstring__list
>
&>
(
o
);
if
(
v
.
size_of
()
>
0
)
{
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_response: Processing value "
,
v
[
0
]);
if
(
std
::
string
(
static_cast
<
const
char
*>
(
header
.
header__name
())).
compare
(
"Content-type"
)
==
0
)
{
// Store it for HTTP body payload encoding
int
j
=
1
;
while
(
j
<
v
.
size_of
())
{
content_type
+=
v
[
j
++
];
}
// End of 'while' statement
}
p_encoding_buffer
.
put_cs
(
v
[
0
]);
int
j
=
1
;
while
(
j
<
v
.
size_of
())
{
...
...
@@ -259,12 +266,43 @@ int http_codec::encode_response (const LibItsHttp__TypesAndValues::Response& p_r
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
}
// End of 'for' statement
// Encode message body
const
OPTIONAL
<
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
>&
v
=
p_response
.
body
();
OCTETSTRING
os
;
if
(
v
.
ispresent
())
{
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
body
=
static_cast
<
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&>
(
*
v
.
get_opt_value
());
loggers
::
get_instance
().
log_msg
(
"http_codec::encode_response: body: "
,
body
);
if
(
encode_body
(
body
,
os
,
content_type
)
==
-
1
)
{
_ec
.
length
=
0
;
_ec
.
is_content_length_present
=
0x00
;
}
else
{
_ec
.
length
=
os
.
lengthof
();
_ec
.
is_content_length_present
=
0x01
;
}
loggers
::
get_instance
().
log
(
"http_codec::encode_request: length=%d"
,
_ec
.
length
);
}
else
{
loggers
::
get_instance
().
log
(
"http_codec::encode_request: HTTP body field not present"
);
_ec
.
length
=
0
;
_ec
.
is_content_length_present
=
0x00
;
}
// Encode Content-length header
if
(
_ec
.
length
!=
0
)
{
p_encoding_buffer
.
put_cs
(
int2str
(
_ec
.
length
+
2
/*Stand for the last CRLF*/
));
_ec
.
is_content_length_present
=
0x01
;
}
else
{
p_encoding_buffer
.
put_cs
(
"0"
);
_ec
.
is_content_length_present
=
0x00
;
}
loggers
::
get_instance
().
log
(
"http_codec::encode_response: Content-length: %d - %x"
,
_ec
.
length
,
_ec
.
is_content_length_present
);
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
if
(
_ec
.
length
!=
0
)
{
p_encoding_buffer
.
put_os
(
os
);
p_encoding_buffer
.
put_cs
(
"
\r\n
"
);
}
return
0
;
}
...
...
@@ -331,12 +369,36 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue
}
}
int
http_codec
::
encode_body
(
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
p_message_body
,
OCTETSTRING
&
p_encoding_buffer
)
{
int
http_codec
::
encode_body
(
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
p_message_body
,
OCTETSTRING
&
p_encoding_buffer
,
const
std
::
string
&
p_content_type
)
{
loggers
::
get_instance
().
log_msg
(
">>> http_codec::encode_body: "
,
(
const
Base_Type
&
)
p_message_body
);
loggers
::
get_instance
().
log
(
"http_codec::encode_body: # of codecs=%d"
,
_codecs
.
size
());
loggers
::
get_instance
().
log
(
"http_codec::encode_body: # of codecs=%d - %p"
,
_codecs
.
size
(),
this
);
loggers
::
get_instance
().
log
(
"http_codec::encode_body: Content-type:'%s'"
,
p_content_type
.
c_str
());
// Sanity check
if
(
p_content_type
.
empty
())
{
loggers
::
get_instance
().
warning
(
"http_codec::encode_body: Failed to select a codec for HTTP body payload"
);
return
-
1
;
}
if
(
p_message_body
.
ischosen
(
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
::
ALT_binary__body
))
{
p_encoding_buffer
=
p_message_body
.
binary__body
().
raw
();
const
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
&
binary_body
=
p_message_body
.
binary__body
();
if
(
binary_body
.
ischosen
(
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
::
ALT_raw
))
{
p_encoding_buffer
=
OCTETSTRING
(
binary_body
.
raw
().
lengthof
(),
(
unsigned
char
*
)
static_cast
<
const
unsigned
char
*>
(
binary_body
.
raw
()));
}
else
{
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
codec
<
Record_Type
,
Record_Type
>
>
>::
const_iterator
it
;
bool
processed
=
false
;
if
(
p_content_type
.
find_first_of
(
"x-its"
)
!=
std
::
string
::
npos
)
{
it
=
_codecs
.
find
(
"etsi_ieee1609dot2"
);
if
(
it
!=
_codecs
.
cend
())
{
loggers
::
get_instance
().
log
(
"http_codec::encode_body: Call 'etsi_ts103097_data_codec'"
);
_codecs
[
"etsi_ieee1609dot2"
]
->
encode
((
Record_Type
&
)
binary_body
,
p_encoding_buffer
);
}
}
// TODO Add new HTTP message codec here
if
(
!
processed
)
{
loggers
::
get_instance
().
warning
(
"http_codec::encode_body: Unsupported HTTP codec, use raw field as default"
);
p_encoding_buffer
=
OCTETSTRING
(
binary_body
.
raw
().
lengthof
(),
(
unsigned
char
*
)
static_cast
<
const
unsigned
char
*>
(
binary_body
.
raw
()));
}
}
}
else
if
(
p_message_body
.
ischosen
(
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
::
ALT_html__body
))
{
p_encoding_buffer
=
OCTETSTRING
(
p_message_body
.
html__body
().
lengthof
(),
(
unsigned
char
*
)
static_cast
<
const
char
*>
(
p_message_body
.
html__body
()));
}
else
if
(
p_message_body
.
ischosen
(
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
::
ALT_text__body
))
{
...
...
@@ -345,15 +407,25 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
const
LibItsHttp__XmlMessageBodyTypes
::
XmlBody
&
xml_body
=
p_message_body
.
xml__body
();
if
(
xml_body
.
ischosen
(
LibItsHttp__XmlMessageBodyTypes
::
XmlBody
::
ALT_raw
))
{
p_encoding_buffer
=
OCTETSTRING
(
xml_body
.
raw
().
lengthof
(),
(
unsigned
char
*
)
static_cast
<
const
char
*>
(
xml_body
.
raw
()));
}
else
{
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
codec
<
Record_Type
,
Record_Type
>
>
>::
const_iterator
it
=
_codecs
.
find
(
"held"
);
if
(
it
!=
_codecs
.
cend
())
{
loggers
::
get_instance
().
log
(
"http_codec::encode_body: Call 'held_codec'"
);
_codecs
[
"held"
]
->
encode
((
Record_Type
&
)
xml_body
,
p_encoding_buffer
);
}
else
{
}
else
{
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
codec
<
Record_Type
,
Record_Type
>
>
>::
const_iterator
it
;
bool
processed
=
false
;
if
(
p_content_type
.
find_first_of
(
"held"
)
!=
std
::
string
::
npos
)
{
it
=
_codecs
.
find
(
"held"
);
if
(
it
!=
_codecs
.
cend
())
{
loggers
::
get_instance
().
log
(
"http_codec::encode_body: Call 'held_codec'"
);
_codecs
[
"held"
]
->
encode
((
Record_Type
&
)
xml_body
,
p_encoding_buffer
);
}
}
else
if
(
p_content_type
.
find_first_of
(
"lost"
)
!=
std
::
string
::
npos
)
{
it
=
_codecs
.
find
(
"lost"
);
if
(
it
!=
_codecs
.
cend
())
{
loggers
::
get_instance
().
log
(
"http_codec::encode_body: Call 'lost_codec'"
);
_codecs
[
"lost"
]
->
encode
((
Record_Type
&
)
xml_body
,
p_encoding_buffer
);
}
}
// TODO Add new HTTP message codec here
if
(
!
processed
)
{
loggers
::
get_instance
().
warning
(
"http_codec::encode_body: Unsupported HTTP codec, use raw field as default"
);
p_encoding_buffer
=
OCTETSTRING
(
xml_body
.
raw
().
lengthof
(),
(
unsigned
char
*
)
static_cast
<
const
char
*>
(
xml_body
.
raw
()));
// TODO Add new HTTP message codec here
}
}
}
else
{
...
...
@@ -532,11 +604,14 @@ void http_codec::set_payload_codecs(const std::string& p_codecs) {
loggers
::
get_instance
().
log
(
"http_codec::set_payload_codecs: %d - %s - %s - %s - %s - %s - %s - %s - %s"
,
m
.
size
(),
m
[
1
].
str
().
c_str
(),
m
[
2
].
str
().
c_str
(),
m
[
3
].
str
().
c_str
(),
m
[
4
].
str
().
c_str
(),
m
[
5
].
str
().
c_str
(),
m
[
6
].
str
().
c_str
(),
m
[
7
].
str
().
c_str
(),
m
[
8
].
str
().
c_str
());
for
(
unsigned
int
j
=
1
;
j
<
m
.
size
()
-
1
;
j
+=
3
)
{
// Exclude m[0]
loggers
::
get_instance
().
log
(
"http_codec::set_payload_codecs: insert (%s, %s), j = %d"
,
m
[
j
].
str
().
c_str
(),
m
[
j
+
1
].
str
().
c_str
(),
j
);
if
(
m
[
j
].
str
().
empty
())
{
break
;
}
std
::
string
key
(
m
[
j
].
str
());
_codecs
.
insert
(
std
::
make_pair
(
key
,
std
::
unique_ptr
<
codec
<
Record_Type
,
Record_Type
>
>
(
codec_stack_builder
::
get_instance
()
->
get_codec
(
m
[
j
+
1
].
str
().
c_str
()))));
}
// End of 'for' statement
}
// End of 'for' statement
//
loggers::get_instance().log("http_codec::set_payload_codecs: _codecs length=%d", _codecs.size());
loggers
::
get_instance
().
log
(
"http_codec::set_payload_codecs: _codecs length=%d
- %p
"
,
_codecs
.
size
()
,
this
);
}
catch
(
const
std
::
logic_error
&
e
){
loggers
::
get_instance
().
warning
(
"http_codec::set_payload_codecs: std::logic_error: %s"
,
e
.
what
());
...
...
ccsrc/Protocols/Http/http_codec.hh
View file @
999abd07
...
...
@@ -56,7 +56,7 @@ public:
private:
int
encode_request
(
const
LibItsHttp__TypesAndValues
::
Request
&
p_request
,
TTCN_Buffer
&
p_encoding_buffer
);
int
encode_response
(
const
LibItsHttp__TypesAndValues
::
Response
&
p_response
,
TTCN_Buffer
&
p_encoding_buffer
);
int
encode_body
(
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
p_message_body
,
OCTETSTRING
&
p_encoding_buffer
);
int
encode_body
(
const
LibItsHttp__MessageBodyTypes
::
HttpMessageBody
&
p_message_body
,
OCTETSTRING
&
p_encoding_buffer
,
const
std
::
string
&
p_content_type
);
int
decode_headers
(
TTCN_Buffer
&
decoding_buffer
,
LibItsHttp__TypesAndValues
::
HeaderLines
&
headers
);
int
decode_header
(
CHARSTRING
&
header_line
,
LibItsHttp__TypesAndValues
::
HeaderLine
&
header
);
...
...
docker/Dockerfile
View file @
999abd07
...
...
@@ -66,7 +66,7 @@ RUN echo "docker-titan-STF525" > /etc/hostname \
xsltproc \
&& DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y \
&& DEBIAN_FRONTEND=noninteractive apt-get autoclean \
&& useradd --create-home --shell /bin/bash
etsi
--groups sudo
username
\
&& useradd --create-home --shell /bin/bash --groups sudo
,etsi etsi
\
&& echo "etsi:etsi" | chpasswd \
&& adduser etsi sudo \
&& cd /home/etsi \
...
...
etc/AtsCAM/AtsCAM.cfg
View file @
999abd07
...
...
@@ -43,7 +43,7 @@ LogEventTypes:= Yes
# latitude : Latitude of the Test System
# longitude : Longitude of the Test System
# beaconing : Set to 1 if GnLayer shall start beaconing
# expiry : Beacon
n
ing timer expiry (ms)
# expiry : Beaconing timer expiry (ms)
# device_mode : Set to 1 if the layer shall encapsulate upper layer PDU
# secured_mode : Set to 1 if message exchanges shall be signed
# encrypted_mode : Set to 1 if message exchanges shall be encrypted
...
...
etc/AtsDENM/AtsDENM.cfg
View file @
999abd07
...
...
@@ -41,7 +41,7 @@ LogEventTypes:= Yes
# latitude : Latitude of the Test System
# longitude : Longitude of the Test System
# beaconing : Set to 1 if GnLayer shall start beaconing
# expiry : Beacon
n
ing timer expiry (ms)
# expiry : Beaconing timer expiry (ms)
# device_mode : Set to 1 if the layer shall encapsulate upper layer PDU
# secured_mode : Set to 1 if message exchanges shall be signed
# encrypted_mode : Set to 1 if message exchanges shall be encrypted
...
...
etc/AtsPki/AtsPki.cfg
View file @
999abd07
...
...
@@ -2,13 +2,8 @@
[MODULE_PARAMETERS]
# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.
# The GeoNetworking address of the IUT.
LibItsGeoNetworking_Pics.PICS_GN_LOCAL_GN_ADDR := {
typeOfAddress := e_initial,
stationType := e_unknown, #e_roadSideUnit,
stationCountryCode := 0, #33,
mid := '4C5E0C14D2EA'O
}
# IUT Station ID
LibItsCommon_Pixits.PX_IUT_STATION_ID := 2533729309
LibItsGeoNetworking_Pixits.PX_GN_UPPER_LAYER := e_btpB
...
...
@@ -19,7 +14,6 @@ LibItsSecurity_Pixits.PX_CERTIFICATE_POOL_PATH := "/home/vagrant/tmp";
# Configuration sub-directory to access certificate stored in files
LibItsSecurity_Pixits.PX_IUT_SEC_CONFIG_NAME := "test_01";
[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).
...
...
@@ -54,7 +48,7 @@ LogEventTypes:= Yes
# latitude : latitude of the Test System
# longitude : longitude of the Test System
# beaconing : Set to 1 if GnLayer shall start beaconing
# Beacon
n
ing timer expiry: expiry (ms)
# Beaconing timer expiry: expiry (ms)
# device_mode : Set to 1 if the layer shall encapsulate upper layer PDU
# secured_mode : Set to 1 if message exchanges shall be signed
# encrypted_mode : Set to 1 if message exchanges shall be encrypted
...
...
@@ -101,11 +95,11 @@ LogEventTypes:= Yes
# save_mode : 1 to save sent packet, 0 otherwise
# Single GeoNetworking component port
system.
geoNetworking
Port.params := "GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,
beaconing=0,expiry=1000)/ETH(mac_src=080027d2b658,mac_bc=FFFFFFFFFFFF,eth_type=8947
)/PCAP(mac_src=0800275
c4958
,nic=
eth1
,filter=and ether proto 0x8947)"
system.httpPort.params := "HTTP(codecs=gn:geonetworking_codec_codec)/TCP(debug=1,server=ptsv2.com,
port=80,
use_ssl=0)"
system.
cam
Port.params := "
CAM(next_header=btpB,header_type=tsb,header_sub_type=sh)/BTP/
GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,
distanceA=1500,distanceB=1500,angle=0,device_mode=1,beaconing=!)/ETH(mac_src=080027500f9b
)/PCAP(mac_src=0800275
00f9b
,nic=
tap0
,filter=and ether proto 0x8947)"
system.httpPort.params := "HTTP(codecs=gn:geonetworking_codec_codec)/TCP(debug=1,server=ptsv2.com,use_ssl=0)"
# GeoNetworking UpperTester port based on UDP
system.utPort.params := "UT_
GN(loopback=0)
/UDP(dst_ip=1
9
2.
168.0.250,dst_port=12345,src_ip=192.168.0.253,src_port=12345)/ETH(mac_src=080027d2b658,mac_dst=90fd61e61902,eth_type=0800)/PCAP(mac_src=080027d2b658,nic=eth1,filter=and udp port 12345
)"
system.utPort.params := "UT_
CAM
/UDP(dst_ip=1
7
2.
23.0.1,dst_port=8000
)"
[EXECUTE]
ItsPki_TestCases.TC_SEC_PKI_SND_EA_01_BV
...
...
etc/TestCodec/TestCodec.cfg
View file @
999abd07
...
...
@@ -23,6 +23,8 @@ LibItsSecurity_Pixits.PX_CERTIFICATE_POOL_PATH := "/home/vagrant/tmp"
# Configuration sub-directory to access certificate stored in files
LibItsSecurity_Pixits.PX_IUT_SEC_CONFIG_NAME := "Yann" #"cert_asn1c" #"test_01";
LibItsHttp_Pics.PICS_HEADER_HOST := "ptsv2.com"
[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).
...
...
@@ -136,6 +138,9 @@ system.ivimPort.params := "IVIM/BTP(type=btpB,dst_port=2005,src_port=0,device_mo
# GeoNetworking UpperTester port based on UDP
system.utPort.params := "UT_GN/UDP(dst_ip=192.168.56.1)"
# HTTP port
system.httpPort.params := "HTTP(codecs=etsi_ieee1609dot2:etsi_ts102941_codec)/TCP(debug=1,server=ptsv2.com,port=80,use_ssl=0)"
[EXECUTE]
# GeoNetworking Req
#TestCodec_GeoNetworking.tc_GeoNetReq_AnycastPacket
...
...
@@ -295,7 +300,7 @@ system.utPort.params := "UT_GN/UDP(dst_ip=192.168.56.1)"
#TestCodec_Certificates.tc_at_certificate_sha256_2
#TestCodec_Certificates.tc_at_certificate_sha256_3
#TestCodec_Certificates.tc_certificate_asn1c_1
TestCodec_Certificates.tc_certificate_asn1c_2
#
TestCodec_Certificates.tc_certificate_asn1c_2
# Secured messages
#TestCodec_SecuredMessages.tc_ssp_cam_1
#TestCodec_SecuredMessages.tc_ssp_cam_2
...
...
@@ -326,6 +331,7 @@ TestCodec_Certificates.tc_certificate_asn1c_2
#TestCodec_SignedAndEncryptedMessages.tc_decrypted_signed_message_4
# Pki
#TestCodec_Pki.tc_inner_ec_request_1
TestCodec_Pki.tc_http_inner_ec_request_1
#TestCodec_Pki.tc_inner_ec_request_2
#TestCodec_Pki.tc_inner_ec_response_1
...
...
scripts/merge_its_project.bash
View file @
999abd07
...
...
@@ -174,7 +174,7 @@ do
do
BN
=
`
basename
$j
`
s1
=
`
sha256sum
-b
$j
|
cut
-d
' '
-f1
`
s2
=
`
sha256sum
-b
${
TTCN_3_DST_PATH
}
/
$i
/
${
BN
}
|
cut
-d
' '
-f1
`
s2
=
`
sha256sum
-b
${
TTCN_3_DST_PATH
}
/
$i
/
ttcn/
${
BN
}
|
cut
-d
' '
-f1
`
if
[
${
s1
}
!=
${
s2
}
]
then
cp
${
TTCN_3_DST_PATH
}
/
$i
/ttcn/
${
BN
}
${
DEST_DIR
}
...
...
ttcn/AtsPki/ItsPki_TestCases.ttcn
View file @
999abd07
...
...
@@ -23,26 +23,19 @@ module ItsPki_TestCases {
import
from
EtsiTs102941TypesEnrolment
language
"ASN.1:1997"
all
;
import
from
EtsiTs102941MessagesItss
language
"ASN.1:1997"
all
;
import
from
EtsiTs103097Module
language
"ASN.1:1997"
all
;
import
from
ITS_Container
language
"ASN.1:1997"
all
;
import
from
CAM_PDU_Descriptions
language
"ASN.1:1997"
all
;
// LibItsCommon
import
from
LibItsCommon_TypesAndValues
all
;
import
from
LibItsCommon_Functions
all
;
import
from
LibItsCommon_TypesAndValues
all
;
import
from
LibItsCommon_ASN1_NamedNumbers
all
;
// LibItsGeoNetworking
import
from
LibItsGeoNetworking_TypesAndValues
all
;
import
from
LibItsGeoNetworking_Functions
all
;
import
from
LibItsGeoNetworking_Templates
all
;
import
from
LibItsGeoNetworking_Pics
all
;
// LibItsCam
import
from
LibItsCam_Templates
all
;
import
from
LibItsCam_TestSystem
all
;
// LibItsDenm
import
from
LibIts
Denm_Templat
es
all
;
import
from
LibIts
Denm_TestSystem
all
;
import
from
LibItsCam_Functions
all
;
import
from
LibItsCam_Templates
all
;
import
from
LibIts
Cam_TypesAndValu
es
all
;
import
from
LibIts
Cam_Pics
all
;
// LibItsSecurity
import
from
LibItsSecurity_TypesAndValues
all
;
...
...
@@ -70,21 +63,23 @@ module ItsPki_TestCases {
// Local variables
var
EtsiTs103097Certificate
v_certificate
;
var
HeaderLines
v_headers
;
var
charstring
vc_hashedId8ToBeUsed
:=
"CERT_IUT_F_AT"
;
// Test control
if
(
not
(
PICS_GN_SECURITY
))
{
log
(
"*** "
&
testcasename
()
&
":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***"
);
stop
;
if
(
not
PICS_CAM_GENERATION
or
PICS_RSU
)
{
log
(
"*** "
&
testcasename
()
&
": PICS_CAM_GENERATION and not PICS_RSU required for executing the TC ***"
);
setverdict
(
inconc
);
stop
;
}
// Test component configuration
vc_hashedId8ToBeUsed
:=
"CERT_IUT_F_AT"
;
f_cf
01
Up
();
// Initialise IUT with CERT_IUT_F_AT signed with CERT_IUT_F_AA
f_cfUp
();
// Initialise IUT with CERT_IUT_F_AT signed with CERT_IUT_F_AA
// Test adapter configuration
// Preamble
f_pr
Neighbour
();
f_pr
InitialState
();
f_readCertificate
(
vc_hashedId8ToBeUsed
,
v_certificate
);
f_selfOrClientSyncAndVerdictPreamble
(
c_prDone
,
e_success
);
...
...
@@ -129,9 +124,8 @@ module ItsPki_TestCases {
}
// End of 'alt' statement
// Postamble
f_poNeighbour
();
f_cf01Down
();
f_cfDown
();
}
// End of testcase TC_SEC_ITSS_SND_MSG_01_BV
}
// End of module ItsPki_TestCases
\ No newline at end of file
}
// End of module ItsPki_TestCases
LibIts
@
2055629d
Compare
00f08fdf
...
2055629d
Subproject commit
00f08fdf2fa8be4f21163899b4b419868d85011e
Subproject commit
2055629d7adf57e8db4ca1d3fb69abd2e2fc6a40
ttcn/TestCodec/TestCodec_Pki.ttcn
View file @
999abd07
...
...
@@ -29,23 +29,24 @@ module TestCodec_Pki {
// LibItsCommon
import
from
LibItsCommon_TypesAndValues
all
;
import
from
LibItsCommon_Functions
all
;
import
from
LibItsCommon_TypesAndValues
all
;
import
from
LibItsCommon_ASN1_NamedNumbers
all
;
// LibItsGeoNetworking
import
from
LibItsGeoNetworking_TypesAndValues
all
;
import
from
LibItsGeoNetworking_Functions
all
;
import
from
LibItsGeoNetworking_Templates
all
;
// LibItsSecurity
import
from
LibItsSecurity_TypesAndValues
all
;
import
from
LibItsSecurity_Templates
all
;
import
from
LibItsSecurity_Functions
all
;
// LibItsHttp
import
from
LibItsHttp_TypesAndValues
all
;
import
from
LibItsHttp_Templates
all
;
import
from
LibItsHttp_BinaryTemplates
all
;
import
from
LibItsHttp_Functions
all
;
// LibItsPki
import
from
LibItsPki_EncdecDeclarations
all
;
import
from
LibItsPki_Templates
all
;
import
from
LibItsPki_TestSystem
all
;
// TestCodec
import
from
TestCodec_TestAndSystem
all
;
...
...
@@ -55,17 +56,17 @@ module TestCodec_Pki {
var
EtsiTs103097Certificate
v_certificate
;
var
InnerEcRequest
v_innerEcRequest
;
var
InnerEcRequest
v_exp_innerEcReq
;
var
bitstring
v_exp_enc_msg
:=
oct2bit
(
'
0004544
F444F0100808
23C5C40E2D3117A493E97ECA2EA7AE164A2E3EBC856EEC760428442076370
ED
8
37
C831A5617008422388301018000FA60010380012481040301FFFF80012581050401FFFFFF8002008D8102010
0
'
O
);
var
bitstring
v_enc_msg
:=
oct2bit
(
'
8003008
0
db4f29fdf09200d2708300000000001a5617008422388301018000fa600103800124810403
01ffff8001
2581050401ffffff80018d810201008080823c5c40e2d3117a493e97eca2ea7ae164a2e3ebc856eec760428442076370ed83808051aae5e5db859816de75db80112fba869e2704829b912d1be3b082f2e531c061c5699757849f335c816ddda1742e3e6c0c2a0930146d1e0697bf035b14655afd
'
O
);
// CERT_IUT_
E_AT
.oer
var
Oct32
v_private_key
:=
'
9
e85f9242800761c6ee2889bb7bbad8942927caad8519729f8475ee50302e7f7
'
O
;
// CERT_IUT_
E_AT
.vkey
var
bitstring
v_exp_enc_msg
:=
oct2bit
(
'
0004544
F444F0100808
3A72B88B6A1ADEEBA7FC18772952F053A81BD18635EE5AB08
ED
1
37
6C107B5413968831874E3808466A8C
0
'
O
);
var
bitstring
v_enc_msg
:=
oct2bit
(
'
8003008
100288300000000001874
e3808466a8c001018080010e80012482080301ffff0301ffff800125820a0401ffffff0401ffffff800189820a0401ffffff04
01ffff
ff
8001
8a820a0401ffffff0401ffffff80018b820a0401ffffff0401ffffff80018c820a0401ffffff0401ffffff00018d0001600001610001620001630001640001650001660102808083a72b88b6a1adeeba7fc18772952f053a81bd18635ee5ab08ed1376c107b541398080c0290e397381bf7502a0e6a6b271d8e2f18fc8311f591f0528a673ee5169f670e224ac455b5e67eb251cc1467f6ffc6840987c8c8eb9245c22be73322b64ca54
'
O
);
// CERT_IUT_
A_RCA
.oer