69 lines
2.2 KiB
C
69 lines
2.2 KiB
C
#include "indications.h"
|
|
|
|
#include <it2s-asn/itss-security/SecurityRequest.h>
|
|
#include <it2s-asn/itss-security/SecurityReply.h>
|
|
|
|
#include <it2s-tender/packet.h>
|
|
|
|
static void tcp_conn_reset(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_r[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) {
|
|
log_error("[facilities] SecurityRequest.tlsReset encoding failed");
|
|
}
|
|
|
|
itss_0send(*security_socket, b_s, enc.encoded+1);
|
|
itss_0recv_rt(security_socket, b_r, 64, b_s, 64, 1000);
|
|
|
|
// TODO handle SReply
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
|
}
|
|
|
|
int transport_data_indication(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(&tdi->choice.tcp.choice.connInfoReset, security_socket);
|
|
break;
|
|
default:
|
|
rv = 1;
|
|
goto cleanup;
|
|
}
|
|
break;
|
|
default:
|
|
rv = 1;
|
|
goto cleanup;
|
|
}
|
|
|
|
cleanup:
|
|
|
|
return rv;
|
|
}
|