SAEM forwarding, documentation
This commit is contained in:
parent
e497628e7d
commit
5bd3925504
|
|
@ -140,6 +140,9 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
|||
ssp_len = tpi->choice.btp.gn.securityPermissions->ssp.size;
|
||||
}
|
||||
|
||||
// Get neighbour certificate ID
|
||||
uint8_t* neighbour_cert = tpi->choice.btp.gn.securityNeighbour ? tpi->choice.btp.gn.securityNeighbour->buf : NULL;
|
||||
|
||||
// Manage message
|
||||
switch (tpi->choice.btp.destinationPort) {
|
||||
case Port_cam:
|
||||
|
|
@ -198,20 +201,17 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
|||
break;
|
||||
|
||||
case Port_saem:
|
||||
saem_check(
|
||||
facilities,
|
||||
&facilities->bulletin,
|
||||
its_msg,
|
||||
tpi->choice.btp.gn.securityNeighbour ? tpi->choice.btp.gn.securityNeighbour->buf : NULL
|
||||
);
|
||||
switch (saem_check(facilities, &facilities->bulletin, its_msg, neighbour_cert)) {
|
||||
case SAEM_NEW:
|
||||
fwd = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 7011:
|
||||
tpm_recv(
|
||||
facilities,
|
||||
its_msg,
|
||||
tpi->choice.btp.gn.securityNeighbour ? tpi->choice.btp.gn.securityNeighbour->buf : NULL
|
||||
);
|
||||
tpm_recv(facilities, its_msg, neighbour_cert);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
#include "mcm.h"
|
||||
#include "facilities.h"
|
||||
|
||||
|
||||
void* mc_service(void* fc) {
|
||||
|
||||
facilities_t* facilities = (facilities_t*) fc;
|
||||
|
||||
while (!facilities->exit) {
|
||||
|
||||
usleep(50*1000);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@ SAEM_CODE_R saem_check(void* fc, bulletin_t* bulletin, SAEM_t* saem, uint8_t* ne
|
|||
}
|
||||
|
||||
if (index == -1) {
|
||||
rv = SAEM_NEW;
|
||||
if (bulletin->to_consume_len + 1 < MAX_ANNOUNCEMENTS_LEN) {
|
||||
bulletin->to_consume[bulletin->to_consume_len]->its_aid = its_aid;
|
||||
bulletin->to_consume[bulletin->to_consume_len]->station_id = saem->header.stationID;
|
||||
|
|
@ -134,7 +135,7 @@ SAEM_CODE_R saem_check(void* fc, bulletin_t* bulletin, SAEM_t* saem, uint8_t* ne
|
|||
|
||||
pthread_mutex_unlock(&bulletin->lock);
|
||||
|
||||
return rv;
|
||||
return rv == SAEM_NEW ? SAEM_NEW : SAEM_OK;
|
||||
}
|
||||
|
||||
void bulletin_init(bulletin_t* bulletin) {
|
||||
|
|
@ -206,7 +207,7 @@ int mk_saem(facilities_t* facilities, uint8_t* b_saem, uint32_t* b_saem_len) {
|
|||
exts->list.array[2]->present = ServiceInfoExt_PR_applicationDataSAM;
|
||||
exts->list.array[2]->choice.applicationDataSAM.buf = malloc(1024);
|
||||
|
||||
enc = uper_encode_to_buffer(&asn_DEF_TollingPaymentInfo, NULL, facilities->tolling.infos.z[0], exts->list.array[2]->choice.applicationDataSAM.buf, 1024);
|
||||
enc = uper_encode_to_buffer(&asn_DEF_TollingPaymentInfo, NULL, facilities->tolling.infos.z[0]->asn, exts->list.array[2]->choice.applicationDataSAM.buf, 1024);
|
||||
if (enc.encoded == -1) {
|
||||
syslog_err("[facilities] [sa] failure to encode TollingPaymentInfo (%s)", enc.failed_type->name);
|
||||
rv = 1;
|
||||
|
|
|
|||
22
src/saem.h
22
src/saem.h
|
|
@ -43,12 +43,34 @@ typedef struct bulletin {
|
|||
|
||||
typedef enum SAEM_CODE {
|
||||
SAEM_OK,
|
||||
SAEM_NEW,
|
||||
SAEM_INVALID_HEADER_MESSAGE_ID,
|
||||
SAEM_INVALID_HEADER_VERSION
|
||||
} SAEM_CODE_R;
|
||||
|
||||
/**
|
||||
* Initiaties bulletin, the main SA structure
|
||||
*
|
||||
* @param bulletin The structure to initialize
|
||||
* @return Nothing
|
||||
*/
|
||||
void bulletin_init(bulletin_t* bulletin);
|
||||
|
||||
/**
|
||||
* Checks SAEM, saves advertisements
|
||||
*
|
||||
* @param fc The main facilities structure
|
||||
* @param bulletin The main SA structure
|
||||
* @param saem The SAEM message to check
|
||||
* @param neighbour The certificate used by the neighbour, for encryption
|
||||
* @return SAEM_CODE
|
||||
*/
|
||||
SAEM_CODE_R saem_check(void* fc, bulletin_t* bulletin, SAEM_t* saem, uint8_t* neighbour);
|
||||
|
||||
/**
|
||||
* The main SA function, run as a thread
|
||||
*
|
||||
* @param The main facilities structure
|
||||
* @return NULL
|
||||
*/
|
||||
void* sa_service(void* fc);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,16 @@ typedef struct tolling {
|
|||
|
||||
} tolling_s;
|
||||
|
||||
/**
|
||||
* Initializes the main tolling struture
|
||||
*
|
||||
* @param tolling The structure to initialize
|
||||
* @param zmq_ctx The facilities ZMQ context
|
||||
* @param security_address The security service ZMQ address
|
||||
* @return Always successful
|
||||
*/
|
||||
int tolling_init(tolling_s* tolling, void* zmq_ctx, char* security_address);
|
||||
|
||||
int tpm_pay(void* fc, uint8_t* neighbour);
|
||||
int tpm_recv(void* fc, TPM_t* tpm_rx, uint8_t* neighbour);
|
||||
int tpm_is_inside_zone(void* fc, tolling_info_s* ti);
|
||||
|
|
|
|||
Loading…
Reference in New Issue