clock_source_private_data clocks_private[MAX_CLOCKS];
client_record clients[MAX_CLIENTS];
-int find_client_id(char *client_shared_memory_interface_name) {
- int response = -1; // signify not found
- if (client_shared_memory_interface_name != NULL) {
- int i = 0;
- // first, see if yu can find it anywhere
- while ((response == -1) && (i < MAX_CLIENTS)) {
- if (strcmp(clients[i].shm_interface_name, client_shared_memory_interface_name) == 0)
- response = i;
- else
- i++;
- }
- }
- return response;
-}
-
const char *get_client_name(int client_id) {
if ((client_id >= 0) && (client_id < MAX_CLIENTS)) {
return clients[client_id].shm_interface_name;
else
i++;
}
-
+
if (response == -1) { // no match, so create one
i = 0;
while ((response == -1) && (i < MAX_CLIENTS)) {
int err;
strncpy(clients[i].shm_interface_name, client_shared_memory_interface_name,
sizeof(clients[i].shm_interface_name));
- // creat the named smi interface
+ // create the named smi interface
// open a shared memory interface.
+ debug(2, "Create a shm interface named \"%s\"", clients[i].shm_interface_name);
clients[i].shm_fd = -1;
mode_t oldumask = umask(0);
} else {
debug(1, "no client_shared_memory_interface_name");
}
+ debug(2, "get_client_id \"%s\" response %d", client_shared_memory_interface_name, response);
return response;
}
void manage_clock_sources(uint64_t reception_time, clock_source_private_data *clocks_private_info);
-int find_client_id(char *client_shared_memory_interface_name);
int get_client_id(char *client_shared_memory_interface_name);
const char *get_client_name(int client_id);
int delete_client(int client_id);
clock_source_private_data *clock_private_info) {
if (recv_len != -1) {
buf[recv_len - 1] = 0; // make sure there's a null in it!
- debug(1, "New control port message: \"%s\".", buf);
+ debug(2, "New control port message: \"%s\".", buf);
// we need to get the client shared memory interface name from the front
char *ip_list = buf;
char *smi_name = strsep(&ip_list, " ");
command = strsep(&ip_list, " ");
if ((command == NULL) || ((strcmp(command, "T") == 0) && (ip_list == NULL))) {
// clear all the flags, but only if the client exists
- client_id = find_client_id(smi_name); // don't create a record
+ client_id = get_client_id(smi_name); // create the record if it doesn't exist
if (client_id != -1) {
// turn off all is_timing_peer flags
int i;
}
}
} else {
+ debug(2,"get or create new record for \"%s\".",smi_name);
client_id = get_client_id(smi_name); // create the record if it doesn't exist
if (client_id != -1) {
if (strcmp(command, "T") == 0) {
[Unit]
+Provides=nqptp.service
Description=NQPTP -- Not Quite PTP
Wants=network-online.target
After=network.target network-online.target