Skip to content

Commit

Permalink
Introduce new ZInfoNTPSource message in proto/info/ntpsource.proto
Browse files Browse the repository at this point in the history
This will be published from EVE.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
  • Loading branch information
rouming committed Jun 6, 2024
1 parent 77df971 commit 364f801
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions proto/info/info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "google/protobuf/timestamp.proto";
import "evecommon/devmodelcommon.proto";
import "evecommon/evecommon.proto";
import "info/patch_envelope.proto";
import "info/ntpsources.proto";

// Deprecated: see deprecatedMetricItem below
enum DepMetricItemType {
Expand Down Expand Up @@ -67,6 +68,7 @@ enum ZInfoTypes {
ZiEdgeview = 12;
ZiLocation = 13;
ZiPatchEnvelope = 14;
ZiNTPSources = 16;
}

// Information about assignable I/O adapter bundles
Expand Down Expand Up @@ -1181,6 +1183,7 @@ message ZInfoMsg {
ZInfoPatchEnvelope patchInfo = 20;
// 21 reserved
ZInfoClusterNode cluster_node = 22;
ZInfoNTPSources ntp_sources = 23;
}
google.protobuf.Timestamp atTimeStamp = 6;
}
Expand Down
74 changes: 74 additions & 0 deletions proto/info/ntpsources.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright(c) 2024 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

import "google/protobuf/timestamp.proto";

package org.lfedge.eve.info;
option go_package = "github.com/lf-edge/eve-api/go/info";

option java_package = "org.lfedge.eve.info";

// Enum for describing the NTP source state
enum NTPSourceState {
NTP_SOURCE_STATE_SYNC = 0;
NTP_SOURCE_STATE_UNREACH = 1;
NTP_SOURCE_STATE_FALSETICKER = 2;
NTP_SOURCE_STATE_JITTERY = 3;
NTP_SOURCE_STATE_CANDIDATE = 4;
NTP_SOURCE_STATE_OUTLIER = 5;
}

// Enum for describing the NTP source mode
enum NTPSourceMode {
NTP_SOURCE_MODE_CLIENT = 0;
NTP_SOURCE_MODE_PEER = 1; // ntp
NTP_SOURCE_MODE_REF = 2; // local
}

// Flags from RFC 5905 + defined by chrony
enum NTPSourceBitmap {
NTP_SOURCE_BITMAP_UNSPECIFIED = 0x0000;
NTP_SOURCE_BITMAP_PKT_DUP = 0x0001;
NTP_SOURCE_BITMAP_PKT_BOGUS = 0x0002;
NTP_SOURCE_BITMAP_PKT_INVALID = 0x0004;
NTP_SOURCE_BITMAP_PKT_AUTH = 0x0008;
NTP_SOURCE_BITMAP_PKT_STRATUM = 0x0010;
NTP_SOURCE_BITMAP_PKT_HEADER = 0x0020;
NTP_SOURCE_BITMAP_TST_MAX_DELAY = 0x0040;
NTP_SOURCE_BITMAP_TST_DELAY_RATIO = 0x0080;
NTP_SOURCE_BITMAP_TST_DELAY_DEV_RATION = 0x0100;
NTP_SOURCE_BITMAP_TST_SYNC_LOOP = 0x0200;
}

// As described in http://doc.ntp.org/current-stable/ntpq.html
message NTPSource {
bool authenticated = 1;
bool reachable = 2; // (reachability == 0xff), i.e. 8 attempts
uint32 reachability = 3;
NTPSourceState state = 4;
NTPSourceMode mode = 5;
string hostname = 6;
string src_addr = 7;
uint32 src_port = 8;
string dst_addr = 9;
uint32 dst_port = 10;
uint32 leap = 11;
uint32 stratum = 12;
uint32 precision = 13;
string ref_id = 14;
google.protobuf.Timestamp ref_time = 15;
sint32 poll = 16;
uint32 flags = 17; // bitmap from NTPSourceBitmap
double offset = 18;
double delay = 19;
double dispersion = 20;
double jitter = 21;
double root_delay = 22;
double root_disp = 23;
}

message ZInfoNTPSources {
repeated NTPSource sources = 1;
}

0 comments on commit 364f801

Please sign in to comment.