rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
wa_mdns.h File Reference

The panel's name on the home network: an mDNS (multicast Domain Name System, RFC 6762) answer for "rcbench-1A2B.local". More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  wa_mdns_tries_t

Macros

#define WA_MDNS_PORT   5353u
#define WA_MDNS_TTL   120u
#define WA_MDNS_MAX   512u
#define WA_MDNS_RETRIES   3u
#define WA_MDNS_RETRY_MS   5000u

Functions

size_t wa_mdns_reply (const uint8_t *q, size_t n, uint16_t src_port, const char *host, const uint8_t ip[4], uint8_t *out, size_t cap)
size_t wa_mdns_announce (const char *host, const uint8_t ip[4], uint8_t *out, size_t cap)
void wa_mdns_tries_reset (wa_mdns_tries_t *t)
bool wa_mdns_tries_due (const wa_mdns_tries_t *t, uint32_t now_ms)
void wa_mdns_tries_started (wa_mdns_tries_t *t, uint32_t now_ms)

Detailed Description

The panel's name on the home network: an mDNS (multicast Domain Name System, RFC 6762) answer for "rcbench-1A2B.local".

Only the one name and only its address (type A): a query for it, of type A or ANY, is answered; everything else is not. A query from port 5353 is answered to the group with ID 0 and no question; one from any other port is a one-shot resolver's and gets its ID and its question back, with a TTL (time to live) of 10s as section 6.7 asks. Names compare without regard to the case of ASCII letters.

Pure C, no sockets: the platform receives on 224.0.0.251 port 5353 and sends what this returns.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ WA_MDNS_MAX

#define WA_MDNS_MAX   512u

Bytes an answer takes at most.

◆ WA_MDNS_TTL

#define WA_MDNS_TTL   120u

Seconds an answer to the group may be kept.

Function Documentation

◆ wa_mdns_announce()

size_t wa_mdns_announce ( const char * host,
const uint8_t ip[4],
uint8_t * out,
size_t cap )

An announcement of host at ip, sent unasked when the address comes.

◆ wa_mdns_reply()

size_t wa_mdns_reply ( const uint8_t * q,
size_t n,
uint16_t src_port,
const char * host,
const uint8_t ip[4],
uint8_t * out,
size_t cap )

The answer to the query q of n bytes from port src_port, for host (without ".local") at ip, into out of cap bytes: its length, or 0 when the query is not for this name, is not a query, or is malformed.

◆ wa_mdns_tries_due()

bool wa_mdns_tries_due ( const wa_mdns_tries_t * t,
uint32_t now_ms )

Whether the responder, not running, may be started now.

◆ wa_mdns_tries_reset()

void wa_mdns_tries_reset ( wa_mdns_tries_t * t)

A new join: no start made.

◆ wa_mdns_tries_started()

void wa_mdns_tries_started ( wa_mdns_tries_t * t,
uint32_t now_ms )

A start made at now_ms.