68 lines
2.3 KiB
C
68 lines
2.3 KiB
C
#include "indications.h"
|
|
|
|
#include <camv2/asn_application.h>
|
|
#include <itss-security/SecurityRequest.h>
|
|
#include <itss-security/SecurityReply.h>
|
|
|
|
static void tcp_conn_reset(facilities_t* facilities, TCPConnRSTInfo_t* cri, void* security_socket) {
|
|
if (cri->destinationAddress.size != 16) return;
|
|
|
|
SecurityRequest_t* sreq = NULL;
|
|
|
|
// Reset tolling, tls
|
|
tolling_t* tolling = &facilities->tolling;
|
|
bulletin_t* bulletin = &facilities->bulletin;
|
|
if (tolling->enabled &&
|
|
(tolling->protocol.p == TOLLING_PROTOCOL_TLS ||
|
|
tolling->protocol.p == TOLLING_PROTOCOL_TLS_GN ||
|
|
tolling->protocol.p == TOLLING_PROTOCOL_TLS_SHS)
|
|
) {
|
|
for (int i = 0; i < bulletin->to_consume_len; ++i) {
|
|
if (!memcmp(bulletin->to_consume[i]->endpoint.ipv6_addr, cri->destinationAddress.buf, 16)) {
|
|
sreq = calloc(1, sizeof(SecurityRequest_t));
|
|
sreq->present = SecurityRequest_PR_tlsReset;
|
|
sreq->choice.tlsReset.connId = tolling->station.obu.tls_conn_id;
|
|
|
|
uint8_t b_s[64];
|
|
b_s[0] = 4;
|
|
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_CANONICAL_OER, &asn_DEF_SecurityRequest, sreq, b_s+1, 63);
|
|
if (enc.encoded == -1) {
|
|
syslog_err("[facilities] SecurityRequest.tlsReset encoding failed");
|
|
}
|
|
|
|
zmq_send(security_socket, b_s, enc.encoded+1, 0);
|
|
zmq_recv(security_socket, b_s, 64, 0);
|
|
|
|
// TODO handle SReply
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
|
}
|
|
|
|
int transport_data_indication(facilities_t* facilities, TransportDataIndication_t* tdi, void* security_socket) {
|
|
int rv = 0;
|
|
|
|
switch (tdi->present) {
|
|
case TransportDataIndication_PR_tcp:
|
|
switch (tdi->choice.tcp.present) {
|
|
case TCPDataIndication_PR_connInfoReset:
|
|
tcp_conn_reset(facilities, &tdi->choice.tcp.choice.connInfoReset, security_socket);
|
|
break;
|
|
default:
|
|
rv = 1;
|
|
goto cleanup;
|
|
}
|
|
break;
|
|
default:
|
|
rv = 1;
|
|
goto cleanup;
|
|
}
|
|
|
|
cleanup:
|
|
|
|
return rv;
|
|
}
|