/** * @file * DNS - host name to IP address resolver. *//* ... *//* * Port to lwIP from uIP * by Jim Pettinato April 2007 * * security fixes and more by Simon Goldschmidt * * uIP version Copyright (c) 2002-2003, Adam Dunkels. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//* ... */#ifndefLWIP_HDR_PROT_DNS_H#defineLWIP_HDR_PROT_DNS_H#include"lwip/arch.h"#ifdef__cplusplusextern"C"{#endif/** DNS server port address */#ifndefDNS_SERVER_PORT#defineDNS_SERVER_PORT53#endif/* DNS field TYPE used for "Resource Records" */#defineDNS_RRTYPE_A1/* a host address */#defineDNS_RRTYPE_NS2/* an authoritative name server */#defineDNS_RRTYPE_MD3/* a mail destination (Obsolete - use MX) */#defineDNS_RRTYPE_MF4/* a mail forwarder (Obsolete - use MX) */#defineDNS_RRTYPE_CNAME5/* the canonical name for an alias */#defineDNS_RRTYPE_SOA6/* marks the start of a zone of authority */#defineDNS_RRTYPE_MB7/* a mailbox domain name (EXPERIMENTAL) */#defineDNS_RRTYPE_MG8/* a mail group member (EXPERIMENTAL) */#defineDNS_RRTYPE_MR9/* a mail rename domain name (EXPERIMENTAL) */#defineDNS_RRTYPE_NULL10/* a null RR (EXPERIMENTAL) */#defineDNS_RRTYPE_WKS11/* a well known service description */#defineDNS_RRTYPE_PTR12/* a domain name pointer */#defineDNS_RRTYPE_HINFO13/* host information */#defineDNS_RRTYPE_MINFO14/* mailbox or mail list information */#defineDNS_RRTYPE_MX15/* mail exchange */#defineDNS_RRTYPE_TXT16/* text strings */#defineDNS_RRTYPE_AAAA28/* IPv6 address */#defineDNS_RRTYPE_SRV33/* service location */#defineDNS_RRTYPE_ANY255/* any type *//* DNS field CLASS used for "Resource Records" */#defineDNS_RRCLASS_IN1/* the Internet */#defineDNS_RRCLASS_CS2/* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */#defineDNS_RRCLASS_CH3/* the CHAOS class */#defineDNS_RRCLASS_HS4/* Hesiod [Dyer 87] */#defineDNS_RRCLASS_ANY255/* any class */#defineDNS_RRCLASS_FLUSH0x800/* Flush bit *//* DNS protocol flags */#defineDNS_FLAG1_RESPONSE0x80#defineDNS_FLAG1_OPCODE_STATUS0x10#defineDNS_FLAG1_OPCODE_INVERSE0x08#defineDNS_FLAG1_OPCODE_STANDARD0x00#defineDNS_FLAG1_AUTHORATIVE0x04#defineDNS_FLAG1_TRUNC0x02#defineDNS_FLAG1_RD0x01#defineDNS_FLAG2_RA0x80#defineDNS_FLAG2_ERR_MASK0x0f#defineDNS_FLAG2_ERR_NONE0x00#defineDNS_FLAG2_ERR_NAME0x03#defineDNS_HDR_GET_OPCODE(hdr)((((hdr)->flags1)>>3)&0xF)37 defines#ifdefPACK_STRUCT_USE_INCLUDES# include"arch/bpstruct.h"#endifPACK_STRUCT_BEGIN/** DNS message header */structdns_hdr{PACK_STRUCT_FIELD(u16_tid);PACK_STRUCT_FLD_8(u8_tflags1);PACK_STRUCT_FLD_8(u8_tflags2);PACK_STRUCT_FIELD(u16_tnumquestions);PACK_STRUCT_FIELD(u16_tnumanswers);PACK_STRUCT_FIELD(u16_tnumauthrr);PACK_STRUCT_FIELD(u16_tnumextrarr);...}PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdefPACK_STRUCT_USE_INCLUDES# include"arch/epstruct.h"#endif#defineSIZEOF_DNS_HDR12/* Multicast DNS definitions *//** UDP port for multicast DNS queries */#ifndefDNS_MQUERY_PORT#defineDNS_MQUERY_PORT5353#endif/* IPv4 group for multicast DNS queries: 224.0.0.251 */#ifndefDNS_MQUERY_IPV4_GROUP_INIT#defineDNS_MQUERY_IPV4_GROUP_INITIPADDR4_INIT_BYTES(224,0,0,251)#endif/* IPv6 group for multicast DNS queries: FF02::FB */#ifndefDNS_MQUERY_IPV6_GROUP_INIT#defineDNS_MQUERY_IPV6_GROUP_INITIPADDR6_INIT_HOST(0xFF020000,0,0,0xFB)#endif#ifdef__cplusplus}extern "C" { ... }#endif/* ... */#endif/* LWIP_HDR_PROT_DNS_H */