Handle [networking] indications
This commit is contained in:
parent
bcb420990b
commit
70bb5bf9ee
|
|
@ -16,6 +16,7 @@ TARGET_LINK_LIBRARIES(it2s-itss-facilities
|
||||||
-lit2s-asn-itss-transport
|
-lit2s-asn-itss-transport
|
||||||
-lit2s-asn-itss-security
|
-lit2s-asn-itss-security
|
||||||
-lit2s-asn-itss-management
|
-lit2s-asn-itss-management
|
||||||
|
-lit2s-asn-itss-networking
|
||||||
-lzmq
|
-lzmq
|
||||||
-lpthread
|
-lpthread
|
||||||
-lit2s-config
|
-lit2s-config
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "cpm.h"
|
#include "cpm.h"
|
||||||
#include "sa.h"
|
#include "sa.h"
|
||||||
|
|
||||||
|
#include <itss-networking/NetworkingIndication.h>
|
||||||
#include <itss-transport/TransportRequest.h>
|
#include <itss-transport/TransportRequest.h>
|
||||||
#include <itss-transport/TransportIndication.h>
|
#include <itss-transport/TransportIndication.h>
|
||||||
#include <itss-facilities/FacilitiesIndication.h>
|
#include <itss-facilities/FacilitiesIndication.h>
|
||||||
|
|
@ -495,6 +496,43 @@ cleanup:
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int networking_indication(facilities_t* facilities, void* responder, uint8_t* msg, uint32_t msg_len) {
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
uint8_t code = 0;
|
||||||
|
|
||||||
|
NetworkingIndication_t* ni = calloc(1, sizeof(NetworkingIndication_t));
|
||||||
|
|
||||||
|
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_NetworkingIndication, (void**) &ni, msg, msg_len);
|
||||||
|
if (dec.code) {
|
||||||
|
rv = 1;
|
||||||
|
code = 1;
|
||||||
|
zmq_send(responder, &code, 1, 0);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
zmq_send(responder, &code, 1, 0);
|
||||||
|
|
||||||
|
if (ni->present != NetworkingIndication_PR_data) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ni->choice.data.mobileNeighbour &&
|
||||||
|
*ni->choice.data.mobileNeighbour) {
|
||||||
|
|
||||||
|
pthread_mutex_lock(&facilities->lightship->lock);
|
||||||
|
facilities->lightship->last_vehicle = it2s_tender_get_clock(&facilities->epv);
|
||||||
|
facilities->lightship->is_vehicle_near = true;
|
||||||
|
pthread_mutex_unlock(&facilities->lightship->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_NetworkingIndication, ni);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int management_indication(facilities_t* facilities, void* responder, uint8_t* msg, uint32_t msg_len) {
|
static int management_indication(facilities_t* facilities, void* responder, uint8_t* msg, uint32_t msg_len) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
|
@ -655,6 +693,10 @@ int main() {
|
||||||
rl = zmq_recv(facilities.zmq.responders[i].socket, buffer, PACKET_MAX_LEN, 0);
|
rl = zmq_recv(facilities.zmq.responders[i].socket, buffer, PACKET_MAX_LEN, 0);
|
||||||
|
|
||||||
switch (buffer[0]) {
|
switch (buffer[0]) {
|
||||||
|
case 2:
|
||||||
|
networking_indication(&facilities, facilities.zmq.responders[i].socket, buffer+1, rl);
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
in_idchange = true;
|
in_idchange = true;
|
||||||
pthread_mutex_lock(&facilities.id.change.lock);
|
pthread_mutex_lock(&facilities.id.change.lock);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue