~nickbp/kapiti

225b392499906ac40f7b6b41335ace99ec0cbd12 — Nick Parker 4 years ago 7d4d4b5
#21 Clean up OPT option handling for eventual cookie support
M examples/update_fbs.rs => examples/update_fbs.rs +5 -5
@@ 159,7 159,7 @@ fn generate_enums_fbs(
            "ResourceType" => generate_resourcetype_enum(enum_csv_path)?,
            "OpCode" => generate_opcode_enum(enum_csv_path)?,
            "ResponseCode" => generate_responsecode_enum(enum_csv_path)?,
            "OPTResponseCode" => generate_optresponsecode_enum(enum_csv_path)?,
            "OPTOptionCode" => generate_optoptioncode_enum(enum_csv_path)?,
            &_ => panic!("Unsupported enum: {}", section.EnumName),
        };



@@ 519,20 519,20 @@ fn generate_responsecode_enum(enum_csv_path: PathBuf) -> Result<Vec<EnumEntry>, 
// RCODE,Name,Description,Reference
#[allow(non_snake_case)]
#[derive(serde::Deserialize)]
struct OPTResponseCodeRecord {
struct OPTOptionCodeRecord {
    Value: String,
    Name: String,
    Status: String,
    Reference: String,
}

fn generate_optresponsecode_enum(enum_csv_path: PathBuf) -> Result<Vec<EnumEntry>, io::Error> {
fn generate_optoptioncode_enum(enum_csv_path: PathBuf) -> Result<Vec<EnumEntry>, io::Error> {
    let mut entries = Vec::new();
    for record in csv::Reader::from_path(&enum_csv_path)
        .expect(format!("opening {:?}", enum_csv_path).as_str())
        .deserialize()
    {
        let record: OPTResponseCodeRecord =
        let record: OPTOptionCodeRecord =
            record.expect(format!("reading/deserializing from {:?}", enum_csv_path).as_str());
        let ignored = record.Value.contains('-') || record.Name == "Unassigned";



@@ 575,7 575,7 @@ fn generate_optresponsecode_enum(enum_csv_path: PathBuf) -> Result<Vec<EnumEntry
                doc: !ignored,
                comment1: comment1,
                comment2: None,
                name: Some(format!("OPTRESPONSE_{}", name)),
                name: Some(format!("OPTOPTION_{}", name)),
                intval: Some(record.Value),
            });
        }

M fbs/dns_enums.fbs => fbs/dns_enums.fbs +20 -20
@@ 432,67 432,67 @@ enum ResponseCode : uint16 {

}

enum OPTResponseCode : uint16 {
enum OPTOptionCode : uint16 {

  /// Reserved [RFC6891]
  OPTRESPONSE_NONE = 0,
  OPTOPTION_NONE = 0,

  /// LLQ: Optional [RFC-sekar-dns-llq-06]
  OPTRESPONSE_LLQ = 1,
  OPTOPTION_LLQ = 1,

  /// UL: On-hold [http://files.dns-sd.org/draft-sekar-dns-ul.txt]
  OPTRESPONSE_UL = 2,
  OPTOPTION_UL = 2,

  /// NSID: Standard [RFC5001]
  OPTRESPONSE_NSID = 3,
  OPTOPTION_NSID = 3,

  /// Reserved [draft-cheshire-edns0-owner-option]
  OPTRESPONSE_RESERVED_4 = 4,
  OPTOPTION_RESERVED_4 = 4,

  /// DAU: Standard [RFC6975]
  OPTRESPONSE_DAU = 5,
  OPTOPTION_DAU = 5,

  /// DHU: Standard [RFC6975]
  OPTRESPONSE_DHU = 6,
  OPTOPTION_DHU = 6,

  /// N3U: Standard [RFC6975]
  OPTRESPONSE_N3U = 7,
  OPTOPTION_N3U = 7,

  /// edns-client-subnet: Optional [RFC7871]
  OPTRESPONSE_EDNS_CLIENT_SUBNET = 8,
  OPTOPTION_EDNS_CLIENT_SUBNET = 8,

  /// EDNS EXPIRE: Optional [RFC7314]
  OPTRESPONSE_EDNS_EXPIRE = 9,
  OPTOPTION_EDNS_EXPIRE = 9,

  /// COOKIE: Standard [RFC7873]
  OPTRESPONSE_COOKIE = 10,
  OPTOPTION_COOKIE = 10,

  /// edns-tcp-keepalive: Standard [RFC7828]
  OPTRESPONSE_EDNS_TCP_KEEPALIVE = 11,
  OPTOPTION_EDNS_TCP_KEEPALIVE = 11,

  /// Padding: Standard [RFC7830]
  OPTRESPONSE_PADDING = 12,
  OPTOPTION_PADDING = 12,

  /// CHAIN: Standard [RFC7901]
  OPTRESPONSE_CHAIN = 13,
  OPTOPTION_CHAIN = 13,

  /// edns-key-tag: Optional [RFC8145]
  OPTRESPONSE_EDNS_KEY_TAG = 14,
  OPTOPTION_EDNS_KEY_TAG = 14,

  // Unassigned
  // 15

  /// EDNS-Client-Tag: Optional [draft-bellis-dnsop-edns-tags]
  OPTRESPONSE_EDNS_CLIENT_TAG = 16,
  OPTOPTION_EDNS_CLIENT_TAG = 16,

  /// EDNS-Server-Tag: Optional [draft-bellis-dnsop-edns-tags]
  OPTRESPONSE_EDNS_SERVER_TAG = 17,
  OPTOPTION_EDNS_SERVER_TAG = 17,

  // Unassigned
  // 18-26945

  /// DeviceID: Optional [https://docs.umbrella.com/developer/networkdevices-api/identifying-dns-traffic2][Brian_Hartvigsen]
  OPTRESPONSE_DEVICEID = 26946,
  OPTOPTION_DEVICEID = 26946,

  // Unassigned
  // 26947-65000


@@ 501,6 501,6 @@ enum OPTResponseCode : uint16 {
  // 65001-65534

  /// Reserved for future expansion [RFC6891]
  OPTRESPONSE_RESERVED_FOR_FUTURE_EXPANSION = 65535,
  OPTOPTION_RESERVED_FOR_FUTURE_EXPANSION = 65535,

}

M fbs/enum-specs/sections.csv => fbs/enum-specs/sections.csv +1 -1
@@ 3,4 3,4 @@ dns-parameters-2.csv,ResourceClass,uint16
dns-parameters-4.csv,ResourceType,uint16
dns-parameters-5.csv,OpCode,uint8
dns-parameters-6.csv,ResponseCode,uint16
dns-parameters-11.csv,OPTResponseCode,uint16
dns-parameters-11.csv,OPTOptionCode,uint16

M src/codec/display.rs => src/codec/display.rs +7 -12
@@ 66,11 66,7 @@ impl fmt::Display for Header<'_> {

impl fmt::Display for OPT<'_> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "udp_size={} response_code=", self.udp_size())?;
        match dns_enums_conv::optresponsecode_int(self.response_code() as usize) {
            Some(response_code) => write!(f, "{:?}", response_code)?,
            None => write!(f, "{}", self.response_code())?,
        }
        write!(f, "udp_size={} response_code={}", self.udp_size(), self.response_code())?;
        write!(
            f,
            " version={} dnssec_ok={} option=[",


@@ 80,13 76,12 @@ impl fmt::Display for OPT<'_> {
        if let Some(entries) = self.option() {
            for i in 0..entries.len() {
                let entry = entries.get(i);
                write!(
                    f,
                    " {}=(code={} data={:02X?})",
                    i,
                    entry.code(),
                    entry.data()
                )?;
                write!(f, " {}=(code=", i)?;
                match dns_enums_conv::optoptioncode_int(entry.code() as usize) {
                    Some(code) => write!(f, "{:?}", code)?,
                    None => write!(f, "{}", entry.code())?,
                }
                write!(f, " data={:02X?})", entry.data())?;
            }
        }
        write!(f, " ]")?;

M src/codec/mod.rs => src/codec/mod.rs +1 -0
@@ 18,4 18,5 @@ pub mod character_string;
pub mod domain_name;

pub mod message;

mod rdata;

M src/codec/rdata.rs => src/codec/rdata.rs +2 -2
@@ 12,7 12,7 @@ use crate::codec::{character_string, domain_name, message};
use crate::fbs::dns_enums_conv;
use crate::fbs::dns_enums_generated::ResourceType;
use crate::fbs::dns_message_generated::{
    rdata, OPTArgs, OPTOption, OPTOptionArgs, ResourceData, ResourceDataArgs, OPT,
    rdata, OPT, OPTArgs, OPTOption, OPTOptionArgs, ResourceData, ResourceDataArgs,
};

macro_rules! io_err {


@@ 1163,7 1163,7 @@ pub fn read_opt<'a>(
            );
        }

        // TODO(#1) support parsing the 'COOKIE' OPT option
        // TODO(#21) support parsing the 'COOKIE' OPT option
        let args = OPTOptionArgs {
            code: bits.code,
            data: Some(fb_builder.create_vector(

M src/fbs/dns_enums_conv.rs => src/fbs/dns_enums_conv.rs +40 -40
@@ 294,52 294,52 @@ pub fn responsecode_int(i: usize) -> Option<dns_enums_generated::ResponseCode> {
    }
}

pub fn optresponsecode_str(s: String) -> Option<dns_enums_generated::OPTResponseCode> {
pub fn optoptioncode_str(s: String) -> Option<dns_enums_generated::OPTOptionCode> {
    match s.as_str() {
        "OPTRESPONSE_NONE" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_NONE),
        "OPTRESPONSE_LLQ" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_LLQ),
        "OPTRESPONSE_UL" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_UL),
        "OPTRESPONSE_NSID" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_NSID),
        "OPTRESPONSE_RESERVED_4" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_RESERVED_4),
        "OPTRESPONSE_DAU" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_DAU),
        "OPTRESPONSE_DHU" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_DHU),
        "OPTRESPONSE_N3U" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_N3U),
        "OPTRESPONSE_EDNS_CLIENT_SUBNET" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_CLIENT_SUBNET),
        "OPTRESPONSE_EDNS_EXPIRE" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_EXPIRE),
        "OPTRESPONSE_COOKIE" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_COOKIE),
        "OPTRESPONSE_EDNS_TCP_KEEPALIVE" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_TCP_KEEPALIVE),
        "OPTRESPONSE_PADDING" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_PADDING),
        "OPTRESPONSE_CHAIN" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_CHAIN),
        "OPTRESPONSE_EDNS_KEY_TAG" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_KEY_TAG),
        "OPTRESPONSE_EDNS_CLIENT_TAG" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_CLIENT_TAG),
        "OPTRESPONSE_EDNS_SERVER_TAG" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_SERVER_TAG),
        "OPTRESPONSE_DEVICEID" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_DEVICEID),
        "OPTRESPONSE_RESERVED_FOR_FUTURE_EXPANSION" => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_RESERVED_FOR_FUTURE_EXPANSION),
        "OPTOPTION_NONE" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_NONE),
        "OPTOPTION_LLQ" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_LLQ),
        "OPTOPTION_UL" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_UL),
        "OPTOPTION_NSID" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_NSID),
        "OPTOPTION_RESERVED_4" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_RESERVED_4),
        "OPTOPTION_DAU" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_DAU),
        "OPTOPTION_DHU" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_DHU),
        "OPTOPTION_N3U" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_N3U),
        "OPTOPTION_EDNS_CLIENT_SUBNET" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_CLIENT_SUBNET),
        "OPTOPTION_EDNS_EXPIRE" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_EXPIRE),
        "OPTOPTION_COOKIE" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_COOKIE),
        "OPTOPTION_EDNS_TCP_KEEPALIVE" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_TCP_KEEPALIVE),
        "OPTOPTION_PADDING" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_PADDING),
        "OPTOPTION_CHAIN" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_CHAIN),
        "OPTOPTION_EDNS_KEY_TAG" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_KEY_TAG),
        "OPTOPTION_EDNS_CLIENT_TAG" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_CLIENT_TAG),
        "OPTOPTION_EDNS_SERVER_TAG" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_SERVER_TAG),
        "OPTOPTION_DEVICEID" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_DEVICEID),
        "OPTOPTION_RESERVED_FOR_FUTURE_EXPANSION" => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_RESERVED_FOR_FUTURE_EXPANSION),
        _ => None
    }
}

pub fn optresponsecode_int(i: usize) -> Option<dns_enums_generated::OPTResponseCode> {
pub fn optoptioncode_int(i: usize) -> Option<dns_enums_generated::OPTOptionCode> {
    match i {
        0 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_NONE),
        1 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_LLQ),
        2 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_UL),
        3 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_NSID),
        4 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_RESERVED_4),
        5 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_DAU),
        6 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_DHU),
        7 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_N3U),
        8 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_CLIENT_SUBNET),
        9 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_EXPIRE),
        10 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_COOKIE),
        11 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_TCP_KEEPALIVE),
        12 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_PADDING),
        13 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_CHAIN),
        14 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_KEY_TAG),
        16 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_CLIENT_TAG),
        17 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_EDNS_SERVER_TAG),
        26946 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_DEVICEID),
        65535 => Some(dns_enums_generated::OPTResponseCode::OPTRESPONSE_RESERVED_FOR_FUTURE_EXPANSION),
        0 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_NONE),
        1 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_LLQ),
        2 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_UL),
        3 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_NSID),
        4 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_RESERVED_4),
        5 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_DAU),
        6 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_DHU),
        7 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_N3U),
        8 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_CLIENT_SUBNET),
        9 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_EXPIRE),
        10 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_COOKIE),
        11 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_TCP_KEEPALIVE),
        12 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_PADDING),
        13 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_CHAIN),
        14 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_KEY_TAG),
        16 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_CLIENT_TAG),
        17 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_EDNS_SERVER_TAG),
        26946 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_DEVICEID),
        65535 => Some(dns_enums_generated::OPTOptionCode::OPTOPTION_RESERVED_FOR_FUTURE_EXPANSION),
        _ => None
    }
}

M src/fbs/dns_enums_generated.rs => src/fbs/dns_enums_generated.rs +49 -49
@@ 575,52 575,52 @@ const ENUM_VALUES_RESPONSE_CODE:[ResponseCode; 21] = [
#[allow(non_camel_case_types)]
#[repr(u16)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum OPTResponseCode {
pub enum OPTOptionCode {
  /// Reserved [RFC6891]
  OPTRESPONSE_NONE = 0,
  OPTOPTION_NONE = 0,
  /// LLQ: Optional [RFC-sekar-dns-llq-06]
  OPTRESPONSE_LLQ = 1,
  OPTOPTION_LLQ = 1,
  /// UL: On-hold [http://files.dns-sd.org/draft-sekar-dns-ul.txt]
  OPTRESPONSE_UL = 2,
  OPTOPTION_UL = 2,
  /// NSID: Standard [RFC5001]
  OPTRESPONSE_NSID = 3,
  OPTOPTION_NSID = 3,
  /// Reserved [draft-cheshire-edns0-owner-option]
  OPTRESPONSE_RESERVED_4 = 4,
  OPTOPTION_RESERVED_4 = 4,
  /// DAU: Standard [RFC6975]
  OPTRESPONSE_DAU = 5,
  OPTOPTION_DAU = 5,
  /// DHU: Standard [RFC6975]
  OPTRESPONSE_DHU = 6,
  OPTOPTION_DHU = 6,
  /// N3U: Standard [RFC6975]
  OPTRESPONSE_N3U = 7,
  OPTOPTION_N3U = 7,
  /// edns-client-subnet: Optional [RFC7871]
  OPTRESPONSE_EDNS_CLIENT_SUBNET = 8,
  OPTOPTION_EDNS_CLIENT_SUBNET = 8,
  /// EDNS EXPIRE: Optional [RFC7314]
  OPTRESPONSE_EDNS_EXPIRE = 9,
  OPTOPTION_EDNS_EXPIRE = 9,
  /// COOKIE: Standard [RFC7873]
  OPTRESPONSE_COOKIE = 10,
  OPTOPTION_COOKIE = 10,
  /// edns-tcp-keepalive: Standard [RFC7828]
  OPTRESPONSE_EDNS_TCP_KEEPALIVE = 11,
  OPTOPTION_EDNS_TCP_KEEPALIVE = 11,
  /// Padding: Standard [RFC7830]
  OPTRESPONSE_PADDING = 12,
  OPTOPTION_PADDING = 12,
  /// CHAIN: Standard [RFC7901]
  OPTRESPONSE_CHAIN = 13,
  OPTOPTION_CHAIN = 13,
  /// edns-key-tag: Optional [RFC8145]
  OPTRESPONSE_EDNS_KEY_TAG = 14,
  OPTOPTION_EDNS_KEY_TAG = 14,
  /// EDNS-Client-Tag: Optional [draft-bellis-dnsop-edns-tags]
  OPTRESPONSE_EDNS_CLIENT_TAG = 16,
  OPTOPTION_EDNS_CLIENT_TAG = 16,
  /// EDNS-Server-Tag: Optional [draft-bellis-dnsop-edns-tags]
  OPTRESPONSE_EDNS_SERVER_TAG = 17,
  OPTOPTION_EDNS_SERVER_TAG = 17,
  /// DeviceID: Optional [https://docs.umbrella.com/developer/networkdevices-api/identifying-dns-traffic2][Brian_Hartvigsen]
  OPTRESPONSE_DEVICEID = 26946,
  OPTOPTION_DEVICEID = 26946,
  /// Reserved for future expansion [RFC6891]
  OPTRESPONSE_RESERVED_FOR_FUTURE_EXPANSION = 65535,
  OPTOPTION_RESERVED_FOR_FUTURE_EXPANSION = 65535,

}

const ENUM_MIN_OPTRESPONSE_CODE: u16 = 0;
const ENUM_MAX_OPTRESPONSE_CODE: u16 = 65535;
const ENUM_MIN_OPTOPTION_CODE: u16 = 0;
const ENUM_MAX_OPTOPTION_CODE: u16 = 65535;

impl<'a> flatbuffers::Follow<'a> for OPTResponseCode {
impl<'a> flatbuffers::Follow<'a> for OPTOptionCode {
  type Inner = Self;
  #[inline]
  fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {


@@ 628,49 628,49 @@ impl<'a> flatbuffers::Follow<'a> for OPTResponseCode {
  }
}

impl flatbuffers::EndianScalar for OPTResponseCode {
impl flatbuffers::EndianScalar for OPTOptionCode {
  #[inline]
  fn to_little_endian(self) -> Self {
    let n = u16::to_le(self as u16);
    let p = &n as *const u16 as *const OPTResponseCode;
    let p = &n as *const u16 as *const OPTOptionCode;
    unsafe { *p }
  }
  #[inline]
  fn from_little_endian(self) -> Self {
    let n = u16::from_le(self as u16);
    let p = &n as *const u16 as *const OPTResponseCode;
    let p = &n as *const u16 as *const OPTOptionCode;
    unsafe { *p }
  }
}

impl flatbuffers::Push for OPTResponseCode {
    type Output = OPTResponseCode;
impl flatbuffers::Push for OPTOptionCode {
    type Output = OPTOptionCode;
    #[inline]
    fn push(&self, dst: &mut [u8], _rest: &[u8]) {
        flatbuffers::emplace_scalar::<OPTResponseCode>(dst, *self);
        flatbuffers::emplace_scalar::<OPTOptionCode>(dst, *self);
    }
}

#[allow(non_camel_case_types)]
const ENUM_VALUES_OPTRESPONSE_CODE:[OPTResponseCode; 19] = [
  OPTResponseCode::OPTRESPONSE_NONE,
  OPTResponseCode::OPTRESPONSE_LLQ,
  OPTResponseCode::OPTRESPONSE_UL,
  OPTResponseCode::OPTRESPONSE_NSID,
  OPTResponseCode::OPTRESPONSE_RESERVED_4,
  OPTResponseCode::OPTRESPONSE_DAU,
  OPTResponseCode::OPTRESPONSE_DHU,
  OPTResponseCode::OPTRESPONSE_N3U,
  OPTResponseCode::OPTRESPONSE_EDNS_CLIENT_SUBNET,
  OPTResponseCode::OPTRESPONSE_EDNS_EXPIRE,
  OPTResponseCode::OPTRESPONSE_COOKIE,
  OPTResponseCode::OPTRESPONSE_EDNS_TCP_KEEPALIVE,
  OPTResponseCode::OPTRESPONSE_PADDING,
  OPTResponseCode::OPTRESPONSE_CHAIN,
  OPTResponseCode::OPTRESPONSE_EDNS_KEY_TAG,
  OPTResponseCode::OPTRESPONSE_EDNS_CLIENT_TAG,
  OPTResponseCode::OPTRESPONSE_EDNS_SERVER_TAG,
  OPTResponseCode::OPTRESPONSE_DEVICEID,
  OPTResponseCode::OPTRESPONSE_RESERVED_FOR_FUTURE_EXPANSION
const ENUM_VALUES_OPTOPTION_CODE:[OPTOptionCode; 19] = [
  OPTOptionCode::OPTOPTION_NONE,
  OPTOptionCode::OPTOPTION_LLQ,
  OPTOptionCode::OPTOPTION_UL,
  OPTOptionCode::OPTOPTION_NSID,
  OPTOptionCode::OPTOPTION_RESERVED_4,
  OPTOptionCode::OPTOPTION_DAU,
  OPTOptionCode::OPTOPTION_DHU,
  OPTOptionCode::OPTOPTION_N3U,
  OPTOptionCode::OPTOPTION_EDNS_CLIENT_SUBNET,
  OPTOptionCode::OPTOPTION_EDNS_EXPIRE,
  OPTOptionCode::OPTOPTION_COOKIE,
  OPTOptionCode::OPTOPTION_EDNS_TCP_KEEPALIVE,
  OPTOptionCode::OPTOPTION_PADDING,
  OPTOptionCode::OPTOPTION_CHAIN,
  OPTOptionCode::OPTOPTION_EDNS_KEY_TAG,
  OPTOptionCode::OPTOPTION_EDNS_CLIENT_TAG,
  OPTOptionCode::OPTOPTION_EDNS_SERVER_TAG,
  OPTOptionCode::OPTOPTION_DEVICEID,
  OPTOptionCode::OPTOPTION_RESERVED_FOR_FUTURE_EXPANSION
];


M src/server.rs => src/server.rs +6 -4
@@ 43,6 43,7 @@ pub async fn handle_query<'a>(
) -> Result<(), io::Error> {
    let received_request_id: u16;
    let requested_udp_size: u16;

    {
        // Reset request_fbb when exiting this block, success or error.
        let mut fbb = scopeguard::guard(&mut m.fbb, |fbb| {


@@ 61,10 62,11 @@ pub async fn handle_query<'a>(
        received_request_id = request.header().expect("missing request header").id();

        // For the response UDP size, lets just return whatever the client sent...
        requested_udp_size = match request.opt() {
            Some(opt) => opt.udp_size(),
            None => 4096,
        };
        if let Some(opt) = request.opt() {
            requested_udp_size = opt.udp_size();
        } else {
            requested_udp_size = 4096;
        }

        if check_local_response(&request, received_request_id, packet_buffer, filter, requested_udp_size)? {
            // Wrote local response to packet_buffer, exit early