#include "nip_init.h"
#include "nip_types.h"
#include "os_core.h"
#include "mem.h"
#include "net/net_if.h"
#include "app/dns.h"
Go to the source code of this file.
Data Structures | |
struct | nip_mdns_name |
struct | nip_mdns_rdata_a |
struct | nip_mdns_rdata_srv |
struct | nip_mdns_rdata_ptr |
struct | nip_mdns_rdata_oth |
union | nip_mdns_rdata_t |
struct | nip_mdns_query |
struct | nip_mdns_namestring |
struct | nip_mdns_record |
struct | nip_mdns_cache |
struct | nip_mdns_cache_subscription |
struct | nip_mdns_check |
Defines | |
#define | NIP_MDNS_ADDR0 224 |
#define | NIP_MDNS_ADDR1 0 |
#define | NIP_MDNS_ADDR2 0 |
#define | NIP_MDNS_ADDR3 251 |
#define | NIP_MDNS_MAX_QUERIES 5 |
maximum number of open MDNS queries. | |
#define | NIP_MDNS_DISCARD_ON_OUT_OF_MEMORY 1 |
If this is set to 1 we won't wait for memory to become free, but discard any incoming packet if we don't have enough memory available to serve it. | |
#define | NIP_MDNS_MAX_NAMESTRINGS 20 |
maximum number of cached DNS name strings. | |
#define | NIP_MDNS_MAX_CACHE_SIZE 20 |
maximum number of entries in MDNS cache | |
#define | NIP_MDNS_DEFEND_HOSTNAME 1 |
Should mdns-hostname be unique in the network? | |
#define | NIP_MDNS_MAX_NAME_DEPTH 6 |
The currently used system maximizes the size of MDNS names to 6 dotted parts which is the maximum size needed for IPv4 in-addr.arpa pointers. | |
#define | NIP_MDNS_CREATE_IN_ADDR_ARPA_PTR 1 |
#define | NIP_MDNS_COUNTER_SIZE 1 |
Byte-Size of temporary query and answer counters for transmission. | |
#define | NIP_MDNS_NO_QUERY_TIMER 255 |
Query timer with this value is disabled until set to a different value. | |
#define | NIP_MDNS_PROBE_COUNT 3 |
Maximum number of probes to send until assuming no conflict. | |
#define | NIP_MDNS_ANNOUNCE_COUNT 3 |
Maximum number of announcements to send until assuming no conflict. | |
#define | NIP_MDNS_DEFAULT_TTL_A 12 |
default TTL for records with a host name \ in rname or rdata, 2min | |
#define | NIP_MDNS_DEFAULT_TTL 4500 |
default TTL for not-A-records, 75min | |
#define | NIP_MDNS_QUERY_ID_MASK 0x3F |
#define | NIP_MDNS_NO_QUERY 0x3F |
#define | NIP_MDNS_QUERY_DELETE 0x80 |
#define | NIP_MDNS_QUERY_ACTIVE 0x00 |
#define | NIP_MDNS_NFY_NONE 0x00 |
#define | NIP_MDNS_NFY_LOCAL 0x80 |
#define | NIP_MDNS_NFY_REMOTE 0x40 |
#define | NIP_MDNS_NFY_ALL (NIP_MDNS_NFY_LOCAL|NIP_MDNS_NFY_REMOTE) |
#define | NIP_MDNS_NFY_NONE 0x00 |
#define | NIP_MDNS_NO_NAMESTRING 0 |
#define | NIP_MDNS_NO_CACHE_ID 0 |
#define | NIP_MDNS_MAX_NAMESTRING_USG (NIP_MDNS_MAX_CACHE_SIZE/2 + NIP_MDNS_MAX_QUERIES) |
Size of usage counter assumes that average usage of a namestring will not exceed two occurances per cache entry and one per query. | |
#define | NIP_MDNS_RDATA_SRV_SIZE (3*sizeof(uint16_t)+sizeof(struct nip_mdns_data_a)) |
PTR data entry only holds instance name as app, proto and domain are implicit. | |
#define | NIP_MDNS_RDATA_PTR_SIZE sizeof(nip_mdns_namestring_id_t) |
PTR data entry only holds instance name as app, proto and domain are implicit. | |
#define | NIP_MDNS_CSTAT_AUTH_BIT 0x01 |
All Cache entries with the NIP_MDNS_CSTAT_AUTHORATIVE_BIT status bit set are considered authorative and will be used to reply to remote queries and will be defended upon conflicts. | |
#define | NIP_MDNS_CSTAT_AUTH_MASK 0x0F |
#define | NIP_MDNS_CSTAT_LEARNED_BIT 0x80 |
All Cache entries with the NIP_MDNS_CSTAT_LEARNED_BIT status bit set are considered learned and bound to one or more local queries. | |
#define | NIP_MDNS_CSTAT_LEARNED_MASK 0xF0 |
#define | NIP_MDNS_QTYPE_TX_BIT 0x80 |
#define | NIP_MDNS_QTYPE_LOCAL_BIT 0x01 |
#define | NIP_MDNS_QTYPE_REMOTE_BIT 0x02 |
#define | NIP_MDNS_STRINGOFF (sizeof(nip_mdns_namestring_id_t)+sizeof(nip_mdns_namestring_usg_t)) |
#define | NIP_MDNS_BASE_RECORD_SIZE (sizeof(struct nip_mdns_record)-sizeof(nip_mdns_rdata_t)) |
#define | NIP_MDNS_OTH_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_oth)) |
#define | NIP_MDNS_A_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_a )) |
#define | NIP_MDNS_SRV_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_srv)) |
#define | NIP_MDNS_PTR_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_ptr)) |
#define | NIP_MDNS_BASE_CACHE_SIZE (sizeof(struct nip_mdns_cache)-sizeof(struct nip_mdns_record)) |
#define | NIP_MDNS_QA_COUNTERS_OFFSET 4 |
counter offset in dns header | |
#define | NIP_MDNS_QA_COUNTERS_NUMBER 4 |
number of query/answer counters | |
Macros for Management of DNS names | |
#define | NIP_MDNS_REG_STRING(name_ptr) nip_mdns_register_name( NULL, 0, name_ptr, 1 ) |
Register name string. | |
#define | NIP_MDNS_REG_NAME(idarr, idcnt, name_ptr) nip_mdns_register_name( idarr, idcnt, name_ptr, 1 ) |
Register dns-encoded name. | |
#define | NIP_MDNS_NAME_USE(idarr, idcnt) nip_mdns_register_name( idarr, idcnt, NULL, 1 ) |
Increment name usage. | |
#define | NIP_MDNS_UNREG_NAME(idarr, idcnt) nip_mdns_register_name( idarr, idcnt, NULL, -1 ) |
Unregister name occurence. | |
#define | NIP_MDNS_CHECK_NAME(name_ptr) nip_mdns_register_name( NULL, 0, name_ptr, 0 ) |
Does name exist in list? | |
#define | NIP_MDNS_WRITE_NAME(idarr, idcnt, buf_ptr) nip_mdns_register_name( idarr, idcnt, buf_ptr, 0 ) |
Write mdns-encoded name to buffer. | |
Macros for Management of DNS Queries | |
#define | NIP_MDNS_PROBE(name) nip_mdns_query( NIP_MDNS_QTYPE_PROBE, name, NIP_MDNS_TYPE_ANY ) |
Send PROBE request for record. | |
#define | NIP_MDNS_ANNOUNCE(name) nip_mdns_query( NIP_MDNS_QTYPE_ANNOUNCE, name, NIP_MDNS_TYPE_ANY ) |
Send Announcements for record. | |
#define | NIP_MDNS_SUBSCRIBE_REMOTE(c_id, q_id) nip_mdns_notify( NIP_MDNS_NFYTASK_SUBSCRIBE, c_id, q_id, NIP_MDNS_NFY_REMOTE ) |
#define | NIP_MDNS_UNSUBSCRIBE_QUERY(q_id) nip_mdns_notify( NIP_MDNS_NFYTASK_UNSUBSCRIBE, NIP_MDNS_NO_CACHE_ID, q_id, NIP_MDNS_NFY_ALL ) |
#define | NIP_MDNS_QUERY_NOTIFIED(c_id, q_id) nip_mdns_notify( NIP_MDNS_NFYTASK_NOTIFIED, c_id, q_id, NIP_MDNS_NFY_REMOTE ) |
Cache subscriptions for (Remote) Queries will be removed upon notification. | |
Macros for Management of DNS Cache | |
#define | NIP_MDNS_REGISTER(cache_id_ptr, record_ptr) nip_mdns_cache_task( NIP_MDNS_TASK_REGISTER, cache_id_ptr, record_ptr ) |
#define | NIP_MDNS_UNREGISTER(cache_id_ptr) nip_mdns_cache_task( NIP_MDNS_TASK_UNREGISTER, cache_id_ptr, NULL ) |
#define | NIP_MDNS_REGUNIQUE(cache_id_ptr, record_ptr) nip_mdns_cache_task( NIP_MDNS_TASK_REGUNIQUE, cache_id_ptr, record_ptr ) |
#define | NIP_MDNS_RESET_CACHE() nip_mdns_cache_task( NIP_MDNS_TASK_RESET, NULL, NULL ) |
#define | NIP_MDNS_GET_RECORD(cache_id_ptr, record_ptr) nip_mdns_cache_task( NIP_MDNS_TASK_GET_LEARNED, cache_id_ptr, record_ptr ) |
#define | NIP_MDNS_GET_LEARNED_CSTAT(item_ptr) ((item_ptr)->stat & NIP_MDNS_CSTAT_LEARNED_MASK) |
#define | NIP_MDNS_GET_AUTH_CSTAT(item_ptr) ((item_ptr)->stat & NIP_MDNS_CSTAT_AUTH_MASK) |
#define | NIP_MDNS_SET_LEARNED_CSTAT(item_ptr, newstat) (item_ptr)->stat = ((item_ptr)->stat & ~NIP_MDNS_CSTAT_LEARNED_MASK) | newstat |
#define | NIP_MDNS_SET_AUTH_CSTAT(item_ptr, newstat) (item_ptr)->stat = ((item_ptr)->stat & ~NIP_MDNS_CSTAT_LEARNED_MASK) | newstat |
Typedefs | |
typedef uint8_t | nip_mdns_query_id_t |
typedef uint8_t | nip_mdns_query_cnt_t |
typedef uint8_t | nip_mdns_namestring_id_t |
typedef uint8_t | nip_mdns_namestring_cnt_t |
typedef uint8_t | nip_mdns_namestring_len_t |
Per standard, the size of the name string length is limited to 6 Bit. | |
typedef uint8_t | nip_mdns_cache_id_t |
typedef uint8_t | nip_mdns_cache_cnt_t |
typedef uint8_t | nip_mdns_namestring_usg_t |
typedef uint8_t | nip_mdns_record_size_t |
typedef uint8_t | nip_mdns_qa_counter_t |
Enumerations | |
enum | nip_mdns_type_t { NIP_MDNS_TYPE_A = 1, NIP_MDNS_TYPE_NS = 2, NIP_MDNS_TYPE_CNAME = 5, NIP_MDNS_TYPE_SOA = 6, NIP_MDNS_TYPE_PTR = 12, NIP_MDNS_TYPE_MX = 15, NIP_MDNS_TYPE_TXT = 16, NIP_MDNS_TYPE_AAAA = 28, NIP_MDNS_TYPE_SRV = 33, NIP_MDNS_TYPE_ANY = 255 } |
enum | nip_mdns_status_t { NIP_MDNS_STAT_DOWN = 0, NIP_MDNS_STAT_INIT, NIP_MDNS_STAT_UP, NIP_MDNS_STAT_CACHE_CHECK, NIP_MDNS_STAT_QUERY_CHECK, NIP_MDNS_STAT_RESET, NIP_MDNS_STAT_BYE } |
enum | nip_mdns_cache_status_t { NIP_MDNS_CSTAT_PROBING = 0x02, NIP_MDNS_CSTAT_PROBECONFLICT = 0x04, NIP_MDNS_CSTAT_AUTHORATIVE = 0x01, NIP_MDNS_CSTAT_UNIQUE_AUTH = 0x09, NIP_MDNS_CSTAT_ANNOUNCING = 0x03, NIP_MDNS_CSTAT_CONFLICT = 0x05, NIP_MDNS_CSTAT_DELETE = 0x00, NIP_MDNS_CSTAT_LEARNED = 0x80, NIP_MDNS_CSTAT_REFRESH = 0x90, NIP_MDNS_CSTAT_OUTDATED1 = 0xA0, NIP_MDNS_CSTAT_OUTDATED2 = 0xB0 } |
enum | nip_mdns_task_t { NIP_MDNS_TASK_UNREGISTER = 0x00, NIP_MDNS_TASK_REGISTER = 0x01, NIP_MDNS_TASK_REGUNIQUE = 0x11, NIP_MDNS_TASK_LEARN = 0x20, NIP_MDNS_TASK_SEARCH = 0x30, NIP_MDNS_TASK_GET = 0x80, NIP_MDNS_TASK_GET_LEARNED = 0x90, NIP_MDNS_TASK_RESET = 0x40 } |
enum | nip_mdns_nfy_task_t { NIP_MDNS_NFYTASK_NOTIFY = 0x01, NIP_MDNS_NFYTASK_SUBSCRIBE = 0x11, NIP_MDNS_NFYTASK_UNSUBSCRIBE = 0x10, NIP_MDNS_NFYTASK_NOTIFIED = 0x20 } |
enum | nip_mdns_name_task_t { NIP_MDNS_NTASK_FIND, NIP_MDNS_NTASK_WRITE } |
enum | nip_mdns_query_type_t { NIP_MDNS_QTYPE_LOCAL = 0x81, NIP_MDNS_QTYPE_REMOTE = 0x02, NIP_MDNS_QTYPE_REMLOC = 0x83, NIP_MDNS_QTYPE_PROBE = 0x82, NIP_MDNS_QTYPE_ANNOUNCE = 0x12 } |
Query types. More... | |
enum | nip_mdns_packet_type_t { NIP_MDNS_PTYPE_NONE = 0x00, NIP_MDNS_PTYPE_QUERY = 0x01, NIP_MDNS_PTYPE_RESPONSE = 0x02, NIP_MDNS_PTYPE_PROBE = 0x11, NIP_MDNS_PTYPE_ANSWCONTINUED = 0x21, NIP_MDNS_PTYPE_PROBERESPONSE = 0x12 } |
The lower two Bits of Packet type describe wether a Query or a Response packet will be sent. More... | |
enum | nip_mdns_qa_offset_t { NIP_MDNS_QDCOUNT_OFFSET = 0, NIP_MDNS_ANCOUNT_OFFSET = 1, NIP_MDNS_NSCOUNT_OFFSET = 2, NIP_MDNS_ARCOUNT_OFFSET = 3 } |
Section types in DNS packet. More... | |
enum | nip_mdns_packet_task_t { NIP_MDNS_PTASK_INC_COUNTER, NIP_MDNS_PTASK_SECTION_PTR, NIP_MDNS_PTASK_SET_TC, NIP_MDNS_PTASK_NEXT_ITEM } |
Functions | |
nip_error_t | nip_mdns_init (void) |
initialize mdns memory | |
void | nip_mdns_interface_up (nip_net_if_id_t if_id) |
Register host name and refresh cache. | |
void | nip_mdns_interface_down (void) |
nip_mdns_query_id_t | nip_mdns_query (nip_mdns_query_type_t qtype, struct nip_mdns_name *name, nip_mdns_type_t type) |
Execute MDNS lookup query. | |
nip_mdns_cache_id_t | nip_mdns_fetch_results (nip_mdns_query_id_t r_id) |
Fetch next result for lookup query. | |
nip_error_t | nip_mdns_close (nip_mdns_query_id_t r_id) |
Close query. | |
nip_mdns_namestring_id_t | nip_mdns_register_name (nip_mdns_namestring_id_t *id, uint8_t cnt, nip_mem_ptr_t *name_ptr, nip_mdns_namestring_usg_t usg) |
Registers new MDNS namestring or retrieves already registered entry for that name. | |
struct nip_mdns_cache * | nip_mdns_cache_ptr (nip_mdns_cache_id_t id) |
Get pointer to specific cache entry. | |
nip_error_t | nip_mdns_cache_task (nip_mdns_task_t task, nip_mdns_cache_id_t *id, struct nip_mdns_record *record) |
Perform mDNS cache operation. | |
void | nip_mdns_disp_check (void) |
Dispatcher function to be called upon receiving mDNS events. | |
Variables | |
nip_mdns_query_id_t | nip_mdns_hostname_queries |
#define NIP_MDNS_A_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_a )) |
#define NIP_MDNS_ADDR0 224 |
#define NIP_MDNS_ADDR1 0 |
#define NIP_MDNS_ADDR2 0 |
#define NIP_MDNS_ADDR3 251 |
#define NIP_MDNS_ANNOUNCE | ( | name | ) | nip_mdns_query( NIP_MDNS_QTYPE_ANNOUNCE, name, NIP_MDNS_TYPE_ANY ) |
#define NIP_MDNS_ANNOUNCE_COUNT 3 |
#define NIP_MDNS_BASE_CACHE_SIZE (sizeof(struct nip_mdns_cache)-sizeof(struct nip_mdns_record)) |
Definition at line 447 of file mdns.h.
Referenced by nip_mdns_cache_ptr(), nip_mdns_cache_task(), and nip_mdns_disp_check_cache().
#define NIP_MDNS_BASE_RECORD_SIZE (sizeof(struct nip_mdns_record)-sizeof(nip_mdns_rdata_t)) |
#define NIP_MDNS_CHECK_NAME | ( | name_ptr | ) | nip_mdns_register_name( NULL, 0, name_ptr, 0 ) |
Does name exist in list?
Definition at line 555 of file mdns.h.
Referenced by nip_mdns_disp_check_cache().
#define NIP_MDNS_COUNTER_SIZE 1 |
Byte-Size of temporary query and answer counters for transmission.
DNS defines these counters to be 16-Bit, but for internal use we can limit them to 8-Bit, as we can -- depending on available memory -- assure, that a counter value of 255 will never be exceeded. If by any chance any query/answer counter might exceed 255 you SHOULD set NIP_MDNS_COUNTER_SIZE to 2, as the program does not perform any boundary checks. Setting it to 2 will only lead to 4 additional Bytes of RAM being used, which will most probbly not hurt, if you feel able to transmit more than 255 queries or answers in one packet.
#define NIP_MDNS_CSTAT_AUTH_BIT 0x01 |
All Cache entries with the NIP_MDNS_CSTAT_AUTHORATIVE_BIT status bit set are considered authorative and will be used to reply to remote queries and will be defended upon conflicts.
Definition at line 295 of file mdns.h.
Referenced by nip_mdns_disp_check_cache().
#define NIP_MDNS_CSTAT_AUTH_MASK 0x0F |
#define NIP_MDNS_CSTAT_LEARNED_BIT 0x80 |
#define NIP_MDNS_DEFAULT_TTL 4500 |
#define NIP_MDNS_DEFAULT_TTL_A 12 |
default TTL for records with a host name \ in rname or rdata, 2min
Definition at line 115 of file mdns.h.
Referenced by nip_mdns_register_hostname().
#define NIP_MDNS_DEFEND_HOSTNAME 1 |
#define NIP_MDNS_DISCARD_ON_OUT_OF_MEMORY 1 |
#define NIP_MDNS_GET_AUTH_CSTAT | ( | item_ptr | ) | ((item_ptr)->stat & NIP_MDNS_CSTAT_AUTH_MASK) |
#define NIP_MDNS_GET_LEARNED_CSTAT | ( | item_ptr | ) | ((item_ptr)->stat & NIP_MDNS_CSTAT_LEARNED_MASK) |
#define NIP_MDNS_GET_RECORD | ( | cache_id_ptr, | |||
record_ptr | ) | nip_mdns_cache_task( NIP_MDNS_TASK_GET_LEARNED, cache_id_ptr, record_ptr ) |
#define NIP_MDNS_MAX_CACHE_SIZE 20 |
maximum number of entries in MDNS cache
Definition at line 65 of file mdns.h.
Referenced by nip_mdns_cache_task().
#define NIP_MDNS_MAX_NAME_DEPTH 6 |
The currently used system maximizes the size of MDNS names to 6 dotted parts which is the maximum size needed for IPv4 in-addr.arpa pointers.
More flexible implementations would require a more complexly programmed system of name concatenation.
Definition at line 79 of file mdns.h.
Referenced by nip_mdns_cache_task(), nip_mdns_disp_check_cache(), nip_mdns_disp_check_queries(), nip_mdns_query(), nip_mdns_register_name(), and nip_mdns_tx_name().
#define NIP_MDNS_MAX_NAMESTRING_USG (NIP_MDNS_MAX_CACHE_SIZE/2 + NIP_MDNS_MAX_QUERIES) |
#define NIP_MDNS_MAX_NAMESTRINGS 20 |
maximum number of cached DNS name strings.
The hereby meant name strings are the parts in between two dots of a DNS name, not the entire name.
Definition at line 60 of file mdns.h.
Referenced by nip_mdns_register_name().
#define NIP_MDNS_MAX_QUERIES 5 |
maximum number of open MDNS queries.
Definition at line 48 of file mdns.h.
Referenced by nip_mdns_query().
#define NIP_MDNS_NAME_USE | ( | idarr, | |||
idcnt | ) | nip_mdns_register_name( idarr, idcnt, NULL, 1 ) |
Increment name usage.
Usage of at most idcnt items in idarr will be increased by 1
Definition at line 549 of file mdns.h.
Referenced by nip_mdns_cache_task(), and nip_mdns_query().
#define NIP_MDNS_NFY_ALL (NIP_MDNS_NFY_LOCAL|NIP_MDNS_NFY_REMOTE) |
#define NIP_MDNS_NFY_REMOTE 0x40 |
#define NIP_MDNS_NO_CACHE_ID 0 |
Definition at line 168 of file mdns.h.
Referenced by nip_mdns_cache_task(), nip_mdns_disp_check_queries(), nip_mdns_fetch_results(), nip_mdns_init(), nip_mdns_notify(), and nip_mdns_register_hostname().
#define NIP_MDNS_NO_NAMESTRING 0 |
Definition at line 153 of file mdns.h.
Referenced by nip_mdns_disp_check_cache(), nip_mdns_init(), nip_mdns_register_hostname(), and nip_mdns_register_name().
#define NIP_MDNS_NO_QUERY 0x3F |
Definition at line 124 of file mdns.h.
Referenced by nip_mdns_disp_check_cache(), nip_mdns_notify(), and nip_mdns_query().
#define NIP_MDNS_NO_QUERY_TIMER 255 |
#define NIP_MDNS_OTH_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_oth)) |
#define NIP_MDNS_PROBE | ( | name | ) | nip_mdns_query( NIP_MDNS_QTYPE_PROBE, name, NIP_MDNS_TYPE_ANY ) |
#define NIP_MDNS_PROBE_COUNT 3 |
#define NIP_MDNS_PTR_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_ptr)) |
#define NIP_MDNS_QA_COUNTERS_NUMBER 4 |
number of query/answer counters
Definition at line 478 of file mdns.h.
Referenced by nip_mdns_parse_packet().
#define NIP_MDNS_QA_COUNTERS_OFFSET 4 |
#define NIP_MDNS_QTYPE_LOCAL_BIT 0x01 |
#define NIP_MDNS_QTYPE_TX_BIT 0x80 |
#define NIP_MDNS_QUERY_ACTIVE 0x00 |
#define NIP_MDNS_QUERY_ID_MASK 0x3F |
Definition at line 123 of file mdns.h.
Referenced by nip_mdns_disp_check_queries(), nip_mdns_notify(), and nip_mdns_query().
#define NIP_MDNS_QUERY_NOTIFIED | ( | c_id, | |||
q_id | ) | nip_mdns_notify( NIP_MDNS_NFYTASK_NOTIFIED, c_id, q_id, NIP_MDNS_NFY_REMOTE ) |
Cache subscriptions for (Remote) Queries will be removed upon notification.
Definition at line 580 of file mdns.h.
Referenced by nip_mdns_disp_check_queries().
#define NIP_MDNS_RDATA_PTR_SIZE sizeof(nip_mdns_namestring_id_t) |
#define NIP_MDNS_RDATA_SRV_SIZE (3*sizeof(uint16_t)+sizeof(struct nip_mdns_data_a)) |
#define NIP_MDNS_REG_NAME | ( | idarr, | |||
idcnt, | |||||
name_ptr | ) | nip_mdns_register_name( idarr, idcnt, name_ptr, 1 ) |
#define NIP_MDNS_REG_STRING | ( | name_ptr | ) | nip_mdns_register_name( NULL, 0, name_ptr, 1 ) |
Register name string.
That is just one part of a name.
Definition at line 541 of file mdns.h.
Referenced by nip_mdns_init(), and nip_mdns_register_hostname().
#define NIP_MDNS_REGISTER | ( | cache_id_ptr, | |||
record_ptr | ) | nip_mdns_cache_task( NIP_MDNS_TASK_REGISTER, cache_id_ptr, record_ptr ) |
#define NIP_MDNS_REGUNIQUE | ( | cache_id_ptr, | |||
record_ptr | ) | nip_mdns_cache_task( NIP_MDNS_TASK_REGUNIQUE, cache_id_ptr, record_ptr ) |
#define NIP_MDNS_RESET_CACHE | ( | ) | nip_mdns_cache_task( NIP_MDNS_TASK_RESET, NULL, NULL ) |
#define NIP_MDNS_SET_AUTH_CSTAT | ( | item_ptr, | |||
newstat | ) | (item_ptr)->stat = ((item_ptr)->stat & ~NIP_MDNS_CSTAT_LEARNED_MASK) | newstat |
#define NIP_MDNS_SET_LEARNED_CSTAT | ( | item_ptr, | |||
newstat | ) | (item_ptr)->stat = ((item_ptr)->stat & ~NIP_MDNS_CSTAT_LEARNED_MASK) | newstat |
#define NIP_MDNS_SRV_RECORD_SIZE (NIP_MDNS_BASE_RECORD_SIZE+sizeof(struct nip_mdns_rdata_srv)) |
#define NIP_MDNS_STRINGOFF (sizeof(nip_mdns_namestring_id_t)+sizeof(nip_mdns_namestring_usg_t)) |
#define NIP_MDNS_SUBSCRIBE_REMOTE | ( | c_id, | |||
q_id | ) | nip_mdns_notify( NIP_MDNS_NFYTASK_SUBSCRIBE, c_id, q_id, NIP_MDNS_NFY_REMOTE ) |
#define NIP_MDNS_UNREG_NAME | ( | idarr, | |||
idcnt | ) | nip_mdns_register_name( idarr, idcnt, NULL, -1 ) |
Unregister name occurence.
Usage of at most idcnt items in idarr will be decreased by 1
Definition at line 552 of file mdns.h.
Referenced by nip_mdns_cache_task(), and nip_mdns_register_hostname().
#define NIP_MDNS_UNREGISTER | ( | cache_id_ptr | ) | nip_mdns_cache_task( NIP_MDNS_TASK_UNREGISTER, cache_id_ptr, NULL ) |
#define NIP_MDNS_UNSUBSCRIBE_QUERY | ( | q_id | ) | nip_mdns_notify( NIP_MDNS_NFYTASK_UNSUBSCRIBE, NIP_MDNS_NO_CACHE_ID, q_id, NIP_MDNS_NFY_ALL ) |
#define NIP_MDNS_WRITE_NAME | ( | idarr, | |||
idcnt, | |||||
buf_ptr | ) | nip_mdns_register_name( idarr, idcnt, buf_ptr, 0 ) |
Write mdns-encoded name to buffer.
At most idcnt items of idarr will be concatenated and written to buffer.
Definition at line 560 of file mdns.h.
Referenced by nip_mdns_disp_check_queries(), and nip_mdns_tx_name().
typedef uint8_t nip_mdns_cache_cnt_t |
typedef uint8_t nip_mdns_cache_id_t |
typedef uint8_t nip_mdns_namestring_cnt_t |
typedef uint8_t nip_mdns_namestring_id_t |
typedef uint8_t nip_mdns_namestring_len_t |
typedef uint8_t nip_mdns_namestring_usg_t |
typedef uint8_t nip_mdns_qa_counter_t |
typedef uint8_t nip_mdns_query_cnt_t |
typedef uint8_t nip_mdns_query_id_t |
typedef uint8_t nip_mdns_record_size_t |
enum nip_mdns_name_task_t |
enum nip_mdns_nfy_task_t |
The lower two Bits of Packet type describe wether a Query or a Response packet will be sent.
The higher Bits are used to code additional information that is needed to determine timing and answer coding.
enum nip_mdns_qa_offset_t |
Section types in DNS packet.
The values are also used as qa_count-array item selectors and as 16-bit offsets in DNS header starting at the NIP_MDNS_QA_COUNTERS_OFFSET position of the header. DO NOT ALTER THE VALUES unless you change a whole bunch of code along with it.
Query types.
The enumeration values are chosen so that the lower two bits decide what packet type will result from the query. That is: LOCAL, PROBE and REMLOC queries will result in a Query-Packet being sent when the timer triggers. REMOTE and REMLOC queries will result in a Response-Packet being sent, whenever there are active Remote-Subscriptions. The High-order Bit indicates Queries that are actively transmitted on the network.
enum nip_mdns_status_t |
enum nip_mdns_task_t |
enum nip_mdns_type_t |
struct nip_mdns_cache* nip_mdns_cache_ptr | ( | nip_mdns_cache_id_t | id | ) | [read] |
Get pointer to specific cache entry.
Definition at line 563 of file mdns.c.
References nip_mdns_cache::id, nip_mem_ptr_t::id, NIP_E_LOCKED, NIP_E_NOT_FOUND, nip_error, NIP_MDNS_BASE_CACHE_SIZE, nip_mdns_record_size(), nip_mem_buf_used(), nip_mem_obtain_ptr(), nip_mem_release_block(), NULL, and nip_mdns_cache::record.
nip_error_t nip_mdns_cache_task | ( | nip_mdns_task_t | task, | |
nip_mdns_cache_id_t * | id, | |||
struct nip_mdns_record * | record | |||
) |
Perform mDNS cache operation.
Type of operation depends on task parameter.
record | Pointer to DNS record to be added or searched | |
task | register, learn or search record or reset cache |
Definition at line 627 of file mdns.c.
References nip_mdns_cache::age, nip_mdns_record::data, nip_mdns_cache::id, nip_mem_ptr_t::id, nip_mdns_record::name, NIP_DISP_CHECK_MDNS, nip_disp_notify, NIP_E_EXISTS, NIP_E_INTERNAL_ERROR, NIP_E_LOCKED, NIP_E_NOT_FOUND, NIP_E_OK, NIP_E_OUT_OF_MEMORY, NIP_E_OUT_OF_RESSOURCES, nip_error, NIP_MDNS_BASE_CACHE_SIZE, NIP_MDNS_CSTAT_ANNOUNCING, NIP_MDNS_CSTAT_AUTH_MASK, NIP_MDNS_CSTAT_DELETE, NIP_MDNS_CSTAT_LEARNED, NIP_MDNS_CSTAT_PROBING, NIP_MDNS_MAX_CACHE_SIZE, NIP_MDNS_MAX_NAME_DEPTH, NIP_MDNS_NAME_USE, NIP_MDNS_NO_CACHE_ID, nip_mdns_record_size(), NIP_MDNS_TASK_GET, NIP_MDNS_TASK_GET_LEARNED, NIP_MDNS_TASK_LEARN, NIP_MDNS_TASK_REGISTER, NIP_MDNS_TASK_REGUNIQUE, NIP_MDNS_TASK_RESET, NIP_MDNS_TASK_SEARCH, NIP_MDNS_TYPE_PTR, NIP_MDNS_UNREG_NAME, nip_mem_buf_used(), nip_mem_obtain_ptr(), nip_mem_ptr(), nip_mem_release_block(), nip_mem_set_used(), nip_mem_write(), nip_memcmp, nip_memcpy(), NULL, nip_mdns_name::part, nip_mem_ptr_t::ptr, nip_mdns_cache::record, nip_mdns_cache::stat, nip_mdns_record::ttl, and nip_mdns_record::type.
Referenced by nip_mdns_disp_check_queries().
nip_error_t nip_mdns_close | ( | nip_mdns_query_id_t | r_id | ) |
void nip_mdns_disp_check | ( | void | ) |
Dispatcher function to be called upon receiving mDNS events.
Definition at line 1838 of file mdns.c.
References nip_udp_sock_addr::ip, NIP_CURR_CMD, NIP_DNS_OP_MASK, NIP_DNS_QR_MASK, NIP_DNS_RC_MASK, NIP_E_OK, NIP_IP_ADDR, nip_mdns, nip_mdns_disp_check_cache(), nip_mdns_disp_check_queries(), nip_mdns_if_id, nip_mdns_init(), NIP_MDNS_NSCOUNT_OFFSET, NIP_MDNS_PTYPE_NONE, NIP_MDNS_PTYPE_PROBE, NIP_MDNS_PTYPE_QUERY, NIP_MDNS_PTYPE_RESPONSE, NIP_MDNS_QDCOUNT_OFFSET, nip_mdns_sock, NIP_MDNS_STAT_CACHE_CHECK, NIP_MDNS_STAT_DOWN, NIP_MDNS_STAT_INIT, NIP_MDNS_STAT_QUERY_CHECK, nip_memcmp, nip_udp_cancel_recv(), nip_udp_data_ptr(), NIP_UDP_NO_SOCKET, nip_udp_ptr_release(), nip_udp_recvfrom(), NIP_UDP_RX_BUF, NULL, nip_dns_header::qa_count, nip_dns_header::qr_opcode_aa_tc_rd, nip_dns_header::ra_z_ad_cd_rcode, nip_mdns_check::recv, nip_mdns_check::recv_size, and nip_mdns_check::stat.
nip_mdns_cache_id_t nip_mdns_fetch_results | ( | nip_mdns_query_id_t | r_id | ) |
Fetch next result for lookup query.
This function has to be called repeatedly, to fetch all results until nip_mdns_close() is called.
r_id | ID of query to fetch result from |
Definition at line 901 of file mdns.c.
References NIP_MDNS_NO_CACHE_ID.
nip_error_t nip_mdns_init | ( | void | ) |
initialize mdns memory
Definition at line 63 of file mdns.c.
References nip_mem_ptr_t::id, NIP_E_NOT_CONFIGURED, NIP_E_OK, NIP_E_OUT_OF_MEMORY, nip_error, NIP_IP_ADDR, nip_ip_join_host_group(), nip_mdns, NIP_MDNS_ADDR0, NIP_MDNS_ADDR1, NIP_MDNS_ADDR2, NIP_MDNS_ADDR3, nip_mdns_cs, nip_mdns_domain, nip_mdns_hostname, nip_mdns_if_id, nip_mdns_names, NIP_MDNS_NO_CACHE_ID, NIP_MDNS_NO_NAMESTRING, NIP_MDNS_REG_STRING, nip_mdns_register_hostname(), nip_mdns_sock, NIP_MDNS_STAT_DOWN, nip_mem_alloc(), NIP_MEM_NULL, nip_memcpy(), NIP_NET_NO_IF, NIP_UDP_NO_SOCKET, NIP_UDP_PORT_MDNS, NIP_UDP_SOCK_FLG_LISTENING, NIP_UDP_SOCK_FLG_NON_BLOCK, nip_udp_socket(), NULL, nip_mem_ptr_t::ptr, and nip_mdns_check::stat.
Referenced by nip_init(), and nip_mdns_disp_check().
void nip_mdns_interface_down | ( | void | ) |
Definition at line 1052 of file mdns.c.
References nip_mdns, nip_mdns_if_id, nip_mdns_sock, NIP_MDNS_STAT_DOWN, NIP_NET_NO_IF, nip_udp_close(), and nip_mdns_check::stat.
void nip_mdns_interface_up | ( | nip_net_if_id_t | if_id | ) |
Register host name and refresh cache.
Definition at line 1039 of file mdns.c.
References NIP_DISP_CHECK_MDNS, nip_disp_notify, nip_mdns, nip_mdns_if_id, NIP_MDNS_RESET_CACHE, NIP_MDNS_STAT_INIT, and nip_mdns_check::stat.
nip_mdns_query_id_t nip_mdns_query | ( | nip_mdns_query_type_t | type, | |
struct nip_mdns_name * | rr_name, | |||
nip_mdns_type_t | rr_type | |||
) |
Execute MDNS lookup query.
The query will be registered within the system and a query ID will be returned. That query has to be ultimately closed by calling nip_mdns_close(). Answers to the query can be polled by calling nip_mdns_fetch_results().
name | pointer to DNS name | |
type | DNS type |
Definition at line 440 of file mdns.c.
References nip_mdns_query::id, nip_mem_ptr_t::id, NIP_E_OK, NIP_MDNS_MAX_NAME_DEPTH, NIP_MDNS_MAX_QUERIES, NIP_MDNS_NAME_USE, NIP_MDNS_NO_QUERY, NIP_MDNS_QTYPE_LOCAL, NIP_MDNS_QTYPE_PROBE, NIP_MDNS_QTYPE_REMLOC, NIP_MDNS_QTYPE_REMOTE, NIP_MDNS_QUERY_ACTIVE, NIP_MDNS_QUERY_ID_MASK, nip_mem_buf_used(), nip_mem_obtain_ptr(), nip_mem_release_block(), nip_mem_write(), nip_memcmp, NULL, nip_mdns_query::rr_name, nip_mdns_query::rr_type, nip_mdns_query::timer, and nip_mdns_query::type.
Referenced by nip_mdns_disp_check_cache().
nip_mdns_namestring_id_t nip_mdns_register_name | ( | nip_mdns_namestring_id_t * | id, | |
uint8_t | cnt, | |||
nip_mem_ptr_t * | name_ptr, | |||
nip_mdns_namestring_usg_t | usg | |||
) |
Registers new MDNS namestring or retrieves already registered entry for that name.
The namestring's usage counter will be increased for every call of nip_mdns_register_name(). This function may also be used to unregister a previously registered namestring by providing a negative usage count.
id | if set, the usage counter for that namestring will be increased and name and len parameter will be ignored. | |
cnt | if > 1, id will be treated as array of namestrings to be registered. Must be 0 if id is not set. | |
name_ptr | pointer to buffer holding the name. If id is set, the found name(s) will be appended to that buffer, preceded by their length. The pointer has to point to a nip_dns_string structure. | |
len | length of name | |
usg | number of string usages to register (negative to unregister) |
The function's result depends very much on the correct combination of the various parameters. Those are chosen to be as minimal as possible, which will most probably lead to erroneous usage of the function. You SHOULD NOT call this function directly but use the provided macros, which, depending on the provided function, require only a subset of the parameters to be set.
Definition at line 258 of file mdns.c.
References nip_mdns_namestring::id, nip_mem_ptr_t::id, nip_dns_string::len, NIP_E_OK, NIP_MDNS_MAX_NAME_DEPTH, NIP_MDNS_MAX_NAMESTRINGS, nip_mdns_name_cmp(), nip_mdns_names, NIP_MDNS_NO_NAMESTRING, NIP_MDNS_STRINGOFF, nip_mem_buf_used(), nip_mem_insert(), NIP_MEM_NULL, nip_mem_ptr(), nip_mem_release_block(), nip_mem_release_ptr(), nip_mem_set_used(), nip_mem_write(), nip_memcpy(), NULL, nip_mem_ptr_t::ptr, nip_dns_string::s, nip_mdns_namestring::str, and nip_mdns_namestring::usg.