Commit 493000b8 authored by vagrant's avatar vagrant
Browse files

Add PKI support to RSU simumlator

parent 6a8275a7
......@@ -103,7 +103,7 @@ void ConfigRsuSimulatorLayer::sendMsg(const LibItsPki__TypesAndValues::UtPkiResu
encoding_buffer.put_c(0x01/*static_cast<const unsigned char>(uppertester_pki_codec::c_utPkiInitializeResult)*/);
encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utPkiInitializeResult()));
} else if (send_par.ischosen(LibItsPki__TypesAndValues::UtPkiResults::ALT_utPkiTriggerResult)) {
encoding_buffer.put_c(0x11/*static_cast<const unsigned char>(uppertester_pki_codec::c_utPkiTriggerResult)*/);
encoding_buffer.put_c(0xBC/*static_cast<const unsigned char>(uppertester_pki_codec::c_utPkiTriggerResult)*/);
encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utPkiTriggerResult()));
} else {
loggers::get_instance().warning("ConfigRsuSimulatorLayer::sendMsg: Unsupported UtPkiResults variant");
......@@ -135,6 +135,8 @@ void ConfigRsuSimulatorLayer::receive_data(OCTETSTRING& data, params& params)
process_ut_cam_changeheading_data(data, params);
} else if ((id >= 0x50) && (id <= 0x54)) { // Receive an UtGnTrigger
process_ut_geonetworking_trigger(data, params);
} else if ((id >= 0xBB) && (id <= 0xBF)) { // Receive an UtPkiTrigger
process_ut_pki_trigger(data, params);
} else {
loggers::get_instance().warning("ConfigRsuSimulatorLayer::receive_data: Unsupported tag %02x", id);
}
......@@ -165,6 +167,11 @@ int ConfigRsuSimulatorLayer::process_utinitialize_data(const OCTETSTRING& data,
LibItsDenm__TypesAndValues::UtDenmInitialize p(hashedId);
// Pass it to the ports if any
to_all_upper_ports(p, params);
} else if (_params[std::string("ut")].compare("pki") == 0) {
OCTETSTRING hashedId(data.lengthof() - 1, 1 + static_cast<const unsigned char*>(data));
LibItsPki__TypesAndValues::UtPkiInitialize p(hashedId);
// Pass it to the ports if any
to_all_upper_ports(p, params);
} else {
loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_utinitialize_data: Unsupported protocol");
return -1;
......@@ -281,4 +288,29 @@ int ConfigRsuSimulatorLayer::process_ut_geonetworking_trigger(const OCTETSTRING&
return 0;
}
int ConfigRsuSimulatorLayer::process_ut_pki_trigger(const OCTETSTRING& data, params& params) {
loggers::get_instance().log(">>> ConfigRsuSimulatorLayer::process_ut_pki_trigger");
params::const_iterator it = _params.find("ut");
if (it == _params.cend()) {
loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_ut_pki_trigger: CF layer's ut parameter is missing");
return -1;
}
if (_params[std::string("ut")].compare("pki") == 0) {
LibItsPki__TypesAndValues::UtPkiTrigger p;
p.triggerEnrolmentRequest().cannonicalId() = OCTETSTRING(0, nullptr); // No parameter used
p.triggerEnrolmentRequest().encAlgorithm() = OCTETSTRING(0, nullptr); // No parameter used
p.triggerEnrolmentRequest().privateKey() = OCTETSTRING(0, nullptr); // No parameter used
p.triggerEnrolmentRequest().compressedPublickey() = OCTETSTRING(0, nullptr); // No parameter used
// Pass it to the ports if any
to_all_upper_ports(p, params);
} else {
loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_ut_pki_trigger: Unsupported protocol");
return -1;
}
return 0;
}
ConfigRsuSimulatorLayerFactory ConfigRsuSimulatorLayerFactory::_f;
......@@ -48,5 +48,6 @@ private:
int process_ut_cam_changecurvature_data(const OCTETSTRING& data, params& params);
int process_ut_cam_changeheading_data(const OCTETSTRING& data, params& params);
int process_ut_geonetworking_trigger(const OCTETSTRING& data, params& params);
int process_ut_pki_trigger(const OCTETSTRING& data, params& params);
}; // End of class ConfigRsuSimulatorLayer
......@@ -211,6 +211,16 @@ namespace ItsRSUsSimulator__TestSystem {
incoming_message(p_ind);
}
void ConfigRsuSimulatorPort::receiveMsg (const LibItsPki__TypesAndValues::UtPkiInitialize& p_ind, const params& p_params) {
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
// Sanity check
if (!p_ind.is_bound()) {
return;
}
incoming_message(p_ind);
}
void ConfigRsuSimulatorPort::receiveMsg (const LibItsPki__TypesAndValues::UtPkiTrigger& p_ind, const params& p_params) {
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
// Sanity check
......
......@@ -21,6 +21,11 @@ tcp_layer::tcp_layer(const std::string & p_type, const std::string & param) : la
} else if (it->second.compare("1") == 0) {
set_socket_debugging(true);
}
bool server_mode = false;
it = _params.find(params::server_mode);
if (it != _params.cend()) {
server_mode = (1 == std::stoi(it->second));
}
it = _params.find(params::server);
if (it == _params.cend()) {
_params.insert(std::pair<std::string, std::string>(std::string("server"), "127.0.0.1"));
......@@ -46,10 +51,25 @@ tcp_layer::tcp_layer(const std::string & p_type, const std::string & param) : la
if (!parameter_set(params::port.c_str(), _params[params::port].c_str())) {
loggers::get_instance().warning("tcp_layer::set_parameter: Unprocessed parameter: %s", params::server.c_str());
}
it = _params.find(params::local_port);
if (it == _params.cend()) {
if (_params[params::use_ssl].compare("0") == 0) { // Use standard HTTP local_port
_params.insert(std::pair<std::string, std::string>(std::string("local_port"), "80"));
} else { // Use standard HTTPS local_port
_params.insert(std::pair<std::string, std::string>(std::string("local_port"), "443"));
}
}
if (!parameter_set(params::local_port.c_str(), _params[params::local_port].c_str())) {
loggers::get_instance().warning("tcp_layer::set_parameter: Unprocessed parameter: %s", params::local_port.c_str());
}
parameter_set(use_connection_ASPs_name(), "yes");
parameter_set(use_connection_ASPs_name(), (!server_mode) ? "yes" : "no");
parameter_set(server_backlog_name(), "1024");
set_server_mode(false);
loggers::get_instance().log("tcp_layer::tcp_layer: server_mode=%x", server_mode);
set_server_mode(server_mode);
if (server_mode) {
parameter_set("serverPort", _params[params::local_port].c_str());
}
set_ttcn_buffer_usercontrol(false);
set_handle_half_close(true);
......
......@@ -32,7 +32,8 @@ udp_layer::udp_layer(const std::string & p_type, const std::string & param) : la
// Initialize the socket
_saddr.sin_family = AF_INET;
_saddr.sin_addr.s_addr = INADDR_ANY;
_saddr.sin_addr.s_addr = htonl(INADDR_ANY);
loggers::get_instance().log("udp_layer::udp_layer: Port tolisten=%d", std::atoi(_params["src_port"].c_str()));
_saddr.sin_port = htons(std::atoi(_params["src_port"].c_str()));
// Create socket
_fd = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
......
......@@ -27,20 +27,26 @@ ItsRSUsSimulator_Pixits.PX_ETSI_USE_CASE_ID := 6
# Indicate which zone to simulate
ItsRSUsSimulator_Pixits.PX_ETSI_ZONE_ID := 1
ItsRSUsSimulator_Pics.PICS_GENERATE_BEACON := false
ItsRSUsSimulator_Pics.PICS_GENERATE_CAM := true
ItsRSUsSimulator_Pics.PICS_GENERATE_DENM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_BEACON := false # Change also its_aid in geoNetworking port setting
ItsRSUsSimulator_Pics.PICS_GENERATE_CAM := true # Change also its_aid in geoNetworking port setting
ItsRSUsSimulator_Pics.PICS_GENERATE_DENM := false # Change also its_aid in geoNetworking port setting
ItsRSUsSimulator_Pics.PICS_GENERATE_IVIM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_MAPEM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_SPATEM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_SSEM := false
ItsRSUsSimulator_Pics.PICS_PKI_SUPPORT := true
ItsRSUsSimulator_Pics.PICS_BEACON_FREQUENCY := 1.0
ItsRSUsSimulator_Pics.PICS_CAM_FREQUENCY := 0.75
ItsRSUsSimulator_Pics.PICS_DENM_FREQUENCY := 0.25
ItsRSUsSimulator_Pics.PICS_DENM_FREQUENCY := 0.75
ItsRSUsSimulator_Pics.PICS_SEND_CAM_INDICATION := false
LibItsHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/x-its-request"
[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).
......@@ -125,10 +131,12 @@ LogEventTypes:= Yes
# Single GeoNetworking component port
# its_aid=36: CAM
# its_aid=37: DENM
system.geoNetworkingPort.params := "GN(ll_address=4C5E0C14D2EB,latitude=43551050,longitude=10298730,its_aid=37,secured_mode=1,encrypted_mode=0,certificate=CERT_IUT_A_AT,peer_certificate=CERT_TS_A_AT,sec_db_path=/home/vagrant/tmp/asn1c_cert)/ETH(mac_src=080027500f9b)/PCAP(mac_src=080027500f9b,nic=eth1,filter=and ether proto 0x8947)"
system.geoNetworkingPort.params := "GN(ll_address=4C5E0C14D2EB,latitude=43551050,longitude=10298730,its_aid=36,secured_mode=1,encrypted_mode=0,certificate=CERT_IUT_A_AT,peer_certificate=CERT_TS_A_AT,sec_db_path=/home/vagrant/tmp/asn1c_cert)/ETH(mac_src=080027500f9b)/PCAP(mac_src=080027500f9b,nic=eth1,filter=and ether proto 0x8947)"
system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(debug=1,server_mode=1,server=192.168.0.250,port=80,use_ssl=0)"
# Config port based on UDP
system.cfPort.params := "CF(ut=pki)/UDP(dst_ip=192.168.0.4)"
system.cfPort.params := "CF(ut=pki)/UDP(dst_ip=192.168.0.252,src_port=12345)"
[EXECUTE]
ItsRSUsSimulator_TestCases.TC_RSUSIMU_BV_01
......
......@@ -106,7 +106,7 @@ module ItsRSUsSimulator_TestSystem {
var boolean vc_ivim := PICS_GENERATE_IVIM;
var boolean vc_mapem := PICS_GENERATE_MAPEM;
var boolean vc_spatem := PICS_GENERATE_SPATEM;
var boolean vc_pki := PICS_PKI_SUPPORT;
var boolean vc_pki := PICS_PKI_SUPPORT;
//var boolean vc_evcsn := PICS_GENERATE_EVCSN;
var float vc_cam_timer_value := PICS_CAM_FREQUENCY;
timer tc_beacon := PICS_BEACON_FREQUENCY;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment