Newer
Older
IVIMLayer::IVIMLayer(const std::string & p_type, const std::string & param) : t_layer<LibItsIvim__TestSystem::IvimPort>(p_type), _params(), _codec() {
loggers::get_instance().log(">>> IVIMLayer::IVIMLayer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
}
void IVIMLayer::sendMsg(const LibItsIvim__TestSystem::IvimReq& p, Params& params){
loggers::get_instance().log_msg(">>> IVIMLayer::sendMsg: ", p);
// Encode IVIM PDU
OCTETSTRING data;
if (_codec.encode(p.msgOut(), data) == -1) {
loggers::get_instance().warning("IVIMLayer::sendMsg: Encodeing failure");
return;
}
void IVIMLayer::send_data(OCTETSTRING& data, Params& params) {
loggers::get_instance().log_msg(">>> IVIMLayer::send_data: ", data);
void IVIMLayer::receive_data(OCTETSTRING& data, Params& params)
loggers::get_instance().log_msg(">>> IVIMLayer::receive_data: ", data);
// Sanity check
if (*(static_cast<const unsigned char*>(data)+ 1) != 0x06) { // Check that received packet has IVI message id - See ETSI TS 102 894
// Not a IVIM message, discard it
loggers::get_instance().warning("IVIMLayer::receive_data: Wrong message id: 0x%02x", *(static_cast<const unsigned char*>(data)+ 1));
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
return;
}
// Decode the payload
LibItsIvim__TestSystem::IvimInd p;
_codec.decode(data, p.msgIn());
if (!p.msgIn().is_bound()) {
// Discard it
return;
} // else, continue
// Process lower layer data
// gnNextHeader
Params::const_iterator it = params.find(Params::gn_next_header);
if (it != params.cend()) {
p.gnNextHeader() = std::stoi(it->second);
} else {
p.gnNextHeader().set_to_omit();
}
// gnHeaderType
it = params.find(Params::gn_header_type);
if (it != params.cend()) {
p.gnHeaderType() = std::stoi(it->second);
} else {
p.gnHeaderType().set_to_omit();
}
// gnHeaderSubtype
it = params.find(Params::gn_header_sub_type);
if (it != params.cend()) {
p.gnHeaderSubtype() = std::stoi(it->second);
} else {
p.gnHeaderSubtype().set_to_omit();
}
// gnLifetime
it = params.find(Params::gn_lifetime);
if (it != params.cend()) {
p.gnLifetime() = std::stoi(it->second);
} else {
p.gnLifetime().set_to_omit();
}
// gnTrafficClass
it = params.find(Params::gn_traffic_class);
if (it != params.cend()) {
p.gnTrafficClass() = std::stoi(it->second);
} else {
p.gnTrafficClass().set_to_omit();
}
// btpDestinationPort
it = params.find(Params::btp_destination_port);
if (it != params.cend()) {
p.btpDestinationPort() = std::stoi(it->second);
} else {
p.btpDestinationPort().set_to_omit();
}
// btpInfo
it = params.find(Params::btp_info);
if (it != params.cend()) {
p.btpInfo() = std::stoi(it->second);
} else {
p.btpInfo().set_to_omit();
}
// ssp
it = params.find(Params::ssp);
if (it != params.cend()) {
OCTETSTRING os(it->second.length(), (const unsigned char *)(it->second.c_str()));
p.ssp() = oct2bit(os);
} else {
p.ssp().set_to_omit();
}
// its_aid
it = params.find(Params::its_aid);
if (it != params.cend()) {
p.its__aid() = std::stoi(it->second);
} else {
p.its__aid().set_to_omit();
}
// Pass it to the ports if amy
}
IVIMLayerFactory IVIMLayerFactory::_f;