TPM print neighbour security ID info

This commit is contained in:
emanuel 2022-01-10 11:43:32 +00:00
parent 76d655c16a
commit 63567a5f74
1 changed files with 18 additions and 5 deletions

View File

@ -144,9 +144,15 @@ cleanup:
return rv;
}
static void rsu_handle_recv(facilities_t* facilities, TollRequest_t* req) {
static void rsu_handle_recv(facilities_t* facilities, TollRequest_t* req, uint8_t* neighbour) {
syslog_info("[facilities] [tolling] received toll payment > client: %ld | nonce: %ld", req->clientId, req->transactionNonce);
syslog_info("[facilities] [tolling] received toll payment > client: %ld (certificate id: %02x%02x%02x) | nonce: %ld",
req->clientId,
neighbour ? neighbour[5] : 0,
neighbour ? neighbour[6] : 0,
neighbour ? neighbour[7] : 0,
req->transactionNonce
);
const size_t buf_len = 2048;
uint8_t buf[buf_len];
@ -217,6 +223,13 @@ static void rsu_handle_recv(facilities_t* facilities, TollRequest_t* req) {
bpr->gn.trafficClass = 2;
bpr->gn.packetTransportType = PacketTransportType_shb;
if (neighbour) { /* neighbour ID for [security] encryption */
bpr->gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t));
bpr->gn.securityNeighbour->size = 8;
bpr->gn.securityNeighbour->buf = malloc(8);
memcpy(bpr->gn.securityNeighbour->buf, neighbour, 8);
}
// encode TR
buf[0] = 4;
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
@ -232,7 +245,7 @@ cleanup:
ASN_STRUCT_FREE(asn_DEF_TransportRequest, tr);
}
static void veh_handle_recv(tolling_s* tolling, TollReply_t* rep) {
static void veh_handle_recv(tolling_s* tolling, TollReply_t* rep, uint8_t* neighbour) {
if (rep->clientId != tolling->client_id) {
syslog_debug("[facilities] [tolling]<- received TPM.reply clientId different from ego");
@ -266,7 +279,7 @@ int tpm_recv(void* fc, TPM_t* tpm_rx, uint8_t* neighbour) {
syslog_debug("[facilities] [tolling] received TPM.request, ignoring");
goto cleanup;
}
rsu_handle_recv(facilities, &tpm_rx->tpm.tollingFlow.choice.request);
rsu_handle_recv(facilities, &tpm_rx->tpm.tollingFlow.choice.request, neighbour);
break;
case TollingFlow_PR_reply:
@ -275,7 +288,7 @@ int tpm_recv(void* fc, TPM_t* tpm_rx, uint8_t* neighbour) {
goto cleanup;
}
syslog_info("[facilities] [tolling] reply took %ld ms", it2s_tender_get_clock(&facilities->epv) - tolling->tz);
veh_handle_recv(tolling, &tpm_rx->tpm.tollingFlow.choice.reply);
veh_handle_recv(tolling, &tpm_rx->tpm.tollingFlow.choice.reply, neighbour);
break;
default: