IVIM permissions
This commit is contained in:
parent
4ca9572932
commit
60b061e5b3
|
|
@ -14,7 +14,54 @@
|
||||||
#define syslog_debug(msg, ...)
|
#define syslog_debug(msg, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static enum SERVICE_EVAL_RESULT service_check(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg) {
|
const ivi_diid_ssp_bm_t DIID_SSP_BM_MAP[] = {
|
||||||
|
{"Vienna Convention Code for road sign", IVI_DIID_ViennaCodeConvention, 0x800000},
|
||||||
|
{"ISO 14823 traffic sign pictogram (danger/warning)", IVI_DIID_TrafficSignPictogramDangerWarning, 0x400000},
|
||||||
|
{"ISO 14823 traffic sign pictogram (regulatory)", IVI_DIID_TrafficSignPictogramRegulatory, 0x200000},
|
||||||
|
{"ISO 14823 traffic sign pictogram (informative)", IVI_DIID_TrafficSignPictogramInformative, 0x100000},
|
||||||
|
{"ISO 14823 public facilities pictogram", IVI_DIID_ServiceCategoryCodePublicFacilitiesPictogram, 0x080000},
|
||||||
|
{"ISO 14283 ambient or road conditions pictogram (ambient condition)", IVI_DIID_ServiceCategoryCodeAmbientOrRoadConditionPictogramAmbientCondition, 0x040000},
|
||||||
|
{"ISO 14283 ambient or road conditions pictogram (road condition)", IVI_DIID_ServiceCategoryCodeAmbientOrRoadConditionPictogramRoadCondition, 0x020000},
|
||||||
|
{"ITIS codes", IVI_DIID_itisCodes, 0x010000},
|
||||||
|
{"Lane status", IVI_DIID_laneStatus, 0x008000},
|
||||||
|
{"Road configuration container", IVI_DIID_rcc, 0x004000},
|
||||||
|
{"Text container", IVI_DIID_tc, 0x002000},
|
||||||
|
{"Layout container", IVI_DIID_lac, 0x001000},
|
||||||
|
{"IVI Status (negation)", IVI_DIID_StatusNegation, 0x000800},
|
||||||
|
};
|
||||||
|
|
||||||
|
static int permissions_check(int diid, uint8_t* permissions, uint8_t permissions_len) {
|
||||||
|
/* IVIM SSP scheme
|
||||||
|
*
|
||||||
|
* byte | description
|
||||||
|
* ---------------------------------
|
||||||
|
* 0 | SSP version control
|
||||||
|
* 1-3 | Service Provider ID
|
||||||
|
* 4-5 | Service-specific parameters
|
||||||
|
* 6-30 | Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (permissions_len < 6) {
|
||||||
|
syslog_debug("[facilities] [infrastrucutre] [ivi] permissions length too small");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t perms_int = *(((uint16_t*) permissions)+2);
|
||||||
|
|
||||||
|
uint32_t perm_val;
|
||||||
|
for (int i = 0; i < 13; ++i) {
|
||||||
|
if (diid == DIID_SSP_BM_MAP[i].diid) {
|
||||||
|
perm_val = DIID_SSP_BM_MAP[i].bitmap_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((perm_val & perms_int) == perm_val) return 1;
|
||||||
|
else return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static enum SERVICE_EVAL_RESULT service_check(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, ServiceSpecificPermissions_t* ssp) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
struct timespec systemtime;
|
struct timespec systemtime;
|
||||||
|
|
@ -31,6 +78,7 @@ static enum SERVICE_EVAL_RESULT service_check(infrastructure_t* infrastructure,
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -56,6 +104,102 @@ static enum SERVICE_EVAL_RESULT service_check(infrastructure_t* infrastructure,
|
||||||
|
|
||||||
uint32_t validity_duration = valid_to - valid_from;
|
uint32_t validity_duration = valid_to - valid_from;
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if (ssp) {
|
||||||
|
if (ivim->ivi.optional) {
|
||||||
|
for (int i = 0; i < ivim->ivi.optional->list.count; ++i) {
|
||||||
|
switch (ivim->ivi.optional->list.array[i]->present) {
|
||||||
|
case IviContainer_PR_giv:
|
||||||
|
;
|
||||||
|
GeneralIviContainer_t* giv = &ivim->ivi.optional->list.array[i]->choice.giv;
|
||||||
|
|
||||||
|
for (int j = 0; j < giv->list.count; ++j) {
|
||||||
|
GicPart_t* gicp = giv->list.array[j];
|
||||||
|
|
||||||
|
for (int k = 0; k < gicp->roadSignCodes.list.count; ++k) {
|
||||||
|
struct RSCode__code* code = &gicp->roadSignCodes.list.array[k]->code;
|
||||||
|
|
||||||
|
switch (code->present) {
|
||||||
|
case RSCode__code_PR_viennaConvention:
|
||||||
|
if (!permissions_check(IVI_DIID_ViennaCodeConvention, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RSCode__code_PR_iso14823:
|
||||||
|
switch (code->choice.iso14823.pictogramCode.serviceCategoryCode.present) {
|
||||||
|
case ISO14823Code__pictogramCode__serviceCategoryCode_PR_trafficSignPictogram:
|
||||||
|
switch (code->choice.iso14823.pictogramCode.serviceCategoryCode.choice.trafficSignPictogram) {
|
||||||
|
case Pictogram_trafficSign_dangerWarning:
|
||||||
|
if (!permissions_check(IVI_DIID_TrafficSignPictogramDangerWarning, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
case Pictogram_trafficSign_regulatory:
|
||||||
|
if (!permissions_check(IVI_DIID_TrafficSignPictogramRegulatory, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
case Pictogram_trafficSign_informative:
|
||||||
|
if (!permissions_check(IVI_DIID_TrafficSignPictogramInformative, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ISO14823Code__pictogramCode__serviceCategoryCode_PR_publicFacilitiesPictogram:
|
||||||
|
if (!permissions_check(IVI_DIID_ServiceCategoryCodePublicFacilitiesPictogram, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ISO14823Code__pictogramCode__serviceCategoryCode_PR_ambientOrRoadConditionPictogram:
|
||||||
|
switch (code->choice.iso14823.pictogramCode.serviceCategoryCode.choice.ambientOrRoadConditionPictogram) {
|
||||||
|
case Pictogram_conditionsSign_ambientCondition:
|
||||||
|
if (!permissions_check(IVI_DIID_ServiceCategoryCodeAmbientOrRoadConditionPictogramAmbientCondition, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
case Pictogram_conditionsSign_roadCondition:
|
||||||
|
if (!permissions_check(IVI_DIID_ServiceCategoryCodeAmbientOrRoadConditionPictogramRoadCondition, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RSCode__code_PR_itisCodes:
|
||||||
|
if (!permissions_check(IVI_DIID_itisCodes, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
} // end RSCode switch
|
||||||
|
} // end roadSIgn codes for
|
||||||
|
|
||||||
|
if (gicp->laneStatus) {
|
||||||
|
if (!permissions_check(IVI_DIID_laneStatus, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
}
|
||||||
|
} // end giv list for
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IviContainer_PR_rcc:
|
||||||
|
if (!permissions_check(IVI_DIID_rcc, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IviContainer_PR_tc:
|
||||||
|
if (!permissions_check(IVI_DIID_tc, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IviContainer_PR_lac:
|
||||||
|
if (!permissions_check(IVI_DIID_lac, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
} // end optional container switch
|
||||||
|
|
||||||
|
} // end optional list for
|
||||||
|
} // end optional if
|
||||||
|
|
||||||
|
if (ivim->ivi.mandatory.iviStatus == IviStatus_negation) {
|
||||||
|
if (!permissions_check(IVI_DIID_StatusNegation, ssp->choice.bitmapSsp.buf, ssp->choice.bitmapSsp.size)) {return SERVICE_INVALID;}
|
||||||
|
}
|
||||||
|
} // end parameters check
|
||||||
|
|
||||||
|
|
||||||
bool is_new = true;
|
bool is_new = true;
|
||||||
bool is_update = false;
|
bool is_update = false;
|
||||||
bool exists_vacancy = false;
|
bool exists_vacancy = false;
|
||||||
|
|
@ -314,7 +458,7 @@ static int service_update(infrastructure_t* infrastructure, enum SERVICE_TYPE ty
|
||||||
|
|
||||||
enum SERVICE_EVAL_RESULT service_eval(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, int64_t* id, ServiceSpecificPermissions_t* ssp) {
|
enum SERVICE_EVAL_RESULT service_eval(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg, int64_t* id, ServiceSpecificPermissions_t* ssp) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
switch (rv = service_check(infrastructure, type, its_msg)) {
|
switch (rv = service_check(infrastructure, type, its_msg, ssp)) {
|
||||||
case SERVICE_NEW:
|
case SERVICE_NEW:
|
||||||
syslog_debug("[facilities] [infrastructure] new service received");
|
syslog_debug("[facilities] [infrastructure] new service received");
|
||||||
if (service_add(infrastructure, type, its_msg, id)) {
|
if (service_add(infrastructure, type, its_msg, id)) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,29 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <itss-transport/ServiceSpecificPermissions.h>
|
#include <itss-transport/ServiceSpecificPermissions.h>
|
||||||
|
|
||||||
|
enum IVI_DIID_TYPE {
|
||||||
|
IVI_DIID_ViennaCodeConvention,
|
||||||
|
IVI_DIID_TrafficSignPictogramDangerWarning,
|
||||||
|
IVI_DIID_TrafficSignPictogramRegulatory,
|
||||||
|
IVI_DIID_TrafficSignPictogramInformative,
|
||||||
|
IVI_DIID_ServiceCategoryCodePublicFacilitiesPictogram,
|
||||||
|
IVI_DIID_ServiceCategoryCodeAmbientOrRoadConditionPictogramAmbientCondition,
|
||||||
|
IVI_DIID_ServiceCategoryCodeAmbientOrRoadConditionPictogramRoadCondition,
|
||||||
|
IVI_DIID_itisCodes,
|
||||||
|
IVI_DIID_laneStatus,
|
||||||
|
IVI_DIID_rcc,
|
||||||
|
IVI_DIID_tc,
|
||||||
|
IVI_DIID_lac,
|
||||||
|
IVI_DIID_StatusNegation
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct ivi_diid_ssp_bm {
|
||||||
|
const char* data_item;
|
||||||
|
const int diid;
|
||||||
|
const uint32_t bitmap_val;
|
||||||
|
} ivi_diid_ssp_bm_t;
|
||||||
|
|
||||||
|
|
||||||
enum SERVICE_STATE {
|
enum SERVICE_STATE {
|
||||||
SERVICE_ACTIVE,
|
SERVICE_ACTIVE,
|
||||||
SERVICE_CANCELLED,
|
SERVICE_CANCELLED,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue