mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Add work on OSNMA receiver
This commit is contained in:
parent
c6c0fc651a
commit
cc8fa9a4d2
@ -111,6 +111,7 @@ void osnma_msg_receiver::process_osnma_message(const std::shared_ptr<OSNMA_msg>&
|
||||
read_nma_header(osnma_msg->hkroot[0]);
|
||||
read_dsm_header(osnma_msg->hkroot[1]);
|
||||
read_dsm_block(osnma_msg);
|
||||
read_mack_block(osnma_msg);
|
||||
}
|
||||
|
||||
|
||||
@ -247,16 +248,34 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
|
||||
{
|
||||
d_osnma_data.d_dsm_kroot_message.kroot[k] = dsm_msg[13 + k];
|
||||
}
|
||||
uint16_t l_ds_bits;
|
||||
const auto it3 = OSNMA_TABLE_15.find("");
|
||||
if (it3 != OSNMA_TABLE_15.cend())
|
||||
|
||||
std::string hash_function;
|
||||
const auto it3 = OSNMA_TABLE_8.find(d_osnma_data.d_dsm_kroot_message.hf);
|
||||
if (it3 != OSNMA_TABLE_8.cend())
|
||||
{
|
||||
l_ds_bits = it3->second;
|
||||
hash_function = it3->second;
|
||||
}
|
||||
// uint32_t l_ld = 0;
|
||||
// const auto it2 = OSNMA_TABLE_5.find()
|
||||
// d_osnma_data.d_dsm_kroot_message.ds = "0";
|
||||
// d_osnma_data.d_dsm_kroot_message.p_dk;
|
||||
|
||||
uint16_t l_ds_bits = 0;
|
||||
const auto it4 = OSNMA_TABLE_15.find(hash_function);
|
||||
if (it4 != OSNMA_TABLE_15.cend())
|
||||
{
|
||||
l_ds_bits = it4->second;
|
||||
}
|
||||
uint16_t l_ds_bytes = l_ds_bits / 8;
|
||||
d_osnma_data.d_dsm_kroot_message.ds = std::vector<uint8_t>(l_ds_bytes, 0);
|
||||
for (uint32_t k = 0; k < l_ds_bytes; k++)
|
||||
{
|
||||
d_osnma_data.d_dsm_kroot_message.ds[k] = dsm_msg[13 + bytes_lk + k];
|
||||
}
|
||||
uint16_t l_pdk_bytes = (l_dk_bits - 104 - lk_bits - l_ds_bits) / 8;
|
||||
|
||||
d_osnma_data.d_dsm_kroot_message.p_dk = std::vector<uint8_t>(l_pdk_bytes, 0);
|
||||
for (uint32_t k = 0; k < l_ds_bytes; k++)
|
||||
{
|
||||
d_osnma_data.d_dsm_kroot_message.ds[k] = dsm_msg[13 + bytes_lk + l_ds_bytes + k];
|
||||
}
|
||||
// validation?
|
||||
}
|
||||
else if (d_osnma_data.d_dsm_header.dsm_id >= 12 && d_osnma_data.d_dsm_header.dsm_id < 16)
|
||||
{
|
||||
@ -308,4 +327,41 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
|
||||
// Reserved message?
|
||||
d_osnma_data = OSNMA_data();
|
||||
}
|
||||
d_number_of_blocks[d_osnma_data.d_dsm_header.dsm_id] = 0;
|
||||
}
|
||||
|
||||
|
||||
void osnma_msg_receiver::read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma_msg)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
for (size_t i = 0; i < osnma_msg->mack.size(); i++)
|
||||
{
|
||||
uint32_t value = osnma_msg->mack[i];
|
||||
d_mack_message[index] = static_cast<uint8_t>((value & 0xFF000000) >> 6);
|
||||
d_mack_message[index + 1] = static_cast<uint8_t>((value & 0x00FF0000) >> 4);
|
||||
d_mack_message[index + 2] = static_cast<uint8_t>((value & 0x0000FF00) >> 2);
|
||||
d_mack_message[index + 3] = static_cast<uint8_t>(value & 0x000000FF);
|
||||
index = index + 4;
|
||||
}
|
||||
read_mack_header(osnma_msg);
|
||||
read_mack_info_and_tags(osnma_msg);
|
||||
read_mack_key(osnma_msg);
|
||||
read_mack_padding(osnma_msg);
|
||||
}
|
||||
|
||||
void osnma_msg_receiver::read_mack_header(const std::shared_ptr<OSNMA_msg>& osnma_msg)
|
||||
{
|
||||
}
|
||||
|
||||
void osnma_msg_receiver::read_mack_info_and_tags(const std::shared_ptr<OSNMA_msg>& osnma_msg)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void osnma_msg_receiver::read_mack_key(const std::shared_ptr<OSNMA_msg>& osnma_msg)
|
||||
{
|
||||
}
|
||||
|
||||
void osnma_msg_receiver::read_mack_padding(const std::shared_ptr<OSNMA_msg>& osnma_msg)
|
||||
{
|
||||
}
|
@ -59,11 +59,19 @@ private:
|
||||
void read_nma_header(uint8_t nma_header);
|
||||
void read_dsm_header(uint8_t dsm_header);
|
||||
void read_dsm_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||
void read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||
void process_dsm_message(const std::vector<uint8_t>& dsm_msg);
|
||||
|
||||
void read_mack_header(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||
void read_mack_info_and_tags(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||
void read_mack_key(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||
void read_mack_padding(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||
|
||||
std::array<std::array<uint8_t, 256>, 16> d_dsm_message{};
|
||||
std::array<std::array<uint8_t, 16>, 16> d_dsm_id_received{};
|
||||
std::array<uint16_t, 16> d_number_of_blocks{};
|
||||
std::array<uint8_t, 60> d_mack_message{};
|
||||
|
||||
OSNMA_data d_osnma_data{};
|
||||
bool d_new_data{false};
|
||||
};
|
||||
|
@ -124,8 +124,10 @@ const std::unordered_map<uint8_t, uint16_t> OSNMA_TABLE_10 = {
|
||||
{15, 0}}; // key: ks, value: lk_bits
|
||||
|
||||
const std::unordered_map<std::string, uint16_t> OSNMA_TABLE_15 = {
|
||||
{std::string("ECDSA P-256"), {512}},
|
||||
{std::string("ECDSA P-521"), {1056}}}; // key: ECDSA Curve and hash function, value: {l_ds_bits}
|
||||
{std::string("ECDSA P-256"), 512},
|
||||
{std::string("ECDSA P-521"), 1056},
|
||||
{std::string("SHA-256"), 512},
|
||||
{std::string("SHA-512"), 1056}}; // key: ECDSA Curve and hash function, value: {l_ds_bits}
|
||||
|
||||
#if __cplusplus == 201103L
|
||||
constexpr std::uint8_t mask_nmas{0xC0};
|
||||
|
@ -42,6 +42,24 @@ struct dsm_header
|
||||
uint8_t dsm_block_id;
|
||||
};
|
||||
|
||||
struct mack_header
|
||||
{
|
||||
std::vector<uint8_t> tag0;
|
||||
uint16_t macsec;
|
||||
uint8_t cop;
|
||||
};
|
||||
|
||||
struct tag
|
||||
{
|
||||
std::vector<uint8_t> tag;
|
||||
uint16_t tag_info;
|
||||
};
|
||||
|
||||
struct tag_and_info
|
||||
{
|
||||
std::vector<tag> tags;
|
||||
};
|
||||
|
||||
struct DSM_PKR_message
|
||||
{
|
||||
uint8_t nb_dp;
|
||||
@ -73,6 +91,14 @@ struct DSM_KROOT_message
|
||||
std::vector<uint8_t> p_dk;
|
||||
};
|
||||
|
||||
struct MACK_message
|
||||
{
|
||||
mack_header header;
|
||||
tag_and_info tag_info;
|
||||
std::vector<uint8_t> key;
|
||||
std::vector<uint8_t> padding;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief This class handles ONSMA data
|
||||
* See https://www.gsc-europa.eu/sites/default/files/sites/all/files/Galileo_OSNMA_User_ICD_for_Test_Phase_v1.0.pdf
|
||||
|
Loading…
Reference in New Issue
Block a user