ReactOS 0.4.16-dev-258-g81860b4
mdns_priv.h
Go to the documentation of this file.
1
6 /*
7 * Copyright (c) 2015 Verisure Innovation AB
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 *
32 * This file is part of the lwIP TCP/IP stack.
33 *
34 * Author: Erik Ekman <erik@kryo.se>
35 * Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
36 *
37 */
38#ifndef LWIP_HDR_MDNS_PRIV_H
39#define LWIP_HDR_MDNS_PRIV_H
40
41#include "lwip/apps/mdns.h"
42#include "lwip/apps/mdns_opts.h"
43#include "lwip/pbuf.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#if LWIP_MDNS_RESPONDER
50
51#define MDNS_READNAME_ERROR 0xFFFF
52#define NUM_DOMAIN_OFFSETS 10
53
54#define SRV_PRIORITY 0
55#define SRV_WEIGHT 0
56
57/* mDNS TTL: (RFC6762 section 10)
58 * - 120 seconds if the hostname appears somewhere in the RR
59 * - 75 minutes if not (4500 seconds)
60 * - 10 seconds if responding to a legacy query
61 */
62#define MDNS_TTL_10 10
63#define MDNS_TTL_120 120
64#define MDNS_TTL_4500 4500
65
66/* RFC6762 section 8.1: If fifteen conflicts occur within any ten-second period,
67 * then the host MUST wait at least five seconds before each successive
68 * additional probe attempt.
69 */
70#define MDNS_PROBE_MAX_CONFLICTS_BEFORE_RATE_LIMIT 15
71#define MDNS_PROBE_MAX_CONFLICTS_TIME_WINDOW 10000
72#define MDNS_PROBE_MAX_CONFLICTS_TIMEOUT 5000
73
74#if LWIP_MDNS_SEARCH
76struct mdns_request {
78 char name[MDNS_LABEL_MAXLEN + 1];
80 struct mdns_domain service;
82 search_result_fn_t result_fn;
83 void *arg;
87 u8_t qtype;
89 u16_t only_ptr;
90};
91#endif
92
94struct mdns_service {
96 struct mdns_domain txtdata;
98 char name[MDNS_LABEL_MAXLEN + 1];
100 char service[MDNS_LABEL_MAXLEN + 1];
103 service_get_txt_fn_t txt_fn;
104 void *txt_userdata;
106 u16_t proto;
108 u16_t port;
109};
110
112struct mdns_outpacket {
114 struct pbuf *pbuf;
116 u16_t write_offset;
118 u16_t questions;
120 u16_t answers;
122 u16_t authoritative;
124 u16_t additional;
127 u16_t domain_offsets[NUM_DOMAIN_OFFSETS];
128};
129
131struct mdns_outmsg {
133 u16_t tx_id;
135 u8_t flags;
137 ip_addr_t dest_addr;
138 u16_t dest_port;
140 u8_t cache_flush;
142 u8_t unicast_reply_requested;
145 u8_t legacy_query;
148 u8_t probe_query_recv;
149 /* Question bitmask for host information */
150 u8_t host_questions;
151 /* Questions bitmask per service */
152 u8_t serv_questions[MDNS_MAX_SERVICES];
153 /* Reply bitmask for host information */
154 u8_t host_replies;
155 /* Bitmask for which reverse IPv6 hosts to answer */
156 u8_t host_reverse_v6_replies;
157 /* Reply bitmask per service */
158 u8_t serv_replies[MDNS_MAX_SERVICES];
159#ifdef LWIP_MDNS_SEARCH
161 struct mdns_request *query;
162#endif
163};
164
166struct mdns_delayed_msg {
168 u8_t multicast_msg_waiting;
170 u8_t multicast_timeout;
172 u8_t multicast_probe_timeout;
174 struct mdns_outmsg delayed_msg_multicast;
177 u8_t multicast_timeout_25TTL;
179 u8_t unicast_msg_in_use;
181 struct mdns_outmsg delayed_msg_unicast;
182};
183
184/* MDNS states */
185typedef enum {
186 /* MDNS module is off */
187 MDNS_STATE_OFF,
188 /* Waiting before probing can be started */
189 MDNS_STATE_PROBE_WAIT,
190 /* Probing the unique records */
191 MDNS_STATE_PROBING,
192 /* Waiting before announcing the probed unique records */
193 MDNS_STATE_ANNOUNCE_WAIT,
194 /* Announcing all records */
195 MDNS_STATE_ANNOUNCING,
196 /* Probing and announcing completed */
197 MDNS_STATE_COMPLETE
198} mdns_resp_state_enum_t;
199
201struct mdns_host {
203 char name[MDNS_LABEL_MAXLEN + 1];
205 struct mdns_service *services[MDNS_MAX_SERVICES];
207 u8_t sent_num;
209 mdns_resp_state_enum_t state;
210#if LWIP_IPV4
212 struct mdns_delayed_msg ipv4;
213#endif
214#if LWIP_IPV6
216 struct mdns_delayed_msg ipv6;
217#endif
219 u32_t conflict_time[MDNS_PROBE_MAX_CONFLICTS_BEFORE_RATE_LIMIT];
221 u8_t rate_limit_activated;
223 u8_t index;
225 u8_t num_conflicts;
226};
227
228struct mdns_host* netif_mdns_data(struct netif *netif);
229struct udp_pcb* get_mdns_pcb(void);
230
231#endif /* LWIP_MDNS_RESPONDER */
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif /* LWIP_HDR_MDNS_PRIV_H */
static int state
Definition: maze.c:121
#define index(s, c)
Definition: various.h:29
USHORT port
Definition: uri.c:228
GLbitfield flags
Definition: glext.h:7161
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
#define MDNS_MAX_SERVICES
Definition: mdns_opts.h:60
ip6_addr_t ip_addr_t
Definition: ip_addr.h:344
Definition: name.c:39
Definition: netif.h:269
Definition: pbuf.h:186
void * arg
Definition: msvc.h:10