Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ns_mdns_api.h Source File

ns_mdns_api.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _NS_MDNS_API_H_
00019 #define _NS_MDNS_API_H_
00020 
00021 /**
00022  * \file ns_mdns_api.h
00023  * \brief Nanostack mDNS-SD API.
00024  */
00025 
00026 /*!
00027  * \struct ns_mdns_t
00028  * \brief Structure for Nanostack mDNS instance
00029  */
00030 typedef struct ns_mdns *ns_mdns_t;  /**< Instance */
00031 
00032 /*!
00033  * \struct ns_mdns_service_t
00034  * \brief Structure for Nanostack mDNS service instance
00035  */
00036 typedef struct ns_mdns_service *ns_mdns_service_t;  /**< Service instance */
00037 
00038 /*!
00039  * \struct ns_mdns_service_param_t
00040  * \brief Structure for mDNS service parameters
00041  */
00042 typedef struct ns_mdns_service_param
00043 {
00044     const char *service_type;                   /**< Null-terminated string owned by the caller */
00045     uint16_t    service_port;                   /**< Service Port number */
00046     const uint8_t *(*service_get_txt)(void);    /**< Call-back function, which returns a pointer to the service TXT record (null-terminated).
00047                                                    If the service does not provide any TXT record, this parameter must be set to NULL. */
00048 } ns_mdns_service_param_t;
00049 
00050 /**
00051  * \brief Start mDNS server
00052  *
00053  * \param server_name NULL terminated string, max length 63 characters
00054  *
00055  * \param ttl time-to-live value in seconds, if set to 0 default value is used
00056  *
00057  * \param ttl_ip time-to-live in hop count, if set to 0 default value is used
00058  *
00059  * \param interface_id ID of the network interface where mDNS will operate
00060  *
00061  * \return mDNS server instace or NULL in case of failure..
00062  */
00063 ns_mdns_t ns_mdns_server_start(const char *server_name, uint32_t ttl, uint32_t ttl_ip, int8_t interface_id);
00064 
00065 /**
00066  * \brief Stop mDNS server
00067  *
00068  * \param ns_mdns_instance Server instance received from ns_mdns_server_start
00069  *
00070  */
00071 void ns_mdns_server_stop(ns_mdns_t ns_mdns_instance);
00072 
00073 /**
00074  * \brief Register service to mDNS server
00075  *
00076  * \param ns_mdns_instance Server instance received from ns_mdns_server_start
00077  *
00078  * \param service Parameters for service
00079  *
00080  * \return mDNS Service descriptor or NULL in case of failure.
00081  *
00082  */
00083 ns_mdns_service_t ns_mdns_service_register(ns_mdns_t ns_mdns_instance, ns_mdns_service_param_t *service);
00084 
00085 /**
00086  * \brief Unregister service from mDNS server
00087  *
00088  * \param service_desc mDNS Service descriptor received from call to ns_mdns_service_register.
00089  */
00090 
00091 void ns_mdns_service_unregister(ns_mdns_service_t service_desc);
00092 
00093 /**
00094  * \brief Send mDNS announcement. Application should call this method once application
00095  * advertised parameters has changed.
00096  *
00097  * \param ns_mdns_instance Server instance received from ns_mdns_server_start
00098  */
00099 
00100 void ns_mdns_announcement_send(ns_mdns_t ns_mdns_instance);
00101 
00102 #endif /* _NS_MDNS_API_H_ */
00103