TLS efforts

This commit is contained in:
emanuel 2022-04-14 17:58:28 +01:00
parent 85f0cfe04b
commit 05778dae7c
1 changed files with 33 additions and 31 deletions

View File

@ -246,7 +246,7 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
packet = tpi->choice.tcp.data.buf;
packet_len = tpi->choice.tcp.data.size;
syslog_debug("[facilities]<- TI.packet.tcp | id:%ld size:%dB", id, msg_len);
sreq = calloc(1, sizeof(SecurityRequest_t));
sreq->present = SecurityRequest_PR_tlsRecv;
sreq->choice.tlsRecv.data.size = tpi->choice.tcp.data.size;
@ -259,8 +259,8 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
syslog_debug("[facilities]->[security] SecurityRequest.tlsRecv (%ldB)", enc.encoded+1);
zmq_send(security_socket, b_sdu, enc.encoded+1, 0);
int32_t rl = zmq_recv(security_socket, b_sdu, enc.encoded, 0);
syslog_debug("[facilities]<-[security] SecurityReply.tlsRecv (%ldB)", enc.encoded);
int32_t rl = zmq_recv(security_socket, b_sdu, 2048, 0);
syslog_debug("[facilities]<-[security] SecurityReply.tlsRecv (%dB)", rl);
if (oer_decode(NULL, &asn_DEF_SecurityReply, (void**) &srep, b_sdu, rl).code) {
syslog_err("[facilities] SecurityReply.tlsRecv decode failure");
@ -282,39 +282,41 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
fflush(stdout);
// Forward to [transport]
tr = calloc(1, sizeof(TransportRequest_t));
tr->present = TransportRequest_PR_packet;
tr->choice.packet.present = TransportPacketRequest_PR_tcp;
TCPPacketRequest_t* tpr = &tr->choice.packet.choice.tcp;
tpr->data.size = srep->data->choice.tlsRecv.data.size;
tpr->data.buf = malloc(srep->data->choice.tlsRecv.data.size);
memcpy(tpr->data.buf, srep->data->choice.tlsRecv.data.buf, srep->data->choice.tlsRecv.data.size);
if (srep->data->choice.tlsRecv.initializing) {
tr = calloc(1, sizeof(TransportRequest_t));
tr->present = TransportRequest_PR_packet;
tr->choice.packet.present = TransportPacketRequest_PR_tcp;
TCPPacketRequest_t* tpr = &tr->choice.packet.choice.tcp;
tpr->data.size = srep->data->choice.tlsRecv.data.size;
tpr->data.buf = malloc(srep->data->choice.tlsRecv.data.size);
memcpy(tpr->data.buf, srep->data->choice.tlsRecv.data.buf, srep->data->choice.tlsRecv.data.size);
tpr->sourcePort = tpi->choice.tcp.destinationPort;
tpr->destinationPort = tpi->choice.tcp.sourcePort;
tpr->sourcePort = tpi->choice.tcp.destinationPort;
tpr->destinationPort = tpi->choice.tcp.sourcePort;
tpr->destinationAddress = calloc(1, sizeof(OCTET_STRING_t));
tpr->destinationAddress->buf = malloc(16);
tpr->destinationAddress->size = 16;
memcpy(tpr->destinationAddress->buf, tpi->choice.tcp.sourceAddress->buf, 16);
tpr->destinationPort = 7011;
tpr->sourcePort = 7011;
tpr->destinationAddress = calloc(1, sizeof(OCTET_STRING_t));
tpr->destinationAddress->buf = malloc(16);
tpr->destinationAddress->size = 16;
memcpy(tpr->destinationAddress->buf, tpi->choice.tcp.sourceAddress->buf, 16);
tpr->destinationPort = 7011;
tpr->sourcePort = 7011;
tpr->gn = calloc(1, sizeof(GeonetworkingOutboundOptions_t));
tpr->gn->packetTransportType = PacketTransportType_shb;
tpr->gn->destinationAddress.buf = calloc(1, 6);
tpr->gn->destinationAddress.size = 6;
tpr->gn = calloc(1, sizeof(GeonetworkingOutboundOptions_t));
tpr->gn->packetTransportType = PacketTransportType_shb;
tpr->gn->destinationAddress.buf = calloc(1, 6);
tpr->gn->destinationAddress.size = 6;
buf[0] = 4;
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
if (enc.encoded == -1) {
syslog_err("TransportRequest encoding fail");
rv = 1;
goto cleanup;
buf[0] = 4;
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
if (enc.encoded == -1) {
syslog_err("TransportRequest encoding fail");
rv = 1;
goto cleanup;
}
it2s_tender_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_TRANSPORT, id, "TR.packet.tcp");
}
it2s_tender_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_TRANSPORT, id, "TR.packet.tcp");
break;
case TransportPacketIndication_PR_udp:
id = tpi->choice.udp.id;
@ -581,7 +583,7 @@ static int networking_indication(facilities_t* facilities, void* responder, uint
}
if (ni->choice.data.mobileNeighbour &&
*ni->choice.data.mobileNeighbour) {
*ni->choice.data.mobileNeighbour) {
pthread_mutex_lock(&facilities->lightship->lock);
facilities->lightship->last_vehicle = it2s_tender_get_clock(&facilities->epv);