[457] | 1 | /*
|
---|
| 2 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
| 3 | * are permitted provided that the following conditions are met:
|
---|
| 4 | *
|
---|
| 5 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
| 6 | * this list of conditions and the following disclaimer.
|
---|
| 7 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
| 8 | * this list of conditions and the following disclaimer in the documentation
|
---|
| 9 | * and/or other materials provided with the distribution.
|
---|
| 10 | * 3. The name of the author may not be used to endorse or promote products
|
---|
| 11 | * derived from this software without specific prior written permission.
|
---|
| 12 | *
|
---|
| 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
---|
| 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
| 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
---|
| 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
| 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
---|
| 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
| 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
| 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
| 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
---|
| 22 | * OF SUCH DAMAGE.
|
---|
| 23 | *
|
---|
| 24 | * This file is part of the lwIP TCP/IP stack.
|
---|
| 25 | *
|
---|
| 26 | * Author: Dirk Ziegelmeier <dziegel@gmx.de>
|
---|
| 27 | *
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | #include "lwip/apps/mdns.h"
|
---|
| 31 | #include "mdns_example.h"
|
---|
| 32 |
|
---|
| 33 | #if LWIP_MDNS_RESPONDER
|
---|
| 34 | static void
|
---|
| 35 | srv_txt(struct mdns_service *service, void *txt_userdata)
|
---|
| 36 | {
|
---|
| 37 | err_t res;
|
---|
| 38 | LWIP_UNUSED_ARG(txt_userdata);
|
---|
| 39 |
|
---|
| 40 | res = mdns_resp_add_service_txtitem(service, "path=/", 6);
|
---|
| 41 | LWIP_ERROR("mdns add service txt failed\n", (res == ERR_OK), return);
|
---|
| 42 | }
|
---|
| 43 | #endif
|
---|
| 44 |
|
---|
| 45 | #if LWIP_MDNS_RESPONDER
|
---|
| 46 | static void
|
---|
| 47 | mdns_example_report(struct netif* netif, u8_t result)
|
---|
| 48 | {
|
---|
| 49 | LWIP_PLATFORM_DIAG(("mdns status[netif %d]: %d\n", netif->num, result));
|
---|
| 50 | }
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | void
|
---|
| 54 | mdns_example_init(void)
|
---|
| 55 | {
|
---|
| 56 | #if LWIP_MDNS_RESPONDER
|
---|
| 57 | mdns_resp_register_name_result_cb(mdns_example_report);
|
---|
| 58 | mdns_resp_init();
|
---|
| 59 | mdns_resp_add_netif(netif_default, "lwip", 3600);
|
---|
| 60 | mdns_resp_add_service(netif_default, "myweb", "_http", DNSSD_PROTO_TCP, 80, 3600, srv_txt, NULL);
|
---|
| 61 | mdns_resp_announce(netif_default);
|
---|
| 62 | #endif
|
---|
| 63 | }
|
---|