58 lines
1.8 KiB
C
58 lines
1.8 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) {
|
|
if (cri->destinationAddress.size != 16) return;
|
|
|
|
SecurityRequest_t* sreq = NULL;
|
|
|
|
// Reset tolling, tls
|
|
tolling_s* tolling = &facilities->tolling;
|
|
bulletin_t* bulletin = &facilities->bulletin;
|
|
if (tolling->enabled && tolling->protocol == TOLLING_PROTOCOL_TLS) {
|
|
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->tls_conn_id;
|
|
|
|
uint8_t b_s[64];
|
|
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_CANONICAL_OER, &asn_DEF_SecurityRequest, sreq, b_s, 64);
|
|
if (enc.encoded == -1) {
|
|
syslog_err("[facilities] SecurityRequest.tlsReset encoding failed");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ASN_STRUCT_FREE(asn_DEF_SecurityRequest, sreq);
|
|
}
|
|
|
|
int transport_data_indication(facilities_t* facilities, TransportDataIndication_t* tdi) {
|
|
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);
|
|
break;
|
|
default:
|
|
rv = 1;
|
|
goto cleanup;
|
|
}
|
|
break;
|
|
default:
|
|
rv = 1;
|
|
goto cleanup;
|
|
}
|
|
|
|
cleanup:
|
|
|
|
return rv;
|
|
}
|