#pragma once #include #include #include #include #define MC_MAX_NEIGHBOURS 256 #define MC_RESOLUTION_TIMEOUT 500 #define MC_TRAJECTORIES_N_MAX 4 #define MC_AFF_STATIONS_N_MAX 7 #define MC_HASH_LINK_LEN 32 #define MC_SESSIONS_N_MAX 16 typedef enum MC_PROTOCOL { MC_PROTOCOL_VCM_RR, MC_PROTOCOL_VCM_RR1C, MC_PROTOCOL_VCM_RRAC } MC_PROTOCOL_e; typedef struct mc_neighbour { uint32_t station_id; uint16_t length; uint16_t width; struct { uint32_t nonce; bool requested; bool replied; bool committed; } session; itss_st_t trajectory[TRAJECTORY_MAX_LEN + 1]; uint8_t trajectory_len; bool intersecting; uint64_t t_iid; /* timestamp of initial intersection detection */ bool proposed; } mc_neighbour_s; typedef struct coordination { bool active; MC_PROTOCOL_e protocol; pthread_mutex_t lock; uint64_t t_last_send_vcm; /* timestamp of last sent (basic) VCM */ uint64_t vcm_period_min; uint64_t vcm_period_max; struct { VCM_t* own_req; /* last VCM.request sent */ uint64_t ts; uint32_t nonce; uint64_t t_init; /* timestamp of request rx */ mc_neighbour_s* requester; mc_neighbour_s* affs[MC_TRAJECTORIES_N_MAX][MC_AFF_STATIONS_N_MAX]; /* trjs over affected stations */ uint8_t n_affs_trjs; uint8_t n_affs_neighs[MC_TRAJECTORIES_N_MAX]; uint8_t n_affs_neighs_reqd; } session; void* mgmt_socket; mc_neighbour_s neighbours[MC_MAX_NEIGHBOURS]; uint16_t neighbours_len; struct { bool enabled; uint64_t id; uint8_t links[MC_AFF_STATIONS_N_MAX + 1][MC_HASH_LINK_LEN]; uint8_t n_links; itss_region_t region; } chain; } coordination_t; /** * Analyses a VCM * @param vcm The VCM to be analyzed * @return 0 on success, other value otherwise */ int vcm_check(VCM_t* vcm); /** * VC loop, threaded * @return NULL */ void* vc_service(); /** * Initializes the main VC struct * @return Nothing */ void coordination_init();