Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mdns.h Source File

mdns.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * MDNS responder
00004  */
00005 
00006  /*
00007  * Copyright (c) 2015 Verisure Innovation AB
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without modification,
00011  * are permitted provided that the following conditions are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright notice,
00014  *    this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright notice,
00016  *    this list of conditions and the following disclaimer in the documentation
00017  *    and/or other materials provided with the distribution.
00018  * 3. The name of the author may not be used to endorse or promote products
00019  *    derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00023  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00024  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00026  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00029  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00030  * OF SUCH DAMAGE.
00031  *
00032  * This file is part of the lwIP TCP/IP stack.
00033  *
00034  * Author: Erik Ekman <erik@kryo.se>
00035  *
00036  */
00037 
00038 #ifndef LWIP_HDR_APPS_MDNS_H
00039 #define LWIP_HDR_APPS_MDNS_H
00040 
00041 #include "lwip/apps/mdns_opts.h"
00042 #include "lwip/netif.h"
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 #if LWIP_MDNS_RESPONDER
00049 
00050 enum mdns_sd_proto {
00051   DNSSD_PROTO_UDP = 0,
00052   DNSSD_PROTO_TCP = 1
00053 };
00054 
00055 #define MDNS_PROBING_CONFLICT   0
00056 #define MDNS_PROBING_SUCCESSFUL 1
00057 
00058 #define MDNS_LABEL_MAXLEN  63
00059 
00060 struct mdns_host;
00061 struct mdns_service;
00062 
00063 /** Callback function to add text to a reply, called when generating the reply */
00064 typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata);
00065 
00066 /** Callback function to let application know the result of probing network for name
00067  * uniqueness, called with result MDNS_PROBING_SUCCESSFUL if no other node claimed
00068  * use for the name for the netif or a service and is safe to use, or MDNS_PROBING_CONFLICT
00069  * if another node is already using it and mdns is disabled on this interface */
00070 typedef void (*mdns_name_result_cb_t)(struct netif* netif, u8_t result);
00071 
00072 void mdns_resp_init(void);
00073 
00074 void mdns_resp_register_name_result_cb(mdns_name_result_cb_t cb);
00075 
00076 err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl);
00077 err_t mdns_resp_remove_netif(struct netif *netif);
00078 err_t mdns_resp_rename_netif(struct netif *netif, const char *hostname);
00079 
00080 s8_t  mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
00081 err_t mdns_resp_del_service(struct netif *netif, s8_t slot);
00082 err_t mdns_resp_rename_service(struct netif *netif, s8_t slot, const char *name);
00083 
00084 err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len);
00085 
00086 void mdns_resp_restart(struct netif *netif);
00087 void mdns_resp_announce(struct netif *netif);
00088 
00089 /**
00090  * @ingroup mdns
00091  * Announce IP settings have changed on netif.
00092  * Call this in your callback registered by netif_set_status_callback().
00093  * No need to call this function when LWIP_NETIF_EXT_STATUS_CALLBACK==1,
00094  * this handled automatically for you.
00095  * @param netif The network interface where settings have changed.
00096  */
00097 #define mdns_resp_netif_settings_changed(netif) mdns_resp_announce(netif)
00098 
00099 #endif /* LWIP_MDNS_RESPONDER */
00100 
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104 
00105 #endif /* LWIP_HDR_APPS_MDNS_H */