if (old_master != -1) {
// but there was a master clock, so remove it
debug(1,"shm interface -- remove master clock designation");
- update_master_clock_info(0, 0, 0);
+ update_master_clock_info(0, NULL, 0, 0);
}
if (timing_peer_count == 0)
debug(2, "No timing peer list found");
// master_clock_index = best_so_far;
if (old_master != best_so_far) {
update_master_clock_info(clocks_private[best_so_far].clock_id,
+ &clocks_private[best_so_far].ip,
clocks_private[best_so_far].local_time,
clocks_private[best_so_far].local_to_source_time_offset);
}
if (old_flags != clock_private_info->flags) {
update_master();
} else if ((clock_private_info->flags & (1 << clock_is_master)) != 0) {
- update_master_clock_info(clock_private_info->clock_id, clock_private_info->local_time,
+ update_master_clock_info(clock_private_info->clock_id,
+ &clock_private_info->ip,
+ clock_private_info->local_time,
clock_private_info->local_to_source_time_offset);
}
#define STORAGE_ID "/nqptp"
#define MAX_CLOCKS 32
-#define NQPTP_SHM_STRUCTURES_VERSION 3
+#define NQPTP_SHM_STRUCTURES_VERSION 4
#define NQPTP_CONTROL_PORT 9000
// the control port will accept a UDP packet with the first letter being:
uint16_t version; // check this is equal to NQPTP_SHM_STRUCTURES_VERSION
uint32_t flags; // unused
uint64_t master_clock_id; // the current master clock
+ char master_clock_ip[64]; // where it's coming from
uint64_t local_time; // the time when the offset was calculated
uint64_t local_to_master_time_offset; // add this to the local time to get master clock time
};
#include <signal.h>
#include <sys/epoll.h>
+#ifndef FIELD_SIZEOF
+#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->f))
+#endif
+
// 8 samples per second
#define BUFLEN 4096 // Max length of buffer
struct shm_structure *shared_memory = NULL; // this is where public clock info is available
int epoll_fd;
-void update_master_clock_info(uint64_t master_clock_id, uint64_t local_time,
+void update_master_clock_info(uint64_t master_clock_id, const char *ip, uint64_t local_time,
uint64_t local_to_master_offset) {
if (shared_memory->master_clock_id != master_clock_id)
debug(1, "Master clock is: %" PRIx64 ".", master_clock_id);
if (rc != 0)
warn("Can't acquire mutex to update master clock!");
shared_memory->master_clock_id = master_clock_id;
+ if (ip != NULL)
+ strncpy((char *)&shared_memory->master_clock_ip, ip, FIELD_SIZEOF(struct shm_structure, master_clock_ip) - 1);
+ else
+ shared_memory->master_clock_ip[0] = '\0';
shared_memory->local_time = local_time;
shared_memory->local_to_master_time_offset = local_to_master_offset;
rc = pthread_mutex_unlock(&shared_memory->shm_mutex);
extern int master_clock_index;
extern struct shm_structure *shared_memory;
-void update_master_clock_info(uint64_t master_clock_id, uint64_t local_time,
+void update_master_clock_info(uint64_t master_clock_id, const char *ip, uint64_t local_time,
uint64_t local_to_master_offset);
#endif
\ No newline at end of file