mdns_domain.h File Reference
`#include "lwip/apps/mdns_opts.h"`
`#include "lwip/apps/mdns_priv.h"`

## Functions

err_t | mdns_domain_add_label (struct mdns_domain *domain, const char *label, u8_t len)
err_t | mdns_domain_add_domain (struct mdns_domain *domain, struct mdns_domain *source)
err_t | mdns_domain_add_string (struct mdns_domain *domain, const char *source)
u16_t | mdns_readname (struct pbuf *p, u16_t offset, struct mdns_domain *domain)
void | mdns_domain_debug_print (struct mdns_domain *domain)
int | mdns_domain_eq (struct mdns_domain *a, struct mdns_domain *b)
err_t | mdns_build_reverse_v4_domain (struct mdns_domain *domain, const ip4_addr_t *addr)
err_t | mdns_build_reverse_v6_domain (struct mdns_domain *domain, const ip6_addr_t *addr)
err_t | mdns_build_host_domain (struct mdns_domain *domain, struct mdns_host *mdns)
err_t | mdns_build_dnssd_domain (struct mdns_domain *domain)
err_t | mdns_build_service_domain (struct mdns_domain *domain, struct mdns_service *service, int include_name)
err_t | mdns_build_request_domain (struct mdns_domain *domain, struct mdns_request *request, int include_name)
u16_t | mdns_compress_domain (struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain)
err_t | mdns_write_domain (struct mdns_outpacket *outpkt, struct mdns_domain *domain)

## Detailed Description

MDNS responder - domain related functionalities

## Function Documentation

## mdns_build_dnssd_domain()

err_t mdns_build_dnssd_domain | ( | struct mdns_domain * | domain | ) |

Build the lookup-all-services special DNS-SD domain name

Parameters

  domain | Where to write the domain name

Returns
  ERR_OK if domain _services._dns-sd._udp.local. was written, an err_t otherwise

## mdns_build_host_domain()

err_t mdns_build_host_domain | ( | struct mdns_domain * | domain,
|  | struct mdns_host * | mdns
| ) |  |

Build the <hostname>.local. domain name

Parameters

  domain | Where to write the domain name
  mdns | TMDNS netif descriptor.

Returns
  ERR_OK if domain <hostname>.local. was written, an err_t otherwise

## mdns_build_request_domain()

err_t mdns_build_request_domain | ( | struct mdns_domain * | domain,
|  | struct mdns_request * | request,
|  | int | include_name
| ) |  |

Build domain name for a request

Parameters

  domain | Where to write the domain name
  request | The request struct, containing service name, type and protocol
  include_name | Whether to include the service name in the domain

Returns
  ERR_OK if domain was written. If service name is included, <name>.<type>.<proto>.local. will be written, otherwise <type>.<proto>.local. An err_t is returned on error.

## mdns_build_reverse_v4_domain()

err_t mdns_build_reverse_v4_domain | ( | struct mdns_domain * | domain,
|  | const ip4_addr_t * | addr
| ) |  |

Build domain for reverse lookup of IPv4 address like 12.0.168.192.in-addr.arpa. for 192.168.0.12

Parameters

  domain | Where to write the domain name
  addr | Pointer to an IPv4 address to encode

Returns
  ERR_OK if domain was written, an err_t otherwise

## mdns_build_reverse_v6_domain()

err_t mdns_build_reverse_v6_domain | ( | struct mdns_domain * | domain,
|  | const ip6_addr_t * | addr
| ) |  |

Build domain for reverse lookup of IP address like b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. for 2001:db8::567:89ab

Parameters

  domain | Where to write the domain name
  addr | Pointer to an IPv6 address to encode

Returns
  ERR_OK if domain was written, an err_t otherwise

## mdns_build_service_domain()

err_t mdns_build_service_domain | ( | struct mdns_domain * | domain,
|  | struct mdns_service * | service,
|  | int | include_name
| ) |  |

Build domain name for a service

Parameters

  domain | Where to write the domain name
  service | The service struct, containing service name, type and protocol
  include_name | Whether to include the service name in the domain

Returns
  ERR_OK if domain was written. If service name is included, <name>.<type>.<proto>.local. will be written, otherwise <type>.<proto>.local. An err_t is returned on error.

## mdns_compress_domain()

u16_t mdns_compress_domain | ( | struct pbuf * | pbuf,
|  | u16_t * | offset,
|  | struct mdns_domain * | domain
| ) |  |

Return bytes needed to write before jump for best result of compressing supplied domain against domain in outpacket starting at specified offset. If a match is found, offset is updated to where to jump to

Parameters

  pbuf | Pointer to pbuf with the partially constructed DNS packet
  offset | Start position of a domain written earlier. If this location is suitable for compression, the pointer is updated to where in the domain to jump to.
  domain | The domain to write

Returns
  Number of bytes to write of the new domain before writing a jump to the offset. If compression can not be done against this previous domain name, the full new domain length is returned.

## mdns_domain_add_domain()

err_t mdns_domain_add_domain | ( | struct mdns_domain * | domain,
|  | struct mdns_domain * | source
| ) |  |

Add a partial domain to a domain

Parameters

  domain | The domain to add a label to
  source | The domain to add, like <\x09_services\007_dns-sd\000>

Returns
  ERR_OK on success, an err_t otherwise if label too long

## mdns_domain_add_label()

err_t mdns_domain_add_label | ( | struct mdns_domain * | domain,
|  | const char * | label,
|  | u8_t | len
| ) |  |

Add a label part to a domain

Parameters

  domain | The domain to add a label to
  label | The label to add, like <hostname>, 'local', 'com' or ''
  len | The length of the label

Returns
  ERR_OK on success, an err_t otherwise if label too long

## mdns_domain_add_string()

err_t mdns_domain_add_string | ( | struct mdns_domain * | domain,
|  | const char * | source
| ) |  |

Add a string domain to a domain

Parameters

  domain | The domain to add a label to
  source | The string to add, like <_services._dns-sd>

Returns
  ERR_OK on success, an err_t otherwise if label too long

## mdns_domain_debug_print()

void mdns_domain_debug_print | ( | struct mdns_domain * | domain | ) |

Print domain name to debug output

Parameters

  domain | The domain name

## mdns_domain_eq()

int mdns_domain_eq | ( | struct mdns_domain * | a,
|  | struct mdns_domain * | b
| ) |  |

Return 1 if contents of domains match (case-insensitive)

Parameters

  a | Domain name to compare 1
  b | Domain name to compare 2

Returns
  1 if domains are equal ignoring case, 0 otherwise

## mdns_readname()

u16_t mdns_readname | ( | struct pbuf * | p,
|  | u16_t | offset,
|  | struct mdns_domain * | domain
| ) |  |

Read possibly compressed domain name from packet buffer

Parameters

  p | The packet
  offset | start position of domain name in packet
  domain | The domain name destination

Returns
  The new offset after the domain, or MDNS_READNAME_ERROR if reading failed

## mdns_write_domain()

err_t mdns_write_domain | ( | struct mdns_outpacket * | outpkt,
|  | struct mdns_domain * | domain
| ) |  |

Write domain to outpacket. Compression will be attempted, unless domain->skip_compression is set.

Parameters

  outpkt | The outpacket to write to
  domain | The domain name to write

Returns
  ERR_OK on success, an err_t otherwise