Forward TPMs to [applications]
This commit is contained in:
parent
ae6480f109
commit
a7683aff77
|
|
@ -227,6 +227,7 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
case 7011:
|
case 7011:
|
||||||
if (facilities->tolling.enabled) {
|
if (facilities->tolling.enabled) {
|
||||||
tpm_recv(facilities, its_msg, security_socket, neighbour_cert, NULL);
|
tpm_recv(facilities, its_msg, security_socket, neighbour_cert, NULL);
|
||||||
|
fwd = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
39
src/tpm.c
39
src/tpm.c
|
|
@ -1,8 +1,10 @@
|
||||||
#include "tpm.h"
|
#include "tpm.h"
|
||||||
#include "facilities.h"
|
#include "facilities.h"
|
||||||
|
|
||||||
|
#include <it2s-tender/constants.h>
|
||||||
#include <itss-security/SecurityRequest.h>
|
#include <itss-security/SecurityRequest.h>
|
||||||
#include <itss-security/SecurityReply.h>
|
#include <itss-security/SecurityReply.h>
|
||||||
|
#include <itss-facilities/FacilitiesIndication.h>
|
||||||
#include <it2s-tender/time.h>
|
#include <it2s-tender/time.h>
|
||||||
#include <itss-transport/TransportRequest.h>
|
#include <itss-transport/TransportRequest.h>
|
||||||
#include <it2s-tender/space.h>
|
#include <it2s-tender/space.h>
|
||||||
|
|
@ -42,6 +44,7 @@ int tpm_pay(void* fc, tolling_info_s* info, void* security_socket, uint8_t* neig
|
||||||
TransportRequest_t* tr = NULL;
|
TransportRequest_t* tr = NULL;
|
||||||
SecurityRequest_t* sreq = NULL;
|
SecurityRequest_t* sreq = NULL;
|
||||||
SecurityReply_t* srep = NULL;
|
SecurityReply_t* srep = NULL;
|
||||||
|
FacilitiesIndication_t* fi = NULL;
|
||||||
TPM_t* tpm = NULL;
|
TPM_t* tpm = NULL;
|
||||||
|
|
||||||
const size_t buf_len = 2048;
|
const size_t buf_len = 2048;
|
||||||
|
|
@ -247,6 +250,23 @@ int tpm_pay(void* fc, tolling_info_s* info, void* security_socket, uint8_t* neig
|
||||||
pthread_mutex_unlock(&facilities->id.lock);
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
it2s_tender_db_add(facilities->logging.dbms, station_id, id, &facilities->epv, true, 117, NULL, tpm_uper, tpm_uper_len);
|
it2s_tender_db_add(facilities->logging.dbms, station_id, id, &facilities->epv, true, 117, NULL, tpm_uper, tpm_uper_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send to [applications]
|
||||||
|
fi = calloc(1, sizeof(FacilitiesIndication_t));
|
||||||
|
fi->present = FacilitiesIndication_PR_message;
|
||||||
|
fi->choice.message.id = id;
|
||||||
|
fi->choice.message.itsMessageType = 7011;
|
||||||
|
fi->choice.message.data.size = tpm_uper_len;
|
||||||
|
fi->choice.message.data.buf = malloc(tpm_uper_len);
|
||||||
|
memcpy(fi->choice.message.data.buf, tpm_uper, tpm_uper_len);
|
||||||
|
enc = oer_encode_to_buffer(&asn_DEF_FacilitiesIndication, NULL, fi, buf+1, buf_len-1);
|
||||||
|
if (enc.encoded == -1) {
|
||||||
|
syslog_err("[facilities] [tolling] error encoding FI TPM.request (%s)", enc.failed_type->name);
|
||||||
|
rv = 1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
it2s_tender_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_APPLICATIONS, id, "FI.message (TPM.request)");
|
||||||
|
|
||||||
if (facilities->logging.recorder) {
|
if (facilities->logging.recorder) {
|
||||||
uint16_t buffer_len = 2048;
|
uint16_t buffer_len = 2048;
|
||||||
uint8_t buffer[buffer_len];
|
uint8_t buffer[buffer_len];
|
||||||
|
|
@ -269,6 +289,7 @@ cleanup:
|
||||||
ASN_STRUCT_FREE(asn_DEF_TransportRequest, tr);
|
ASN_STRUCT_FREE(asn_DEF_TransportRequest, tr);
|
||||||
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
||||||
ASN_STRUCT_FREE(asn_DEF_SecurityReply, srep);
|
ASN_STRUCT_FREE(asn_DEF_SecurityReply, srep);
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_FacilitiesIndication, fi);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
@ -304,6 +325,7 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, void* secur
|
||||||
TransportRequest_t* tr = NULL;
|
TransportRequest_t* tr = NULL;
|
||||||
SecurityRequest_t* sreq = NULL;
|
SecurityRequest_t* sreq = NULL;
|
||||||
SecurityReply_t* srep = NULL;
|
SecurityReply_t* srep = NULL;
|
||||||
|
FacilitiesIndication_t* fi = NULL;
|
||||||
TPM_t* tpm = NULL;
|
TPM_t* tpm = NULL;
|
||||||
|
|
||||||
if (tolling->protocol == TOLLING_PROTOCOL_SIMPLE) {
|
if (tolling->protocol == TOLLING_PROTOCOL_SIMPLE) {
|
||||||
|
|
@ -555,6 +577,22 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, void* secur
|
||||||
pthread_mutex_unlock(&facilities->id.lock);
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
it2s_tender_db_add(facilities->logging.dbms, station_id, id, &facilities->epv, true, 117, NULL, tpm_uper, tpm_uper_len);
|
it2s_tender_db_add(facilities->logging.dbms, station_id, id, &facilities->epv, true, 117, NULL, tpm_uper, tpm_uper_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send to [applications]
|
||||||
|
fi = calloc(1, sizeof(FacilitiesIndication_t));
|
||||||
|
fi->present = FacilitiesIndication_PR_message;
|
||||||
|
fi->choice.message.id = id;
|
||||||
|
fi->choice.message.itsMessageType = 7011;
|
||||||
|
fi->choice.message.data.size = tpm_uper_len;
|
||||||
|
fi->choice.message.data.buf = malloc(tpm_uper_len);
|
||||||
|
memcpy(fi->choice.message.data.buf, tpm_uper, tpm_uper_len);
|
||||||
|
enc = oer_encode_to_buffer(&asn_DEF_FacilitiesIndication, NULL, fi, buf+1, buf_len-1);
|
||||||
|
if (enc.encoded == -1) {
|
||||||
|
syslog_err("[facilities] [tolling] error encoding FI TPM.reply (%s)", enc.failed_type->name);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
it2s_tender_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_APPLICATIONS, id, "FI.message (TPM.reply)");
|
||||||
if (facilities->logging.recorder) {
|
if (facilities->logging.recorder) {
|
||||||
uint16_t buffer_len = 2048;
|
uint16_t buffer_len = 2048;
|
||||||
uint8_t buffer[buffer_len];
|
uint8_t buffer[buffer_len];
|
||||||
|
|
@ -577,6 +615,7 @@ cleanup:
|
||||||
ASN_STRUCT_FREE(asn_DEF_TransportRequest, tr);
|
ASN_STRUCT_FREE(asn_DEF_TransportRequest, tr);
|
||||||
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
||||||
ASN_STRUCT_FREE(asn_DEF_SecurityReply, srep);
|
ASN_STRUCT_FREE(asn_DEF_SecurityReply, srep);
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_FacilitiesIndication, fi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void veh_handle_recv(tolling_s* tolling, TPM_t* tpm_rx, void* security_socket, uint8_t* neighbour) {
|
static void veh_handle_recv(tolling_s* tolling, TPM_t* tpm_rx, void* security_socket, uint8_t* neighbour) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue