50#if LWIP_MDNS_RESPONDER
55#define DOMAIN_JUMP_SIZE 2
56#define DOMAIN_JUMP 0xc000
58#define TOPDOMAIN_LOCAL "local"
60#define REVERSE_PTR_TOPDOMAIN "arpa"
61#define REVERSE_PTR_V4_DOMAIN "in-addr"
62#define REVERSE_PTR_V6_DOMAIN "ip6"
64static const char *dnssd_protos[] = {
71static err_t mdns_domain_add_label_pbuf(
struct mdns_domain *
domain,
76static err_t mdns_add_dotlocal(
struct mdns_domain *
domain);
80mdns_domain_add_label_base(
struct mdns_domain *
domain,
u8_t len)
82 if (
len > MDNS_LABEL_MAXLEN) {
85 if (
len > 0 && (1 +
len +
domain->length >= MDNS_DOMAIN_MAXLEN)) {
89 if (
len == 0 && (1 +
domain->length > MDNS_DOMAIN_MAXLEN)) {
146mdns_domain_add_domain(
struct mdns_domain *
domain,
struct mdns_domain *
source)
149 if (
len > 0 && (1 +
len +
domain->length >= MDNS_DOMAIN_MAXLEN)) {
153 if (
len == 0 && (1 +
domain->length > MDNS_DOMAIN_MAXLEN)) {
175mdns_domain_add_string(
struct mdns_domain *
domain,
const char *
source)
211 return MDNS_READNAME_ERROR;
218 if ((
c & 0xc0) == 0xc0) {
222 return MDNS_READNAME_ERROR;
231 if (
res == MDNS_READNAME_ERROR) {
235 return MDNS_READNAME_ERROR;
241 if (
c <= MDNS_LABEL_MAXLEN) {
244 if (
c +
domain->length >= MDNS_DOMAIN_MAXLEN) {
245 return MDNS_READNAME_ERROR;
249 return MDNS_READNAME_ERROR;
254 return MDNS_READNAME_ERROR;
281mdns_domain_debug_print(
struct mdns_domain *
domain)
289 for (
i = 0;
i < label_len;
i++) {
304mdns_domain_eq(
struct mdns_domain *
a,
struct mdns_domain *
b)
310 if (
a->length !=
b->length) {
316 while (*ptra && *ptrb && ptra < &a->
name[
a->length]) {
317 if (*ptra != *ptrb) {
330 if (*ptra != *ptrb && ptra < &a->
name[
a->length]) {
345mdns_build_reverse_v4_domain(
struct mdns_domain *
domain,
const ip4_addr_t *
addr)
357 for (
i =
sizeof(ip4_addr_t) - 1;
i >= 0;
i--) {
365 res = mdns_domain_add_label(
domain, REVERSE_PTR_V4_DOMAIN, (
u8_t)(
sizeof(REVERSE_PTR_V4_DOMAIN) - 1));
367 res = mdns_domain_add_label(
domain, REVERSE_PTR_TOPDOMAIN, (
u8_t)(
sizeof(REVERSE_PTR_TOPDOMAIN) - 1));
385mdns_build_reverse_v6_domain(
struct mdns_domain *
domain,
const ip6_addr_t *
addr)
400 for (
j = 0;
j < 2;
j++) {
401 if ((
byte & 0x0F) < 0xA) {
402 buf =
'0' + (
byte & 0x0F);
404 buf =
'a' + (
byte & 0x0F) - 0xA;
411 res = mdns_domain_add_label(
domain, REVERSE_PTR_V6_DOMAIN, (
u8_t)(
sizeof(REVERSE_PTR_V6_DOMAIN) - 1));
413 res = mdns_domain_add_label(
domain, REVERSE_PTR_TOPDOMAIN, (
u8_t)(
sizeof(REVERSE_PTR_TOPDOMAIN) - 1));
424mdns_add_dotlocal(
struct mdns_domain *
domain)
426 err_t res = mdns_domain_add_label(
domain, TOPDOMAIN_LOCAL, (
u8_t)(
sizeof(TOPDOMAIN_LOCAL) - 1));
429 return mdns_domain_add_label(
domain,
NULL, 0);
439mdns_build_host_domain(
struct mdns_domain *
domain,
struct mdns_host *mdns)
447 return mdns_add_dotlocal(
domain);
456mdns_build_dnssd_domain(
struct mdns_domain *
domain)
461 res = mdns_domain_add_label(
domain,
"_services", (
u8_t)(
sizeof(
"_services") - 1));
463 res = mdns_domain_add_label(
domain,
"_dns-sd", (
u8_t)(
sizeof(
"_dns-sd") - 1));
465 res = mdns_domain_add_label(
domain, dnssd_protos[DNSSD_PROTO_UDP], (
u8_t)
strlen(dnssd_protos[DNSSD_PROTO_UDP]));
467 return mdns_add_dotlocal(
domain);
480mdns_build_service_domain(
struct mdns_domain *
domain,
struct mdns_service *service,
int include_name)
491 res = mdns_domain_add_label(
domain, dnssd_protos[service->proto], (
u8_t)
strlen(dnssd_protos[service->proto]));
493 return mdns_add_dotlocal(
domain);
507mdns_build_request_domain(
struct mdns_domain *
domain,
struct mdns_request *
request,
int include_name)
519 return mdns_add_dotlocal(
domain);
538 struct mdns_domain
target;
547 if (target_end == MDNS_READNAME_ERROR) {
552 while (writelen < domain->
length) {
555 if (domainlen <= target.length && domainlen > DOMAIN_JUMP_SIZE) {
558 if ((targetpos + DOMAIN_JUMP_SIZE) >= target_len) {
562 if (
target.length >= domainlen &&
570 writelen += 1 + labellen;
585mdns_write_domain(
struct mdns_outpacket *outpkt,
struct mdns_domain *
domain)
590 u16_t jump_offset = 0;
593 if (!
domain->skip_compression) {
594 for (
i = 0;
i < NUM_DOMAIN_OFFSETS;
i++) {
598 if (
len < writelen) {
614 for (
i = 0;
i < NUM_DOMAIN_OFFSETS;
i++) {
615 if (outpkt->domain_offsets[
i] == 0) {
616 outpkt->domain_offsets[
i] = outpkt->write_offset;
621 outpkt->write_offset += writelen;
626 res =
pbuf_take_at(outpkt->pbuf, &jump, DOMAIN_JUMP_SIZE, outpkt->write_offset);
630 outpkt->write_offset += DOMAIN_JUMP_SIZE;
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
#define LWIP_DEBUGF(debug, message)
#define LWIP_ERROR(message, expression, handler)
GLint GLint GLsizei GLsizei GLsizei depth
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum const GLvoid * addr
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define LWIP_UNUSED_ARG(x)
u8_t pbuf_get_at(const struct pbuf *p, u16_t offset)
u16_t pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
int lwip_strnicmp(const char *str1, const char *str2, size_t len)
void lwip_itoa(char *result, size_t bufsize, int number)
#define MEMCPY(DST, SRC, BYTES)
static const WCHAR label[]
typedefPACK_STRUCT_END struct ip6_addr_packed ip6_addr_p_t