Packet IDs
This commit is contained in:
parent
73349e61d7
commit
a0e18ae4d8
|
|
@ -165,7 +165,7 @@ static enum EVENT_CHECK_R event_check(den_t *den, DENM_t *denm, it2s_tender_epv_
|
||||||
return EVENT_NEW;
|
return EVENT_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event_add(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, int64_t* id) {
|
static int event_add(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, uint64_t* id) {
|
||||||
|
|
||||||
uint64_t now = it2s_tender_get_clock(epv);
|
uint64_t now = it2s_tender_get_clock(epv);
|
||||||
|
|
||||||
|
|
@ -212,8 +212,7 @@ static int event_add(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, int64_t*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
den->events[index]->id = rand();
|
den->events[index]->id = *id;
|
||||||
*id = den->events[index]->id;
|
|
||||||
den->events[index]->enabled = true;
|
den->events[index]->enabled = true;
|
||||||
den->events[index]->state = state;
|
den->events[index]->state = state;
|
||||||
den->events[index]->station_id = denm->denm.management.actionID.originatingStationID;
|
den->events[index]->station_id = denm->denm.management.actionID.originatingStationID;
|
||||||
|
|
@ -236,7 +235,7 @@ static int event_add(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, int64_t*
|
||||||
else return 0; // Event added to db
|
else return 0; // Event added to db
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event_update(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, int64_t* id) {
|
static int event_update(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, uint64_t* id) {
|
||||||
|
|
||||||
uint64_t now = it2s_tender_get_clock(epv);
|
uint64_t now = it2s_tender_get_clock(epv);
|
||||||
|
|
||||||
|
|
@ -319,7 +318,7 @@ static int event_update(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, int64_
|
||||||
else return 0; // Event updated
|
else return 0; // Event updated
|
||||||
}
|
}
|
||||||
|
|
||||||
enum EVENT_CHECK_R event_manage(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, int64_t* id, uint8_t* ssp, uint32_t ssp_len) {
|
enum EVENT_CHECK_R event_manage(den_t *den, DENM_t *denm, it2s_tender_epv_t* epv, uint64_t* id, uint8_t* ssp, uint32_t ssp_len) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
switch (rv = event_check(den, denm, epv, ssp, ssp_len)) {
|
switch (rv = event_check(den, denm, epv, ssp, ssp_len)) {
|
||||||
case EVENT_NEW:
|
case EVENT_NEW:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ typedef struct cc_ssp_bm {
|
||||||
* @param ssp permissions
|
* @param ssp permissions
|
||||||
* @return 0 if event OK, 1 if event NOK
|
* @return 0 if event OK, 1 if event NOK
|
||||||
*/
|
*/
|
||||||
enum EVENT_CHECK_R event_manage(den_t* den, DENM_t* denm, it2s_tender_epv_t* epv, int64_t* id, uint8_t* ssp, uint32_t ssp_len);
|
enum EVENT_CHECK_R event_manage(den_t* den, DENM_t* denm, it2s_tender_epv_t* epv, uint64_t* id, uint8_t* ssp, uint32_t ssp_len);
|
||||||
|
|
||||||
void* den_service(void* fc);
|
void* den_service(void* fc);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,14 +77,15 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
|
|
||||||
bool fwd = false;
|
bool fwd = false;
|
||||||
|
|
||||||
|
uint64_t id = 0;
|
||||||
|
|
||||||
asn_TYPE_descriptor_t *its_msg_descriptor = NULL;
|
asn_TYPE_descriptor_t *its_msg_descriptor = NULL;
|
||||||
void *its_msg = NULL;
|
void *its_msg = NULL;
|
||||||
int its_msg_type = 0;
|
int its_msg_type = 0;
|
||||||
|
|
||||||
switch (tpi->present) {
|
switch (tpi->present) {
|
||||||
case TransportPacketIndication_PR_btp:
|
case TransportPacketIndication_PR_btp:
|
||||||
;
|
id = tpi->choice.btp.id;
|
||||||
|
|
||||||
// Parse message
|
// Parse message
|
||||||
switch (tpi->choice.btp.destinationPort) {
|
switch (tpi->choice.btp.destinationPort) {
|
||||||
case Port_cam:
|
case Port_cam:
|
||||||
|
|
@ -185,7 +186,6 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
syslog_debug("DENM XER %d: %.*s", (int)rve.encoded, (int)rve.encoded , xml_denm);
|
syslog_debug("DENM XER %d: %.*s", (int)rve.encoded, (int)rve.encoded , xml_denm);
|
||||||
free(xml_denm);
|
free(xml_denm);
|
||||||
#endif
|
#endif
|
||||||
int64_t id = -1;
|
|
||||||
switch (event_manage(facilities->den, its_msg, &facilities->epv, &id, ssp, ssp_len)) {
|
switch (event_manage(facilities->den, its_msg, &facilities->epv, &id, ssp, ssp_len)) {
|
||||||
case EVENT_NEW:
|
case EVENT_NEW:
|
||||||
case EVENT_CANCELLATION:
|
case EVENT_CANCELLATION:
|
||||||
|
|
@ -243,6 +243,7 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TransportPacketIndication_PR_tcp:
|
case TransportPacketIndication_PR_tcp:
|
||||||
|
id = tpi->choice.tcp.id;
|
||||||
|
|
||||||
sreq = calloc(1, sizeof(SecurityRequest_t));
|
sreq = calloc(1, sizeof(SecurityRequest_t));
|
||||||
sreq->present = SecurityRequest_PR_tlsRecv;
|
sreq->present = SecurityRequest_PR_tlsRecv;
|
||||||
|
|
@ -315,6 +316,7 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TransportPacketIndication_PR_udp:
|
case TransportPacketIndication_PR_udp:
|
||||||
|
id = tpi->choice.udp.id;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -327,6 +329,8 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
fi->present = FacilitiesIndication_PR_message;
|
fi->present = FacilitiesIndication_PR_message;
|
||||||
FacilitiesMessageIndication_t* fmi = &fi->choice.message;
|
FacilitiesMessageIndication_t* fmi = &fi->choice.message;
|
||||||
|
|
||||||
|
fmi->id = id;
|
||||||
|
|
||||||
fmi->itsMessageType = tpi->choice.btp.destinationPort;
|
fmi->itsMessageType = tpi->choice.btp.destinationPort;
|
||||||
|
|
||||||
fmi->data.size = tpi->choice.btp.data.size;
|
fmi->data.size = tpi->choice.btp.data.size;
|
||||||
|
|
@ -369,7 +373,7 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
||||||
|
|
||||||
switch (fr->present) {
|
switch (fr->present) {
|
||||||
case FacilitiesRequest_PR_message:
|
case FacilitiesRequest_PR_message:
|
||||||
rv = facilities_request_single_message(facilities, responder, fr);
|
rv = facilities_request_single_message(facilities, responder, &fr->choice.message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FacilitiesRequest_PR_data:
|
case FacilitiesRequest_PR_data:
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ static enum SERVICE_EVAL_R service_check(infrastructure_t* infrastructure, enum
|
||||||
|
|
||||||
IVIM_t* ivim = (IVIM_t*) its_msg;
|
IVIM_t* ivim = (IVIM_t*) its_msg;
|
||||||
|
|
||||||
|
|
||||||
uint64_t timestamp, valid_to, valid_from;
|
uint64_t timestamp, valid_to, valid_from;
|
||||||
if (!ivim->ivi.mandatory.timeStamp) {
|
if (!ivim->ivi.mandatory.timeStamp) {
|
||||||
timestamp = now;
|
timestamp = now;
|
||||||
|
|
@ -262,7 +261,7 @@ static enum SERVICE_EVAL_R service_check(infrastructure_t* infrastructure, enum
|
||||||
return SERVICE_NEW;
|
return SERVICE_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int service_add(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, int64_t* id) {
|
static int service_add(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, uint64_t* id) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SERVICE_IVI:
|
case SERVICE_IVI:
|
||||||
|
|
@ -332,8 +331,7 @@ static int service_add(infrastructure_t* infrastructure, enum SERVICE_TYPE type,
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
infrastructure->services[index]->ivim = ivim;
|
infrastructure->services[index]->ivim = ivim;
|
||||||
infrastructure->services[index]->id = rand();
|
infrastructure->services[index]->id = *id;
|
||||||
*id = infrastructure->services[index]->id;
|
|
||||||
infrastructure->services[index]->enabled = true;
|
infrastructure->services[index]->enabled = true;
|
||||||
infrastructure->services[index]->state = state;
|
infrastructure->services[index]->state = state;
|
||||||
infrastructure->services[index]->station_id = ivim->header.stationID;
|
infrastructure->services[index]->station_id = ivim->header.stationID;
|
||||||
|
|
@ -349,7 +347,7 @@ static int service_add(infrastructure_t* infrastructure, enum SERVICE_TYPE type,
|
||||||
else return 0; // Services added to db
|
else return 0; // Services added to db
|
||||||
}
|
}
|
||||||
|
|
||||||
static int service_update(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, int64_t* id) {
|
static int service_update(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, uint64_t* id) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SERVICE_IVI:
|
case SERVICE_IVI:
|
||||||
|
|
@ -456,7 +454,7 @@ static int service_update(infrastructure_t* infrastructure, enum SERVICE_TYPE ty
|
||||||
else return 0; // Event updated
|
else return 0; // Event updated
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SERVICE_EVAL_R service_eval(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, int64_t* id, uint8_t* ssp, uint16_t ssp_len) {
|
enum SERVICE_EVAL_R service_eval(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, uint64_t* id, uint8_t* ssp, uint16_t ssp_len) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
switch (rv = service_check(infrastructure, type, its_msg, epv, ssp, ssp_len)) {
|
switch (rv = service_check(infrastructure, type, its_msg, epv, ssp, ssp_len)) {
|
||||||
case SERVICE_NEW:
|
case SERVICE_NEW:
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ enum SERVICE_EVAL_R {
|
||||||
SERVICE_BAD_PERMISSIONS
|
SERVICE_BAD_PERMISSIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SERVICE_EVAL_R service_eval(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, int64_t* id, uint8_t* ssp, uint16_t ssp_len);
|
enum SERVICE_EVAL_R service_eval(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, it2s_tender_epv_t* epv, uint64_t* id, uint8_t* ssp, uint16_t ssp_len);
|
||||||
|
|
||||||
void* infrastructure_service(void* fc);
|
void* infrastructure_service(void* fc);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,16 @@ int facilities_request_result_rejected(void* responder) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int facilities_request_single_message(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr) {
|
int facilities_request_single_message(facilities_t* facilities, void* responder, FacilitiesMessageRequest_t* frm) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
uint64_t id = 0;
|
||||||
|
if (!frm->id) {
|
||||||
|
id = rand();
|
||||||
|
} else if (*frm->id == 0) {
|
||||||
|
id = rand();
|
||||||
|
}
|
||||||
|
|
||||||
TransportRequest_t* tr = calloc(1, sizeof(TransportRequest_t));
|
TransportRequest_t* tr = calloc(1, sizeof(TransportRequest_t));
|
||||||
tr->present = TransportRequest_PR_packet;
|
tr->present = TransportRequest_PR_packet;
|
||||||
TransportPacketRequest_t* tpr = &tr->choice.packet;
|
TransportPacketRequest_t* tpr = &tr->choice.packet;
|
||||||
|
|
@ -70,7 +77,7 @@ int facilities_request_single_message(facilities_t* facilities, void* responder,
|
||||||
uint32_t transmission_interval = 0;
|
uint32_t transmission_interval = 0;
|
||||||
uint64_t transmission_start = 0;
|
uint64_t transmission_start = 0;
|
||||||
|
|
||||||
switch (fr->choice.message.itsMessageType) {
|
switch (frm->itsMessageType) {
|
||||||
case ItsMessageType_cam:
|
case ItsMessageType_cam:
|
||||||
its_msg_def = &asn_DEF_CAM;
|
its_msg_def = &asn_DEF_CAM;
|
||||||
its_msg = calloc(1, sizeof(CAM_t));
|
its_msg = calloc(1, sizeof(CAM_t));
|
||||||
|
|
@ -105,13 +112,13 @@ int facilities_request_single_message(facilities_t* facilities, void* responder,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
syslog_err("[facilities] unrecognized FR message type (%ld)", fr->choice.message.itsMessageType);
|
syslog_err("[facilities] unrecognized FR message type (%ld)", frm->itsMessageType);
|
||||||
facilities_request_result_rejected(responder);
|
facilities_request_result_rejected(responder);
|
||||||
rv = 1;
|
rv = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_def, (void**) &its_msg, fr->choice.message.data.buf, fr->choice.message.data.size);
|
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_def, (void**) &its_msg, frm->data.buf, frm->data.size);
|
||||||
if (dec.code) {
|
if (dec.code) {
|
||||||
syslog_debug("[facilities] invalid FR %s received", its_msg_def->name);
|
syslog_debug("[facilities] invalid FR %s received", its_msg_def->name);
|
||||||
facilities_request_result_rejected(responder);
|
facilities_request_result_rejected(responder);
|
||||||
|
|
@ -119,11 +126,10 @@ int facilities_request_single_message(facilities_t* facilities, void* responder,
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t id = -1;
|
|
||||||
bool is_update = false;
|
bool is_update = false;
|
||||||
|
|
||||||
int managed_msg = false;
|
int managed_msg = false;
|
||||||
if (fr->choice.message.itsMessageType == ItsMessageType_denm) {
|
if (frm->itsMessageType == ItsMessageType_denm) {
|
||||||
managed_msg = true;
|
managed_msg = true;
|
||||||
|
|
||||||
uint8_t event_type = event_manage(facilities->den, its_msg, &facilities->epv, &id, NULL, 0);
|
uint8_t event_type = event_manage(facilities->den, its_msg, &facilities->epv, &id, NULL, 0);
|
||||||
|
|
@ -211,7 +217,7 @@ int facilities_request_single_message(facilities_t* facilities, void* responder,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fr->choice.message.itsMessageType == ItsMessageType_ivim) {
|
} else if (frm->itsMessageType == ItsMessageType_ivim) {
|
||||||
managed_msg = true;
|
managed_msg = true;
|
||||||
|
|
||||||
uint8_t service_type = service_eval(facilities->infrastructure, SERVICE_IVI, its_msg, &facilities->epv, &id, NULL, 0);
|
uint8_t service_type = service_eval(facilities->infrastructure, SERVICE_IVI, its_msg, &facilities->epv, &id, NULL, 0);
|
||||||
|
|
@ -262,14 +268,10 @@ int facilities_request_single_message(facilities_t* facilities, void* responder,
|
||||||
|
|
||||||
// Forward message to [transport]
|
// Forward message to [transport]
|
||||||
if (fwd) {
|
if (fwd) {
|
||||||
if (id != -1) {
|
|
||||||
bpr->id = id;
|
|
||||||
} else {
|
|
||||||
bpr->id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bpr->btpType = BTPType_btpB;
|
bpr->btpType = BTPType_btpB;
|
||||||
|
|
||||||
|
bpr->id = id;
|
||||||
|
|
||||||
bpr->data.buf = malloc(2048);
|
bpr->data.buf = malloc(2048);
|
||||||
asn_enc_rval_t enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, bpr->data.buf, 2048);
|
asn_enc_rval_t enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, bpr->data.buf, 2048);
|
||||||
if (enc.encoded == -1) {
|
if (enc.encoded == -1) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
int facilities_request_result_accepted(void* responder);
|
int facilities_request_result_accepted(void* responder);
|
||||||
int facilities_request_result_rejected(void* responder);
|
int facilities_request_result_rejected(void* responder);
|
||||||
|
|
||||||
int facilities_request_single_message(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
int facilities_request_single_message(facilities_t* facilities, void* responder, FacilitiesMessageRequest_t* frm);
|
||||||
int facilities_request_active_episodes(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
int facilities_request_active_episodes(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
||||||
int facilities_request_attribute_types(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
int facilities_request_attribute_types(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
||||||
int facilities_request_loaded_protected_zones(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
int facilities_request_loaded_protected_zones(facilities_t* facilities, void* responder, FacilitiesRequest_t* fr);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue