This commit is contained in:
parent
dec270f337
commit
e1b0521b19
10
src/cam.c
10
src/cam.c
|
|
@ -175,15 +175,15 @@ void *ca_service(void *fc) {
|
||||||
|
|
||||||
bdr->btpType = BTPType_btpB;
|
bdr->btpType = BTPType_btpB;
|
||||||
|
|
||||||
bdr->destinationAddress.buf = malloc(6);
|
bdr->gnDestinationAddress.buf = malloc(6);
|
||||||
for (int i = 0; i < 6; ++i) {bdr->destinationAddress.buf[i] = 0xff;}
|
for (int i = 0; i < 6; ++i) {bdr->gnDestinationAddress.buf[i] = 0xff;}
|
||||||
bdr->destinationAddress.size = 6;
|
bdr->gnDestinationAddress.size = 6;
|
||||||
|
|
||||||
bdr->packetTransportType = PacketTransportType_shb;
|
bdr->gnPacketTransportType = PacketTransportType_shb;
|
||||||
|
|
||||||
bdr->destinationPort = Port_cam;
|
bdr->destinationPort = Port_cam;
|
||||||
|
|
||||||
bdr->trafficClass = 2;
|
bdr->gnTrafficClass = 2;
|
||||||
|
|
||||||
bdr->data.buf = malloc(256);
|
bdr->data.buf = malloc(256);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ static int transport_indication(facilities_t *facilities, uint8_t *msg, uint32_t
|
||||||
|
|
||||||
dec = uper_decode_complete(NULL, its_msg_descriptor, (void**) &its_msg, bdi->data.buf, bdi->data.size);
|
dec = uper_decode_complete(NULL, its_msg_descriptor, (void**) &its_msg, bdi->data.buf, bdi->data.size);
|
||||||
if (dec.code) {
|
if (dec.code) {
|
||||||
syslog_debug("[facilities] invalid %s received", its_msg_descriptor->name);
|
syslog_debug("[facilities]<- invalid %s received", its_msg_descriptor->name);
|
||||||
rv = 1;
|
rv = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ static int transport_indication(facilities_t *facilities, uint8_t *msg, uint32_t
|
||||||
uint8_t buffer[512];
|
uint8_t buffer[512];
|
||||||
buffer[0] = 4; // Facilities
|
buffer[0] = 4; // Facilities
|
||||||
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_FacilitiesDataIndication, NULL, fdi, buffer+1, 511);
|
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_FacilitiesDataIndication, NULL, fdi, buffer+1, 511);
|
||||||
syslog_debug("[facilities] -> [app] FDI (%ldB)", enc.encoded);
|
syslog_debug("[facilities] -> sending FDI to -> [app] (%ldB)", enc.encoded);
|
||||||
zmq_send(facilities->app_socket, buffer, enc.encoded+1, 0);
|
zmq_send(facilities->app_socket, buffer, enc.encoded+1, 0);
|
||||||
zmq_recv(facilities->app_socket, &code, 1, 0);
|
zmq_recv(facilities->app_socket, &code, 1, 0);
|
||||||
|
|
||||||
|
|
@ -118,13 +118,18 @@ static int facilities_request(facilities_t *facilities, uint8_t *msg, uint32_t m
|
||||||
uint8_t *fdres_oer = NULL;
|
uint8_t *fdres_oer = NULL;
|
||||||
asn_enc_rval_t enc;
|
asn_enc_rval_t enc;
|
||||||
|
|
||||||
|
void *its_msg = NULL;
|
||||||
|
asn_TYPE_descriptor_t *its_msg_def = NULL;
|
||||||
|
|
||||||
|
bool managed_event = false;
|
||||||
|
|
||||||
FacilitiesDataRequest_t *fdreq = calloc(1, sizeof(FacilitiesDataRequest_t));
|
FacilitiesDataRequest_t *fdreq = calloc(1, sizeof(FacilitiesDataRequest_t));
|
||||||
FacilitiesDataResult_t *fdres = calloc(1, sizeof(FacilitiesDataResult_t));
|
FacilitiesDataResult_t *fdres = calloc(1, sizeof(FacilitiesDataResult_t));
|
||||||
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
||||||
|
|
||||||
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_FacilitiesDataRequest, (void**) &fdreq, msg, msg_len);
|
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_FacilitiesDataRequest, (void**) &fdreq, msg, msg_len);
|
||||||
if (dec.code) {
|
if (dec.code) {
|
||||||
syslog_err("[facilities] <- invalid FDR received");
|
syslog_err("[facilities]<- invalid FDRequest received");
|
||||||
rv = 1;
|
rv = 1;
|
||||||
code = 1;
|
code = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
@ -135,22 +140,28 @@ static int facilities_request(facilities_t *facilities, uint8_t *msg, uint32_t m
|
||||||
;
|
;
|
||||||
bool fwd = true;
|
bool fwd = true;
|
||||||
switch (fdreq->choice.singleMessage.itssMessageType) {
|
switch (fdreq->choice.singleMessage.itssMessageType) {
|
||||||
|
case ItssMessageType_cam:
|
||||||
|
its_msg_def = &asn_DEF_CAM;
|
||||||
|
its_msg = calloc(1, sizeof(CAM_t));
|
||||||
|
bdr->destinationPort = Port_cam;
|
||||||
|
bdr->gnPacketTransportType = PacketTransportType_shb;
|
||||||
|
bdr->gnTrafficClass = 1;
|
||||||
|
|
||||||
|
break;
|
||||||
case ItssMessageType_denm:
|
case ItssMessageType_denm:
|
||||||
;
|
its_msg_def = &asn_DEF_DENM;
|
||||||
DENM_t *denm = calloc(1, sizeof(DENM_t));
|
its_msg = calloc(1, sizeof(DENM_t));
|
||||||
dec = uper_decode_complete(NULL, &asn_DEF_DENM, (void**) &denm, fdreq->choice.singleMessage.data.buf, fdreq->choice.singleMessage.data.size);
|
|
||||||
if (dec.code) {
|
|
||||||
syslog_debug("[facilities] invalid FDRequest DENM received");
|
|
||||||
rv = 1;
|
|
||||||
ASN_STRUCT_FREE(asn_DEF_DENM, denm);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
bdr->destinationPort = Port_denm;
|
bdr->destinationPort = Port_denm;
|
||||||
|
bdr->gnPacketTransportType = PacketTransportType_gbc;
|
||||||
|
bdr->gnTrafficClass = 2;
|
||||||
|
|
||||||
if (event_manage(facilities->den, denm)) {
|
break;
|
||||||
fwd = false;
|
case ItssMessageType_ivim:
|
||||||
}
|
its_msg_def = &asn_DEF_IVIM;
|
||||||
|
its_msg = calloc(1, sizeof(IVIM_t));
|
||||||
|
bdr->destinationPort = Port_ivim;
|
||||||
|
bdr->gnPacketTransportType = PacketTransportType_shb;
|
||||||
|
bdr->gnTrafficClass = 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -159,6 +170,20 @@ static int facilities_request(facilities_t *facilities, uint8_t *msg, uint32_t m
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dec = uper_decode_complete(NULL, its_msg_def, (void**) &its_msg, fdreq->choice.singleMessage.data.buf, fdreq->choice.singleMessage.data.size);
|
||||||
|
if (dec.code) {
|
||||||
|
syslog_debug("[facilities] invalid FDRequest %s received", its_msg_def->name);
|
||||||
|
rv = 1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fdreq->choice.singleMessage.itssMessageType == ItssMessageType_denm) {
|
||||||
|
managed_event = true;
|
||||||
|
if (event_manage(facilities->den, its_msg)) {
|
||||||
|
fwd = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Respond to [itss]
|
// Respond to [itss]
|
||||||
fdres->code = ResultCode_accepted;
|
fdres->code = ResultCode_accepted;
|
||||||
fdres_oer = malloc(16);
|
fdres_oer = malloc(16);
|
||||||
|
|
@ -176,11 +201,9 @@ static int facilities_request(facilities_t *facilities, uint8_t *msg, uint32_t m
|
||||||
bdr->data.buf = malloc(fdreq->choice.singleMessage.data.size);
|
bdr->data.buf = malloc(fdreq->choice.singleMessage.data.size);
|
||||||
memcpy(bdr->data.buf, fdreq->choice.singleMessage.data.buf, fdreq->choice.singleMessage.data.size);
|
memcpy(bdr->data.buf, fdreq->choice.singleMessage.data.buf, fdreq->choice.singleMessage.data.size);
|
||||||
bdr->data.size = fdreq->choice.singleMessage.data.size;
|
bdr->data.size = fdreq->choice.singleMessage.data.size;
|
||||||
bdr->destinationAddress.buf = malloc(6);
|
bdr->gnDestinationAddress.buf = malloc(6);
|
||||||
for (int i = 0; i < 6; ++i) bdr->destinationAddress.buf[i] = 0xff;
|
for (int i = 0; i < 6; ++i) bdr->gnDestinationAddress.buf[i] = 0xff;
|
||||||
bdr->destinationAddress.size = 6;
|
bdr->gnDestinationAddress.size = 6;
|
||||||
bdr->packetTransportType = PacketTransportType_gbc;
|
|
||||||
bdr->trafficClass = 1;
|
|
||||||
|
|
||||||
// Encode ITS message into OER
|
// Encode ITS message into OER
|
||||||
uint8_t bdr_oer[384];
|
uint8_t bdr_oer[384];
|
||||||
|
|
@ -258,6 +281,7 @@ static int facilities_request(facilities_t *facilities, uint8_t *msg, uint32_t m
|
||||||
zmq_send(facilities->responder, fdres_oer, enc.encoded, 0);
|
zmq_send(facilities->responder, fdres_oer, enc.encoded, 0);
|
||||||
}
|
}
|
||||||
free(fdres_oer);
|
free(fdres_oer);
|
||||||
|
if (its_msg_def && !managed_event) ASN_STRUCT_FREE(*its_msg_def, its_msg);
|
||||||
ASN_STRUCT_FREE(asn_DEF_FacilitiesDataResult, fdres);
|
ASN_STRUCT_FREE(asn_DEF_FacilitiesDataResult, fdres);
|
||||||
ASN_STRUCT_FREE(asn_DEF_FacilitiesDataRequest, fdreq);
|
ASN_STRUCT_FREE(asn_DEF_FacilitiesDataRequest, fdreq);
|
||||||
ASN_STRUCT_FREE(asn_DEF_BTPDataRequest, bdr);
|
ASN_STRUCT_FREE(asn_DEF_BTPDataRequest, bdr);
|
||||||
|
|
@ -297,8 +321,6 @@ int main() {
|
||||||
memset(buffer, 0x00, 512);
|
memset(buffer, 0x00, 512);
|
||||||
zmq_recv(facilities.responder, buffer, 512, 0);
|
zmq_recv(facilities.responder, buffer, 512, 0);
|
||||||
|
|
||||||
printf("NEW MESSAGE buffer[0] %d \n", buffer[0]);
|
|
||||||
|
|
||||||
switch (buffer[0]) {
|
switch (buffer[0]) {
|
||||||
case 3:
|
case 3:
|
||||||
code = transport_indication(&facilities, buffer+1, 511);
|
code = transport_indication(&facilities, buffer+1, 511);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue