Commit 5dd9e087 authored by YannGarcia's avatar YannGarcia
Browse files

Merge branch v2.2.1-dev into master

parents c56308e2 b3d46463
#!/bin/bash
# Copyright ETSI 2018
# Copyright ETSI 2018-2021
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt
#set -vx
set -vx
#set -e
cd "$(dirname "$0")"
cd $(dirname $0)
cd ./docker
run_dir="$(pwd)"
run_dir=`pwd`
./build.sh
# Docker version 2
cd ./virtualization/docker
./build.sh #--force-stfubuntu
#./run.sh
cd -
exit 0
if [ "$1" == "--remove" ]
then
docker rmi --force ttf_t012_mec:latest
fi
cd -
......@@ -203,10 +203,24 @@ Procedure:
- Clone the ETSI MEC Testing Framework project into $HOME/dev folder
```sh
$ git clone
$ git clone --recurse-submodules --branch TTF012_Mec https://forge.etsi.org/rep/mec/gs032p3-ttcn-test-suite.git ./TTF012_Mec
$ cd /home/etsi/dev/TTF012_Mec/ttcn/LibIts
$ rm -fr t3q
$ cd ttcn && rm -fr Common
```
- Update your default environment with the content of the script $HOME/dev/STF569_Mec/scripts/devenv.bash.ubuntu
- Apply patches
```sh
$ cd /home/etsi/dev/TTF012_Mec
$ cp ./ttcn/patch_lib_common_titan/module.mk ./ttcn/LibCommon/
$ cp ./ttcn/patch_lib_common_titan/*.ttcn ./ttcn/LibCommon/
$ cp ./ttcn/patch_lib_http/*.ttcn ./ttcn/LibIts/ttcn/Http/
$ cp ./ttcn/patch_lib_its/module.mk ./ttcn/LibIts/
```
- Update your default environment with the content of the script $HOME/dev/TTF012_Mec/scripts/devenv.bash.ubuntu
- Switch to the next clause (Usage)
......@@ -223,16 +237,17 @@ Procedure using Eclipse TITAN:
- Start eclipse using a new workspace, (e.g. with the name workspace_titan)
- Download and follow the steps to install Eclipse plugins for TITAN, accessible [here]{https://www.eclipse.org/downloads/download.php?file=/titan/Eclipse_installationguide.pdf}
- Open the workspace_titan
- Create a new TITAN project (e.g. STF569_Mec)
- Create a new TITAN project (e.g. TTF012_Mec)
<TODO>
Procedure in TITAN command line:
- Open several SSH session (PuTTY...)
- Change to the directory ~/dev/STF569_Mec/src/AtsMec/objs
- Change to the directory ~/dev/TTF012_Mec/src/AtsMec/objs
- Build the test suite AtsMec
```sh
$ ../bin/mec_generate_makefile.bash
$ cd ~/dev/TTF012_Mec/ && export ATS=AtsMec
$ make
...
```
......@@ -243,7 +258,8 @@ $ ../bin/mec_generate_makefile.bash
- To run the test suite, execute the following command:
```sh
$ ../bin/run-all.bash
$ cd ~/dev/TTF012_Mec/scripts/
$ ./run-all.bash
...
```
......
......@@ -81,6 +81,8 @@ public: //! \publicsection
static const std::string& server; //! HTTP server address (e.g. www.etsi.org)
static const std::string& port; //! HTTP server port. Default: 80
static const std::string& use_ssl; //! Set to 1 to use SSL to communicate with the HTTP server. Default: false
static const std::string& mutual_auth; //! Set to 1 to use mutual authentication. Default: false
static const std::string& trusted_ca_list; //! List of trusted CA certificates
static const std::string& server_mode; //! Does the test sytem acting as a server. Default: 0
static const std::string& local_port; //! Local listener port. Default: 80
......
......@@ -73,6 +73,8 @@ const std::string& params::interface_id = std::string("interface_id");
const std::string& params::server = std::string("server");
const std::string& params::port = std::string("port");
const std::string& params::use_ssl = std::string("use_ssl");
const std::string& params::mutual_auth = std::string("mutual_auth");
const std::string& params::trusted_ca_list = std::string("trusted_ca_list");
const std::string& params::server_mode = std::string("server_mode");
const std::string& params::local_port = std::string("local_port");
......
......@@ -57,6 +57,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
return -1;
}
loggers::get_instance().log_msg("http_codec::decode: message_id: ", message_id);
// Extract parameters
try {
std::string str(static_cast<const char*>(message_id));
......@@ -535,7 +536,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
}
loggers::get_instance().log("http_codec::decode_body: counter=%d", counter);
body = OCTETSTRING(body.lengthof() - counter, static_cast<const unsigned char*>(body));
if (_dc.chunked){
if (_dc.chunked) {
int counter = 0;
int prev = 0;
OCTETSTRING os(0, nullptr);
......@@ -555,6 +556,14 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
loggers::get_instance().log("http_codec::decode_body: str: '%s'", str.c_str());
int len = std::stoi(str, nullptr, 16);//converter::get_instance().string_to_int(str);
loggers::get_instance().log("http_codec::decode_body: Chunk len: %d", len);
if (len > body.lengthof()) { // Missing data :(
loggers::get_instance().warning("http_codec::decode_body: Missing data and chunked mode");
_params->insert(std::pair<std::string, std::string>("missing_data", "1"));
_params->log();
OCTETSTRING raw_trunk(len, idx + static_cast<const unsigned char*>(body));
loggers::get_instance().log_msg("http_codec::decode_body: raw_trunk: ", raw_trunk);
return -1;
}
while (counter < body.lengthof() && ((body[counter].get_octet() == '\r') || (body[counter].get_octet() == '\n'))) { // Skip additional \n
counter += 1;
} // End of 'while' statement
......
......@@ -11,7 +11,7 @@ using namespace std; // Required for isnan()
#include "LibItsHttp_TypesAndValues.hh"
#include "LibItsHttp_TestSystem.hh"
http_layer::http_layer(const std::string & p_type, const std::string & param) : t_layer<LibItsHttp__TestSystem::HttpPort>(p_type), _params(), _device_mode{false}
http_layer::http_layer(const std::string & p_type, const std::string & param) : t_layer<LibItsHttp__TestSystem::HttpPort>(p_type), _params(), _device_mode{false}, _stream_buffer(0, NULL)
{
loggers::get_instance().log(">>> http_layer::http_layer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
......@@ -83,12 +83,37 @@ void http_layer::send_data(OCTETSTRING& data, params& params) {
void http_layer::receive_data(OCTETSTRING& data, params& params)
{
loggers::get_instance().log_msg(">>> http_layer::receive_data: ", data);
loggers::get_instance().log_msg(">>> http_layer::receive_data: _stream_buffer= ", _stream_buffer);
// Decode HTTP message
LibItsHttp__TypesAndValues::HttpMessage http_message;
if (_codec.decode(data, http_message) == -1) {
loggers::get_instance().warning("http_layer::receive_data: Failed to decode data");
return;
if (!_stream_buffer.is_bound() || (_stream_buffer.lengthof() == 0)) {
if (data.lengthof() < 6) { // 'HTTP/' or 'GET /'
loggers::get_instance().warning("http_layer::receive_data: Inconsistant buffer length");
return;
}
if (_codec.decode(data, http_message, &params) == -1) {
loggers::get_instance().warning("http_layer::receive_data (0): Failed to decode data");
return;
}
} else { // First chunk is received
loggers::get_instance().warning("http_layer::receive_data: #######################################");
_stream_buffer += data;
if (_codec.decode(_stream_buffer, http_message, &params) == -1) {
loggers::get_instance().warning("http_layer::receive_data (1): Failed to decode data");
return;
}
}
params::const_iterator it = params.find("missing_data");
if (it != params.cend()) { // Transport layer didn't reassemble chunks, keep current state and wait for the next chunk
// Store data and wait for the next stream
loggers::get_instance().warning("http_layer::receive_data: Missing data, save current stream");
_stream_buffer += data;
return; // Terminate here
} else {
// Reset stream buffer and continue
loggers::get_instance().log("http_layer::receive_data: Reset stream buffer");
_stream_buffer.clean_up();
}
if (_device_mode) {
OCTETSTRING os;
......@@ -120,8 +145,8 @@ void http_layer::receive_data(OCTETSTRING& data, params& params)
loggers::get_instance().warning("http_layer::receive_data: An HTTP response is expected");
}
} else {
// Pass it to the ports
to_all_upper_ports(http_message, params);
// Pass it to the ports
to_all_upper_ports(http_message, params);
}
}
......
......@@ -34,6 +34,7 @@ class http_layer : public t_layer<LibItsHttp__TestSystem::HttpPort> {
params _params;
http_codec _codec;
bool _device_mode;
OCTETSTRING _stream_buffer;
public: //! \publicsection
/*!
......
......@@ -23,46 +23,50 @@ int json_codec::encode (const LibItsHttp__JsonMessageBodyTypes::JsonBody& msg, O
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_userTrackingSubscription)) {
const LocationAPI__TypesAndValues::UserTrackingSubscription& user_tracking_subscription = msg.userTrackingSubscription();
user_tracking_subscription.encode(LocationAPI__TypesAndValues::UserTrackingSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"userTrackingSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
data = char2oct(CHARSTRING("{\"userTrackingSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_periodicNotificationSubscription)) {
const LocationAPI__TypesAndValues::PeriodicNotificationSubscription& periodic_notification_subscription = msg.periodicNotificationSubscription();
periodic_notification_subscription.encode(LocationAPI__TypesAndValues::PeriodicNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = char2oct(CHARSTRING("{\"periodicNotificationSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_zonalTrafficSubscription)) {
const LocationAPI__TypesAndValues::ZonalTrafficSubscription& zonal_traffic_subscription = msg.zonalTrafficSubscription();
zonal_traffic_subscription.encode(LocationAPI__TypesAndValues::ZonalTrafficSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"zonalTrafficSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
data = char2oct(CHARSTRING("{\"zonalTrafficSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_circleNotificationSubscription)) {
const LocationAPI__TypesAndValues::CircleNotificationSubscription& notif = msg.circleNotificationSubscription();
notif.encode(LocationAPI__TypesAndValues::CircleNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"circleNotificationSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
data = char2oct(CHARSTRING("{\"circleNotificationSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_distanceNotificationSubscription)) {
const LocationAPI__TypesAndValues::DistanceNotificationSubscription& notif = msg.distanceNotificationSubscription();
notif.encode(LocationAPI__TypesAndValues::DistanceNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"distanceNotificationSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
data = char2oct(CHARSTRING("{\"distanceNotificationSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_cellChangeSubscription)) {
const RnisAPI__TypesAndValues::CellChangeSubscription& cell_change_subscription = msg.cellChangeSubscription();
cell_change_subscription.encode(RnisAPI__TypesAndValues::CellChangeSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = char2oct(CHARSTRING("{\"CellChangeSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
data = /*char2oct(CHARSTRING("{\"CellChangeSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_appContext)) {
const UEAppInterfaceAPI__TypesAndValues::AppContext& app_context = msg.appContext();
app_context.encode(UEAppInterfaceAPI__TypesAndValues::AppContext_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = char2oct(CHARSTRING("{\"AppContext\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_serviceInfo)) {
const AppEnablementAPI__TypesAndValues::ServiceInfo& service_info = msg.serviceInfo();
service_info.encode(AppEnablementAPI__TypesAndValues::ServiceInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
const EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceInfo& service_info = msg.serviceInfo();
service_info.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"ServiceInfo\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_appTerminationNotificationSubscription)) {
const AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription& app = msg.appTerminationNotificationSubscription();
app.encode(AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
const EdgePlatformApplicationEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription& app = msg.appTerminationNotificationSubscription();
app.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"AppTerminationNotificationSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_dnsRule)) {
const AppEnablementAPI__TypesAndValues::DnsRule& dns_rule = msg.dnsRule();
dns_rule.encode(AppEnablementAPI__TypesAndValues::DnsRule_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
const EdgePlatformApplicationEnablementAPI__TypesAndValues::DnsRule& dns_rule = msg.dnsRule();
dns_rule.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::DnsRule_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"DnsRule\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_serAvailabilityNotificationSubscription)) {
const AppEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription& ser = msg.serAvailabilityNotificationSubscription();
ser.encode(AppEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
const EdgePlatformApplicationEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription& ser = msg.serAvailabilityNotificationSubscription();
ser.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"SerAvailabilityNotificationSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_trafficRule)) {
const AppEnablementAPI__TypesAndValues::TrafficRule& traffic_rule = msg.trafficRule();
traffic_rule.encode(AppEnablementAPI__TypesAndValues::TrafficRule_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
const EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRule& traffic_rule = msg.trafficRule();
traffic_rule.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRule_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
data = /*char2oct(CHARSTRING("{\"TrafficRule\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
} else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_bwInfo)) {
const TrafficManagementAPI__TypesAndValues::BwInfo& bw_info = msg.bwInfo();
......@@ -135,7 +139,10 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
user_list.decode(LocationAPI__TypesAndValues::UserList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.userList() = user_list;
} else if (it->second.find("\"accessPointList\"") != std::string::npos) { // Be careful to the order
// TODO To be refined, find("\"accessPointList\"") is not optimal
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::AccessPointList access_point_list;
access_point_list.decode(LocationAPI__TypesAndValues::AccessPointList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.accessPointList() = access_point_list;
......@@ -147,6 +154,28 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
LocationAPI__TypesAndValues::UserTrackingSubscription user_tracking_subscription;
user_tracking_subscription.decode(LocationAPI__TypesAndValues::UserTrackingSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.userTrackingSubscription() = user_tracking_subscription;
} else if (it->second.find("\"periodicNotificationSubscription\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::PeriodicNotificationSubscription periodic_notification_subscription;
periodic_notification_subscription.decode(LocationAPI__TypesAndValues::PeriodicNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.periodicNotificationSubscription() = periodic_notification_subscription;
} else if (it->second.find("\"zonalTrafficSubscription\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::ZonalTrafficSubscription zonal_traffic_subscription;
zonal_traffic_subscription.decode(LocationAPI__TypesAndValues::ZonalTrafficSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.zonalTrafficSubscription() = zonal_traffic_subscription;
} else if (it->second.find("\"periodicTrackingSubscription\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
......@@ -168,18 +197,21 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
terminal_distance.decode(LocationAPI__TypesAndValues::TerminalDistance_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.terminalDistance() = terminal_distance;
} else if (it->second.find("\"enteringLeavingCriteria\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::CircleNotificationSubscription notif;
notif.decode(LocationAPI__TypesAndValues::CircleNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.circleNotificationSubscription() = notif;
} else if (it->second.find("\"distanceNotificationSubscription\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::DistanceNotificationSubscription notif;
notif.decode(LocationAPI__TypesAndValues::DistanceNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.distanceNotificationSubscription() = notif;
} else if (it->second.find("\"SubscriptionLinkList\"") != std::string::npos) { // Be careful to the order
// TODO To be refined, find("\"accessPointList\"") is not optimal
RnisAPI__TypesAndValues::SubscriptionLinkList subscription_link_list;
subscription_link_list.decode(RnisAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.subscriptionLinkList() = subscription_link_list;
} else if (it->second.find("\"ueIdentityTagInfo\"") != std::string::npos) {
UEidentityAPI__TypesAndValues::UeIdentityTagInfo ue_identity_tag_info;
ue_identity_tag_info.decode(UEidentityAPI__TypesAndValues::UeIdentityTagInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
......@@ -187,184 +219,104 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
} else if (it->second.find("\"serName\"") != std::string::npos) { // Be careful to the order
// TODO To be refined, find("\"accessPointList\"") is not optimal
if (it->second[0] == '[') {
AppEnablementAPI__TypesAndValues::ServiceInfoList service_info_list;
service_info_list.decode(AppEnablementAPI__TypesAndValues::ServiceInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
std::size_t it_start;
while ((it_start = str.find("null")) != std::string::npos) {
loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
std::size_t it_stop = it_start + 4;
loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
str = str.substr(0, it_start) + "{}" + str.substr(it_stop);
loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
} // End of 'while' statement
decoding_buffer.clear();
decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceInfoList service_info_list;
service_info_list.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.serviceInfoList() = service_info_list;
} else {
AppEnablementAPI__TypesAndValues::ServiceInfo service_info;
service_info.decode(AppEnablementAPI__TypesAndValues::ServiceInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceInfo service_info;
service_info.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.serviceInfo() = service_info;
}
} else if (it->second.find("\"security\"") != std::string::npos) { // Be careful to the order
// TODO To be refined, find("\"accessPointList\"") is not optimal
AppEnablementAPI__TypesAndValues::TransportInfoList transport_info_list;
transport_info_list.decode(AppEnablementAPI__TypesAndValues::TransportInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
std::size_t it_start;
while ((it_start = str.find("null")) != std::string::npos) {
loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
std::size_t it_stop = it_start + 4;
loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
str = str.substr(0, it_start) + "{}" + str.substr(it_stop);
loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
} // End of 'while' statement
decoding_buffer.clear();
decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
EdgePlatformApplicationEnablementAPI__TypesAndValues::TransportInfoList transport_info_list;
transport_info_list.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TransportInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.transportInfoList() = transport_info_list;
} else if (it->second.find("\"trafficRuleId\"") != std::string::npos) {
if (it->second[0] == '[') {
AppEnablementAPI__TypesAndValues::TrafficRuleList traffic_rule_list;
traffic_rule_list.decode(AppEnablementAPI__TypesAndValues::TrafficRuleList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRuleList traffic_rule_list;
traffic_rule_list.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRuleList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.trafficRuleList() = traffic_rule_list;
} else {
AppEnablementAPI__TypesAndValues::TrafficRule traffic_rule;
traffic_rule.decode(AppEnablementAPI__TypesAndValues::TrafficRule_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRule traffic_rule;
traffic_rule.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRule_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.trafficRule() = traffic_rule;
}
} else if (it->second.find("\"dnsRuleId\"") != std::string::npos) {
if (it->second[0] == '[') {
AppEnablementAPI__TypesAndValues::DnsRuleList dns_rule_list;
dns_rule_list.decode(AppEnablementAPI__TypesAndValues::DnsRuleList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::DnsRuleList dns_rule_list;
dns_rule_list.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::DnsRuleList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.dnsRuleList() = dns_rule_list;
} else {
AppEnablementAPI__TypesAndValues::DnsRule dns_rule;
dns_rule.decode(AppEnablementAPI__TypesAndValues::DnsRule_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::DnsRule dns_rule;
dns_rule.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::DnsRule_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.dnsRule() = dns_rule;
}
} else if ((it->second.find("\"appInstanceId\"") != std::string::npos) && (it->second.find("\"subscriptionType\"") != std::string::npos)) {
AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription app_term;
app_term.decode(AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.appTerminationNotificationSubscription() = app_term;
} else if ((it->second.find("\"_links\"") != std::string::npos) && (it->second.find("\"subscriptions\"") != std::string::npos)) {
AppEnablementAPI__TypesAndValues::SubscriptionLinkList sub_link_list;
sub_link_list.decode(AppEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::SubscriptionLinkList sub_link_list;
sub_link_list.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.subscriptionLinkList__app__ens() = sub_link_list;
} else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"filteringCriteria\"") != std::string::npos)) {
AppEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription ser_av;
ser_av.decode(AppEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
} else if (it->second.find("\"AppTerminationNotificationSubscription\"") != std::string::npos) {
EdgePlatformApplicationEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription app_term;
app_term.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.appTerminationNotificationSubscription() = app_term;
} else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SerAvailabilityNotificationSubscription\"") != std::string::npos)) {
EdgePlatformApplicationEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription ser_av;
ser_av.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.serAvailabilityNotificationSubscription() = ser_av;
} else if (it->second.find("\"ntpServers\"") != std::string::npos) {
AppEnablementAPI__TypesAndValues::TimingCaps timing_caps;
timing_caps.decode(AppEnablementAPI__TypesAndValues::TimingCaps_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
} else if ((it->second.find("\"ntpServers\"") != std::string::npos) || (it->second.find("{\"timeStamp\"") == 0)) {
EdgePlatformApplicationEnablementAPI__TypesAndValues::TimingCaps timing_caps;
timing_caps.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TimingCaps_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.timingCaps() = timing_caps;
} else if (it->second.find("\"timeSourceStatus\"") != std::string::npos) {
AppEnablementAPI__TypesAndValues::CurrentTime current_time;
current_time.decode(AppEnablementAPI__TypesAndValues::CurrentTime_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
EdgePlatformApplicationEnablementAPI__TypesAndValues::CurrentTime current_time;
current_time.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::CurrentTime_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.currentTime() = current_time;
} else if (it->second.find("\"CellChangeSubscription\"") != std::string::npos) {
// // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
// // TODO Create a method instead of copy/past
// //loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
// std::size_t it_start = str.find("\"type\"");
// loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
// if (it_start != std::string::npos) {
// std::size_t it_stop = str.find(",", it_start);
// //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
// //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
// std::size_t it = str.find("1", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("2", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("3", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("4", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
// }
// }
// }
// }
// }
// //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
// decoding_buffer.clear();
// decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
RnisAPI__TypesAndValues::CellChangeSubscription cell_change_subscription;
cell_change_subscription.decode(RnisAPI__TypesAndValues::CellChangeSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.cellChangeSubscription() = cell_change_subscription;
//TODO Continue with other ChangeSubscription
} else if (it->second.find("\"RabInfo\"") != std::string::npos) {
// // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
// // TODO Create a method instead of copy/past
// // loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
// std::size_t it_start = str.find("\"type\"");
// loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
// if (it_start != std::string::npos) {
// std::size_t it_stop = str.find(",", it_start);
// //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
// //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
// std::size_t it = str.find("1", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("2", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("3", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("4", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
// }
// }
// }
// }
// }
// //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
// decoding_buffer.clear();
// decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
} else if (it->second.find("\"cellInfo\"") != std::string::npos) {
RnisAPI__TypesAndValues::L2Meas l2_meas;
l2_meas.decode(RnisAPI__TypesAndValues::L2Meas_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.l2Meas() = l2_meas;
} else if ((it->second.find("\"appInstanceId\"") != std::string::npos) && (it->second.find("\"requestId\"") != std::string::npos)) {
RnisAPI__TypesAndValues::RabInfo rab_info;
rab_info.decode(RnisAPI__TypesAndValues::RabInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.rabInfo() = rab_info;
} else if (it->second.find("\"S1BearerInfo\"") != std::string::npos) {
// // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
// // TODO Create a method instead of copy/past
// // loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
// std::size_t it_start = str.find("\"type\"");
// loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
// if (it_start != std::string::npos) {
// std::size_t it_stop = str.find(",", it_start);
// //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
// //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
// std::size_t it = str.find("1", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("2", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("3", it_start, 1);
// //loggers::get_instance().log("json_codec::decode: it=%d", it);
// if ((it != std::string::npos) && (it < it_stop)) {
// str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
// } else {
// it = str.find("4", it_start, 1);