fn build_response_header()

in clock-bound-d/src/response.rs [181:200]


fn build_response_header(mut request_type: u8, sync_flag: u8) -> Vec<u8> {
    let mut response: Vec<u8> = Vec::with_capacity(4);
    // Send back the response version of ClockBoundD
    response.push(RESPONSE_VERSION);

    // If the request type is not a valid type then set it to Error (0)
    let request_types: [u8; 4] = [0, 1, 2, 3];
    if !request_types.contains(&request_type) {
        request_type = ERROR_RESPONSE;
    }

    // Send back the request type. Will be set to Error (0) if an error occurred.
    response.push(request_type);
    // Set the sync flag based on the Chrony tracking information
    response.push(sync_flag);
    // 4th byte is currently reserved
    let reserved: u8 = 0;
    response.push(reserved);
    response
}