Tiny DNS Server.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | label_t |
Macros | |
#define | COMPRESSED_STR_SIZE (2) |
#define | DHCP_OPTION_DOMAIN_NAME 15 |
#define | DHCP_OPTION_VENDOR_SPECIFIC_INFO 43 |
#define | DHCP_RESPONSE_DEFAULT_SIZE (512) |
Handle slightly smaller response than standard implementations. More... | |
#define | DNS_ANCOUNT_OFFSET (6) |
#define | DNS_ARCOUNT_OFFSET (10) |
#define | DNS_CLIENT_PORT (53000) |
DNS client port is set to 53000. More... | |
#define | DNS_DEFAULT_REQUEST_LEN (300) |
Default to slightly smaller DNS request than normal. More... | |
#define | DNS_FLAG1_AUTHORATIVE 0x04 |
#define | DNS_FLAG1_OPCODE_INVERSE 0x08 |
#define | DNS_FLAG1_OPCODE_STANDARD 0x00 |
#define | DNS_FLAG1_OPCODE_STATUS 0x10 |
#define | DNS_FLAG1_RD 0x01 |
#define | DNS_FLAG1_RESPONSE 0x80 |
#define | DNS_FLAG1_TRUNC 0x02 |
#define | DNS_FLAG2_ERR_MASK 0x0f |
#define | DNS_FLAG2_ERR_NAME 0x03 |
#define | DNS_FLAG2_ERR_NONE 0x00 |
#define | DNS_FLAG2_RA 0x80 |
#define | DNS_FLAGS_OFFSET (2) |
#define | DNS_NSCOUNT_OFFSET (8) |
#define | DNS_QDCOUNT_OFFSET (4) |
#define | DNS_RESPONSE_DEFAULT_SIZE (512) |
Handle default DNS Response size. More... | |
#define | DNS_RRCLASS_IN 1 /* internet class */ |
#define | DNS_RRTYPE_A 1 /* a host address */ |
#define | DNS_RRTYPE_AAAA (28) |
#define | DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ |
#define | DNS_RRTYPE_NS 2 /* an authoritative name server */ |
#define | DNS_RRTYPE_PTR 12 /* a domain name pointer */ |
#define | DNS_RRTYPE_SRV 33 /* a service locator */ |
#define | DNS_RRTYPE_TXT 16 /* arbitrary text - used by DNS-SD and others */ |
#define | DNS_RTYPE_A_FLAG (1 << 0) |
#define | DNS_RTYPE_NS_FLAG (1 << 1) |
#define | DNS_RTYPE_PTR_FLAG (1 << 2) |
#define | DNS_RTYPE_SRV_FLAG (1 << 3) |
#define | DNS_RTYPE_TXT_FLAG (1 << 4) |
#define | DNS_SD "_dns-sd" |
#define | DNS_SD_RR SERVICES "." DNS_SD "." UDP_PROTO "." LOCAL_DOMAIN |
#define | DNS_SERVER_PORT (53) |
#define | DNS_SRV_PRIORITY 0 |
#define | DNS_SRV_WEIGHT 0 |
#define | DNS_TID_OFFSET (0) |
#define | HTTP_SRV "_http" |
#define | HTTP_SRV_LOCAL_NAME_RR HTTP_SRV_LOCAL_NAME "." HTTP_SRV "." TCP_PROTO "." LOCAL_DOMAIN |
#define | HTTP_SRV_RR HTTP_SRV "." TCP_PROTO "." LOCAL_DOMAIN |
#define | HTTP_SRV_SHORT_NAME_RR HTTP_SRV_LOCAL_NAME "." LOCAL_DOMAIN |
#define | LOCAL_DOMAIN "local" |
#define | MDNS_ADDR_IP _tiny_ip4_addr(MDNS_ADDRESS) |
#define | MDNS_ADDRESS 224, 0, 0, 251 |
#define | MDNS_PORT (5353) |
#define | MFI_RR "_mfi-config." TCP_PROTO "." LOCAL_DOMAIN |
#define | MFI_SRV_LOCAL_NAME_RR HTTP_SRV_LOCAL_NAME "." MFI_RR |
#define | MSG_COMPRESSION_FLAGS (0xc0) |
#define | MSG_COMPRESSION_FLAGS16 (0xc000) |
#define | MSG_OFFSET_MASK (0x3FF) |
#define | QUERY_STRING_LEN (30) |
#define | SERVICES "_services" |
#define | SIZEOF_ANCOUNTFIELD (2) |
#define | SIZEOF_ARCOUNTFIELD (2) |
#define | SIZEOF_CLASSFIELD (2) |
#define | SIZEOF_DNS_HDR (12) |
#define | SIZEOF_IPADDR (4) |
#define | SIZEOF_LENFIELD (2) |
#define | SIZEOF_MIN_DNS_QUERY (5) |
#define | SIZEOF_MIN_DNS_STR (2) |
#define | SIZEOF_NSCOUNTFIELD (2) |
#define | SIZEOF_PORTFIELD (2) |
#define | SIZEOF_PRIOFIELD (2) |
#define | SIZEOF_QDCOUNTFIELD (2) |
#define | SIZEOF_SRV_PORTFIELD (2) |
#define | SIZEOF_SRV_PRIORITYFIELD (2) |
#define | SIZEOF_SRV_RDATA_HDR (SIZEOF_SRV_PRIORITYFIELD + SIZEOF_SRV_WEIGHTFIELD + SIZEOF_SRV_PORTFIELD) |
#define | SIZEOF_SRV_WEIGHTFIELD (2) |
#define | SIZEOF_TTLFIELD (4) |
#define | SIZEOF_TYPEFIELD (2) |
#define | SIZEOF_WEIGHTFIELD (2) |
#define | TCP_PROTO "_tcp" |
#define | TINY_DNS_CLIENT_TIMEOUT (5000) /* default to 5 seconds */ |
#define | UDP_PROTO "_udp" |
Typedefs | |
typedef enum dns_transmission_type | dns_transmission_type_t |
typedef enum subqry | subqry_t |
Enumerations | |
enum | dns_transmission_type { DNS_MULTICAST, DNS_UNICAST } |
enum | subqry { DNS_QRY_REVERSE_NAME_LOOKUP_FOR_LOCAL_IP, DNS_QRY_HTTP_LOCAL, DNS_QRY_DNS_SD_LOCAL, DNS_QRY_MFI_LOCAL, DNS_QRY_UNKNOWN, DNS_QRY_NONE } |
Functions | |
static ip_addr_t | _tiny_ip4_addr (uint8_t a, uint8_t b, uint8_t c, uint8_t d) |
uint32_t | lwip_dns_hton_string (struct pbuf *pbuf, uint32_t offset, char const *name, bool flag, uint32_t *plen) |
Put host name into DNS RDATA format. More... | |
uint32_t | pbuf_read16be (struct pbuf *pbuf, uint32_t offset, uint16_t *pval) |
Read two bytes (big-endian) from a pbuf. More... | |
uint32_t | pbuf_read32le (struct pbuf *pbuf, uint32_t offset, uint32_t *pval) |
Read four bytes (little-endian) from a pbuf. More... | |
uint32_t | pbuf_read8 (struct pbuf *pbuf, uint32_t offset, uint8_t *pval) |
Read a byte from a pbuf. More... | |
static uint32_t | pbuf_read_ip (struct pbuf *pbuf, uint32_t offset, ip_addr_t *p_addr) |
err_t | pbuf_take_partial (struct pbuf *buf, uint32_t offset, const void *dataptr, u16_t len) |
Copy application supplied data into a pbuf. More... | |
uint32_t | pbuf_write16be (struct pbuf *pbuf, uint32_t offset, uint16_t val) |
Write two bytes (big-endian) to a pbuf. More... | |
uint32_t | pbuf_write32be (struct pbuf *pbuf, uint32_t offset, uint32_t val) |
Write four bytes (big-endian) to a pbuf. More... | |
uint32_t | pbuf_write32le (struct pbuf *pbuf, uint32_t offset, uint32_t val) |
Write four bytes (little-endian) to a pbuf. More... | |
uint32_t | pbuf_write8 (struct pbuf *pbuf, uint32_t offset, uint8_t val) |
Write a byte to a pbuf. More... | |
static uint32_t | pbuf_write_ip (struct pbuf *pbuf, uint32_t offset, ip_addr_t addr) |
#define COMPRESSED_STR_SIZE (2) |
#define DHCP_OPTION_DOMAIN_NAME 15 |
#define DHCP_OPTION_VENDOR_SPECIFIC_INFO 43 |
#define DHCP_RESPONSE_DEFAULT_SIZE (512) |
Handle slightly smaller response than standard implementations.
#define DNS_ANCOUNT_OFFSET (6) |
#define DNS_ARCOUNT_OFFSET (10) |
#define DNS_CLIENT_PORT (53000) |
DNS client port is set to 53000.
#define DNS_DEFAULT_REQUEST_LEN (300) |
Default to slightly smaller DNS request than normal.
#define DNS_FLAG1_AUTHORATIVE 0x04 |
#define DNS_FLAG1_OPCODE_INVERSE 0x08 |
#define DNS_FLAG1_OPCODE_STANDARD 0x00 |
#define DNS_FLAG1_OPCODE_STATUS 0x10 |
#define DNS_FLAG1_RD 0x01 |
#define DNS_FLAG1_RESPONSE 0x80 |
#define DNS_FLAG1_TRUNC 0x02 |
#define DNS_FLAG2_ERR_MASK 0x0f |
#define DNS_FLAG2_ERR_NAME 0x03 |
#define DNS_FLAG2_ERR_NONE 0x00 |
#define DNS_FLAG2_RA 0x80 |
#define DNS_FLAGS_OFFSET (2) |
#define DNS_NSCOUNT_OFFSET (8) |
#define DNS_QDCOUNT_OFFSET (4) |
#define DNS_RESPONSE_DEFAULT_SIZE (512) |
Handle default DNS Response size.
#define DNS_RRCLASS_IN 1 /* internet class */ |
#define DNS_RRTYPE_A 1 /* a host address */ |
#define DNS_RRTYPE_AAAA (28) |
#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ |
#define DNS_RRTYPE_NS 2 /* an authoritative name server */ |
#define DNS_RRTYPE_PTR 12 /* a domain name pointer */ |
#define DNS_RRTYPE_SRV 33 /* a service locator */ |
#define DNS_RRTYPE_TXT 16 /* arbitrary text - used by DNS-SD and others */ |
#define DNS_RTYPE_A_FLAG (1 << 0) |
#define DNS_RTYPE_NS_FLAG (1 << 1) |
#define DNS_RTYPE_PTR_FLAG (1 << 2) |
#define DNS_RTYPE_SRV_FLAG (1 << 3) |
#define DNS_RTYPE_TXT_FLAG (1 << 4) |
#define DNS_SD "_dns-sd" |
#define DNS_SD_RR SERVICES "." DNS_SD "." UDP_PROTO "." LOCAL_DOMAIN |
#define DNS_SERVER_PORT (53) |
#define DNS_SRV_PRIORITY 0 |
#define DNS_SRV_WEIGHT 0 |
#define DNS_TID_OFFSET (0) |
#define HTTP_SRV "_http" |
#define HTTP_SRV_LOCAL_NAME_RR HTTP_SRV_LOCAL_NAME "." HTTP_SRV "." TCP_PROTO "." LOCAL_DOMAIN |
#define HTTP_SRV_RR HTTP_SRV "." TCP_PROTO "." LOCAL_DOMAIN |
#define HTTP_SRV_SHORT_NAME_RR HTTP_SRV_LOCAL_NAME "." LOCAL_DOMAIN |
#define LOCAL_DOMAIN "local" |
#define MDNS_ADDR_IP _tiny_ip4_addr(MDNS_ADDRESS) |
#define MDNS_ADDRESS 224, 0, 0, 251 |
#define MDNS_PORT (5353) |
#define MFI_RR "_mfi-config." TCP_PROTO "." LOCAL_DOMAIN |
#define MFI_SRV_LOCAL_NAME_RR HTTP_SRV_LOCAL_NAME "." MFI_RR |
#define MSG_COMPRESSION_FLAGS (0xc0) |
#define MSG_COMPRESSION_FLAGS16 (0xc000) |
#define MSG_OFFSET_MASK (0x3FF) |
#define QUERY_STRING_LEN (30) |
#define SERVICES "_services" |
#define SIZEOF_ANCOUNTFIELD (2) |
#define SIZEOF_ARCOUNTFIELD (2) |
#define SIZEOF_CLASSFIELD (2) |
#define SIZEOF_DNS_HDR (12) |
#define SIZEOF_IPADDR (4) |
#define SIZEOF_LENFIELD (2) |
#define SIZEOF_MIN_DNS_QUERY (5) |
#define SIZEOF_MIN_DNS_STR (2) |
#define SIZEOF_NSCOUNTFIELD (2) |
#define SIZEOF_PORTFIELD (2) |
#define SIZEOF_PRIOFIELD (2) |
#define SIZEOF_QDCOUNTFIELD (2) |
#define SIZEOF_SRV_PORTFIELD (2) |
#define SIZEOF_SRV_PRIORITYFIELD (2) |
#define SIZEOF_SRV_RDATA_HDR (SIZEOF_SRV_PRIORITYFIELD + SIZEOF_SRV_WEIGHTFIELD + SIZEOF_SRV_PORTFIELD) |
#define SIZEOF_SRV_WEIGHTFIELD (2) |
#define SIZEOF_TTLFIELD (4) |
#define SIZEOF_TYPEFIELD (2) |
#define SIZEOF_WEIGHTFIELD (2) |
#define TCP_PROTO "_tcp" |
#define TINY_DNS_CLIENT_TIMEOUT (5000) /* default to 5 seconds */ |
#define UDP_PROTO "_udp" |
typedef enum dns_transmission_type dns_transmission_type_t |
enum subqry |
|
inlinestatic |
uint32_t lwip_dns_hton_string | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
char const * | name, | ||
bool | flag, | ||
uint32_t * | plen | ||
) |
Put host name into DNS RDATA format.
uint32_t pbuf_read16be | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint16_t * | pval | ||
) |
Read two bytes (big-endian) from a pbuf.
If the read is beyond the end of the pbuf chain's payload, then return an error instead.
buf | pbuf to read data from. |
offset | logical offset into pbuf to start reading from |
pval | memory to place the read bytes into. |
References _wifi_get16_be(), pbuf_copy_partial(), and pbuf::tot_len.
uint32_t pbuf_read32le | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint32_t * | pval | ||
) |
Read four bytes (little-endian) from a pbuf.
If the requested read is beyond the * end of the pbuf chain's payload, then this function does not perform the read. It returns an error instead.
buf | pbuf to read data from. |
offset | logical offset into pbuf to start reading from. |
val | the data to read from the pbuf. |
References _wifi_get32_le(), pbuf_copy_partial(), and pbuf::tot_len.
Referenced by pbuf_read_ip().
uint32_t pbuf_read8 | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint8_t * | pval | ||
) |
Read a byte from a pbuf.
If the read is beyond the end of the pbuf chain's payload, then return an error instead.
buf | pbuf to read data from. |
offset | logical offset into pbuf to start reading from |
pval | memory to place the read byte into. |
References pbuf_get_at(), and pbuf::tot_len.
|
inlinestatic |
References pbuf_read32le().
Copy application supplied data into a pbuf.
This function can only be used to copy the equivalent of buf->tot_len data.
buf | pbuf to fill with data |
offset | logical offset into pbuf to start writing data into |
dataptr | application supplied data buffer |
len | length of the application supplied data buffer |
References Assert, ERR_ARG, ERR_OK, pbuf::len, pbuf::next, NULL, and pbuf::payload.
Referenced by pbuf_write16be(), pbuf_write32be(), pbuf_write32le(), and pbuf_write8().
uint32_t pbuf_write16be | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint16_t | val | ||
) |
Write two bytes (big-endian) to a pbuf.
If the requested write is beyond the * end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.
buf | pbuf to write data to. |
offset | logical offset into pbuf to start writing to. |
val | the data to write to the pbuf. |
References _wifi_put16_be(), ERR_OK, pbuf_take_partial(), and pbuf::tot_len.
uint32_t pbuf_write32be | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint32_t | val | ||
) |
Write four bytes (big-endian) to a pbuf.
If the requested write is beyond the * end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.
buf | pbuf to write data to. |
offset | logical offset into pbuf to start writing to. |
val | the data to write to the pbuf. |
References _wifi_put32_be(), ERR_OK, pbuf_take_partial(), and pbuf::tot_len.
uint32_t pbuf_write32le | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint32_t | val | ||
) |
Write four bytes (little-endian) to a pbuf.
If the requested write is beyond the * end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.
buf | pbuf to write data to. |
offset | logical offset into pbuf to start writing to. |
val | the data to write to the pbuf. |
References _wifi_put32_le(), ERR_OK, pbuf_take_partial(), and pbuf::tot_len.
Referenced by pbuf_write_ip().
uint32_t pbuf_write8 | ( | struct pbuf * | pbuf, |
uint32_t | offset, | ||
uint8_t | val | ||
) |
Write a byte to a pbuf.
If the requested write is beyond the end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.
buf | pbuf to write data to. |
offset | logical offset into pbuf to start writing to. |
val | the data to write to the pbuf. |
References ERR_OK, pbuf_take_partial(), and pbuf::tot_len.
|
inlinestatic |
References pbuf_write32le().