using System; using System.Collections.Generic; namespace EGFramework{ /// /// Support a class for analysis the .local(mdns) or other www.com(dns) protocol to get the message, /// mdns protocol format type reference from https://github.com/richardschneider/net-mdns /// nuget package is Makaretu.Dns.Multicast /// mdns reference from https://www.rfc-editor.org/rfc/rfc6763.html /// public static class EGDnsExtension { public const string DefaultDnsServer = "1.1.1.1"; public const int DefaultDnsPort = 53; public const string DefaultMDnsServerIpv4 = "224.0.0.251"; public const string DefaultMDnsServerIpv6 = "FF02::FB"; public const int DefaultMDnsPort = 5353; public const string DNS_SRV_RR = "_services._dns-sd._udp.local"; } /// /// Dns's OpCode /// public enum DnsOpCode : ushort{ /// /// Standard query. /// Query = 0x0000, /// /// Inverse query (obsolete), see https://tools.ietf.org/html/rfc3425. /// InverseQuery = 0x0800, /// /// A server status request. /// Status = 0x1000, /// /// Zone change, see https://tools.ietf.org/html/rfc1996. /// Notify = 0x2000, /// /// Update message, see https://tools.ietf.org/html/rfc2136. /// Update = 0x2800 } /// /// A resource record or query type. /// public enum DnsType{ /// /// A host address. /// A = 1, /// /// An authoritative name server. /// NS = 2, /// /// The canonical name for an alias. /// CNAME = 5, /// /// Marks the start of a zone of authority. /// SOA = 6, /// /// A mailbox domain name (EXPERIMENTAL). /// MB = 7, /// /// A mail group member (EXPERIMENTAL). /// MG = 8, /// /// A mailbox rename domain name (EXPERIMENTAL). /// MR = 9, /// /// A Null resource record (EXPERIMENTAL). /// NULL = 10, /// /// A well known service description. /// WKS = 11, /// /// A domain name pointer. /// PTR = 12, /// /// Host information. /// HINFO = 13, /// /// Mailbox or mail list information. /// MINFO = 14, /// /// Mail exchange. /// MX = 15, /// /// Text resources. /// TXT = 16, /// /// Responsible Person. /// RP = 17, /// /// AFS Data Base location. /// AFSDB = 18, /// /// An IPv6 host address. /// AAAA = 28, /// /// A resource record which specifies the location of the server(s) for a specific protocol and domain. /// SRV = 33, /// /// Maps an entire domain name. /// DNAME = 39, /// /// Option record. /// OPT = 41, /// /// Delegation Signer. /// DS = 43, /// /// Signature for a RRSET with a particular name, class, and type. /// RRSIG = 46, /// /// Next secure owener. /// NSEC = 47, /// /// Public key cryptography to sign and authenticate resource records. /// DNSKEY = 48, /// /// Authenticated next secure owner. /// NSEC3 = 50, /// /// Parameters needed by authoritative servers to calculate hashed owner names. /// NSEC3PARAM = 51, /// /// Shared secret key. /// TKEY = 249, /// /// Transactional Signature. /// TSIG = 250, /// /// A request for a transfer of an entire zone. /// AXFR = 252, /// /// A request for mailbox-related records (MB, MG or MR). /// MAILB = 253, /// /// A request for any record(s). /// ANY = 255, /// /// A Uniform Resource Identifier (URI) resource record. /// URI = 256, /// /// A certification authority authorization. /// CAA = 257 } /// /// The values are maintained by IANA at https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-2. /// public enum DnsClass : ushort { /// /// The Internet. /// IN = 1, /// /// The CSNET class (Obsolete - used only for examples insome obsolete RFCs). /// CS = 2, /// /// The CHAOS class. /// CH = 3, /// /// Hesiod[Dyer 87]. /// HS = 4, /// /// Used in UPDATE message to signify no class. /// None = 254, /// /// Only used in QCLASS. /// ANY = 255 } public struct DnsHead{ } /// /// MDns Head /// | TransactionID (2 bytes) | OpCode (2 bytes) | Dns Sign (2 byte) /// public struct MDnsHead { /// /// /// /// public ushort TransactionID { set; get; } /// /// The requested operation. /// /// public DnsOpCode OpCode { set; get; } #region Sign Code /// /// A one bit field that specifies whether this message is a query(0), or a response(1). /// /// public bool QR { set; get; } public bool AA { set; get; } public bool TC { set; get; } public bool RD { set; get; } public bool RA { set; get; } public byte OpCode4Bit { set; get; } /// /// Reserved for future use. /// /// Must be zero in all queries and responses. public byte Z { set; get; } /// /// Authentic data. /// /// true if the response data is authentic; otherwise, false. public bool AD { get; set; } /// /// Checking disabled. /// /// true if the query does not require authenticated data; otherwise, false. public bool CD { get; set; } #endregion } public struct DnsQuestionRequest : IRequest { public byte ReplyCode { set; get; } public ushort QuestionsCount { set; get; } public ushort AnswerRRs { set; get; } public ushort AuthorityRRs { set; get; } public ushort Additional { set; get; } public List Data { set; get; } public byte QuestionType { set; get; } public byte QuestionClass { set; get; } public byte[] ToProtocolByteData() { throw new NotImplementedException(); } public string ToProtocolData() { throw new NotImplementedException(); } } }