(refid: u32, stratum: Stratum)
| 77 | } |
| 78 | |
| 79 | fn params_to_source(refid: u32, stratum: Stratum) -> ClockSource { |
| 80 | match stratum { |
| 81 | Stratum::Unspecified => { |
| 82 | // Stratum 0 - interpret as kiss codes |
| 83 | match refid { |
| 84 | v if v == u32::from_be_bytes(*b"INIT") => ClockSource::Init, |
| 85 | v if v == u32::from_be_bytes(*b"XPHC") => ClockSource::Phc, |
| 86 | v if v == u32::from_be_bytes(*b"XVMC") => ClockSource::VMClock, |
| 87 | _ => { |
| 88 | let bytes = refid.to_be_bytes(); |
| 89 | unreachable!( |
| 90 | "Unknown kiss code [{}, {}, {}, {}]; should not occur with restricted API", |
| 91 | bytes[0], bytes[1], bytes[2], bytes[3] |
| 92 | ) |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | Stratum::Level(_) => ClockSource::Server(refid), |
| 97 | Stratum::Unsynchronized => ClockSource::None, |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | fn set(&self, source: ClockSource, stratum: Stratum) { |
| 102 | let packed = (u64::from(u8::from(stratum)) << 32) | u64::from(u32::from(source)); |
nothing calls this directly
no outgoing calls
no test coverage detected