TPM closed system efforts
This commit is contained in:
parent
ace3bcecc1
commit
1fff533e2b
60
src/tpm.c
60
src/tpm.c
|
|
@ -118,7 +118,13 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
|
||||||
type->choice.exit->choice.request->clientId = tolling->station.obu.client_id;
|
type->choice.exit->choice.request->clientId = tolling->station.obu.client_id;
|
||||||
type->choice.exit->choice.request->infoId = info->asn->id;
|
type->choice.exit->choice.request->infoId = info->asn->id;
|
||||||
type->choice.exit->choice.request->transactionNonce = tolling->station.obu.nonce;
|
type->choice.exit->choice.request->transactionNonce = tolling->station.obu.nonce;
|
||||||
//type->choice.exit->choice.request->entryProof = calloc(1, sizeof(TollingEntryProof_t));
|
uint8_t b_tep[1024];
|
||||||
|
asn_enc_rval_t e_tep = uper_encode_to_buffer(&asn_DEF_TPM, NULL, tolling->station.obu.entry_proof, b_tep, 1024);
|
||||||
|
if (e_tep.encoded == -1) {
|
||||||
|
syslog_err("[facilities] [tolling] error encoding TPM entry proof");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
uper_decode_complete(NULL, &asn_DEF_TPM, (void**) &type->choice.exit->choice.request->entryProof, b_tep, (e_tep.encoded+7)/8);
|
||||||
break;
|
break;
|
||||||
case TollType_single:
|
case TollType_single:
|
||||||
type->present = TollingType_PR_single;
|
type->present = TollingType_PR_single;
|
||||||
|
|
@ -796,11 +802,24 @@ static void veh_handle_recv(tolling_t* tolling, TPM_t* tpm_rx, void* security_so
|
||||||
syslog_err("[facilities] [tolling] received TPM.entry is not reply");
|
syslog_err("[facilities] [tolling] received TPM.entry is not reply");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (tolling->station.obu.toll_type != TollingType_PR_entry) {
|
||||||
|
syslog_err("[facilities] [tolling] received TPM (%d) is not expected toll type (%d)",
|
||||||
|
TollingType_PR_entry, tolling->station.obu.toll_type);
|
||||||
|
}
|
||||||
client_id = type_rx->choice.entry.choice.reply.clientId;
|
client_id = type_rx->choice.entry.choice.reply.clientId;
|
||||||
nonce = type_rx->choice.entry.choice.reply.transactionNonce;
|
nonce = type_rx->choice.entry.choice.reply.transactionNonce;
|
||||||
info_id = type_rx->choice.entry.choice.reply.infoId;
|
info_id = type_rx->choice.entry.choice.reply.infoId;
|
||||||
confirmation_code = type_rx->choice.entry.choice.reply.confirmationCode;
|
confirmation_code = type_rx->choice.entry.choice.reply.confirmationCode;
|
||||||
|
|
||||||
|
uint8_t b_tep[1024];
|
||||||
|
asn_enc_rval_t e_tep = uper_encode_to_buffer(&asn_DEF_TPM, NULL, tpm_rx, b_tep, 1024);
|
||||||
|
if (e_tep.encoded == -1) {
|
||||||
|
syslog_err("[facilities] [tolling] error encoding received TPM as entry proof");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uper_decode_complete(NULL, &asn_DEF_TPM, (void**) &tolling->station.obu.entry_proof, b_tep, (e_tep.encoded+7)/8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TollingType_PR_exit:
|
case TollingType_PR_exit:
|
||||||
if (!type_rx->choice.exit ||
|
if (!type_rx->choice.exit ||
|
||||||
type_rx->choice.exit->present != TollingExit_PR_reply
|
type_rx->choice.exit->present != TollingExit_PR_reply
|
||||||
|
|
@ -808,28 +827,37 @@ static void veh_handle_recv(tolling_t* tolling, TPM_t* tpm_rx, void* security_so
|
||||||
syslog_err("[facilities] [tolling] received TPM.exit is not reply");
|
syslog_err("[facilities] [tolling] received TPM.exit is not reply");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (tolling->station.obu.toll_type != TollingType_PR_exit) {
|
||||||
|
syslog_err("[facilities] [tolling] received TPM (%d) is not expected toll type (%d)",
|
||||||
|
TollingType_PR_exit, tolling->station.obu.toll_type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
client_id = type_rx->choice.exit->choice.reply.clientId;
|
client_id = type_rx->choice.exit->choice.reply.clientId;
|
||||||
nonce = type_rx->choice.exit->choice.reply.transactionNonce;
|
nonce = type_rx->choice.exit->choice.reply.transactionNonce;
|
||||||
info_id = type_rx->choice.exit->choice.reply.infoId;
|
info_id = type_rx->choice.exit->choice.reply.infoId;
|
||||||
confirmation_code = type_rx->choice.exit->choice.reply.confirmationCode;
|
confirmation_code = type_rx->choice.exit->choice.reply.confirmationCode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TollingType_PR_single:
|
case TollingType_PR_single:
|
||||||
if (type_rx->choice.single.present != TollingSingle_PR_reply) {
|
if (type_rx->choice.single.present != TollingSingle_PR_reply) {
|
||||||
syslog_err("[facilities] [tolling] received TPM.single is not reply");
|
syslog_err("[facilities] [tolling] received TPM.single is not reply");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (tolling->station.obu.toll_type != TollingType_PR_single) {
|
||||||
|
syslog_err("[facilities] [tolling] received TPM (%d) is not expected toll type (%d)",
|
||||||
|
TollingType_PR_single, tolling->station.obu.toll_type);
|
||||||
|
}
|
||||||
client_id = type_rx->choice.single.choice.reply.clientId;
|
client_id = type_rx->choice.single.choice.reply.clientId;
|
||||||
nonce = type_rx->choice.single.choice.reply.transactionNonce;
|
nonce = type_rx->choice.single.choice.reply.transactionNonce;
|
||||||
info_id = type_rx->choice.single.choice.reply.infoId;
|
info_id = type_rx->choice.single.choice.reply.infoId;
|
||||||
confirmation_code = type_rx->choice.single.choice.reply.confirmationCode;
|
confirmation_code = type_rx->choice.single.choice.reply.confirmationCode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
syslog_err("[facilities] [tolling] received TPM has unrecognized type");
|
syslog_err("[facilities] [tolling] received TPM has unrecognized type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO if sent ENTRY.REQUEST expect ENTRY.REPLY, if send SINGLE.REQUEST expect ENTRY.REPLY, etc
|
|
||||||
|
|
||||||
if (client_id != tolling->station.obu.client_id) {
|
if (client_id != tolling->station.obu.client_id) {
|
||||||
syslog_debug("[facilities] [tolling]<- received TPM.reply clientId different from ego");
|
syslog_debug("[facilities] [tolling]<- received TPM.reply clientId different from ego");
|
||||||
return;
|
return;
|
||||||
|
|
@ -902,9 +930,29 @@ static void veh_handle_recv(tolling_t* tolling, TPM_t* tpm_rx, void* security_so
|
||||||
accepted = confirmation_code == TollingConfirmationCode_accepted;
|
accepted = confirmation_code == TollingConfirmationCode_accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog_info("[facilities] [tolling] received tolling payment reply | client:%lld nonce:%ld accepted:%s", (long long) tolling->station.obu.client_id, tolling->station.obu.nonce, accepted ? "yes" : "no");
|
switch (type_rx->present) {
|
||||||
|
case TollingType_PR_entry:
|
||||||
|
syslog_info("[facilities] [tolling] received entry tolling reply | client:%lld nonce:%ld accepted:%s", (long long) tolling->station.obu.client_id, tolling->station.obu.nonce, accepted ? "yes" : "no");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TollingType_PR_exit:
|
||||||
|
syslog_info("[facilities] [tolling] received exit tolling reply | client:%lld nonce:%ld accepted:%s", (long long) tolling->station.obu.client_id, tolling->station.obu.nonce, accepted ? "yes" : "no");
|
||||||
|
tolling->station.obu.toll_type = -1;
|
||||||
|
tolling->station.obu.active = false;
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_TPM, tolling->station.obu.entry_proof);
|
||||||
|
tolling->station.obu.entry_proof = NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TollingType_PR_single:
|
||||||
|
syslog_info("[facilities] [tolling] received single tolling reply | client:%lld nonce:%ld accepted:%s", (long long) tolling->station.obu.client_id, tolling->station.obu.nonce, accepted ? "yes" : "no");
|
||||||
|
tolling->station.obu.toll_type = -1;
|
||||||
|
tolling->station.obu.active = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tolling->station.obu.active = false;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
||||||
|
|
@ -983,7 +1031,7 @@ int tpm_recv(void* fc, TPM_t* tpm_rx, void* security_socket, uint8_t* neighbour,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
// Single
|
||||||
case TollingType_PR_single:
|
case TollingType_PR_single:
|
||||||
switch (tpm_rx->tpm->tollingType->choice.single.present) {
|
switch (tpm_rx->tpm->tollingType->choice.single.present) {
|
||||||
case TollingSingle_PR_request:
|
case TollingSingle_PR_request:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue