open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
ua_discovery_manager.h
Go to the documentation of this file.
1/** This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 *
5 * Copyright 2014-2018 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
6 * Copyright 2014, 2017 (c) Florian Palm
7 * Copyright 2015-2016 (c) Sten GrĂ¼ner
8 * Copyright 2015 (c) Chris Iatrou
9 * Copyright 2015-2016 (c) Oleksiy Vasylyev
10 * Copyright 2016-2017 (c) Stefan Profanter, fortiss GmbH
11 * Copyright 2017 (c) Julian Grothoff
12 */
13
14#ifndef UA_DISCOVERY_MANAGER_H_
15#define UA_DISCOVERY_MANAGER_H_
16
17#include <open62541/server.h>
18
19#include "open62541_queue.h"
20
22
23#ifdef UA_ENABLE_DISCOVERY
24
30
39
44
45#ifdef UA_ENABLE_DISCOVERY_MULTICAST
46
48
49
50
51typedef struct serverOnNetwork_list_entry {
52 LIST_ENTRY(serverOnNetwork_list_entry) pointers;
53 UA_ServerOnNetwork serverOnNetwork;
54 UA_DateTime created;
55 UA_DateTime lastSeen;
56 UA_Boolean txtSet;
57 UA_Boolean srvSet;
58 char* pathTmp;
59} serverOnNetwork_list_entry;
60
61#define SERVER_ON_NETWORK_HASH_SIZE 1000
62typedef struct serverOnNetwork_hash_entry {
63 serverOnNetwork_list_entry* entry;
64 struct serverOnNetwork_hash_entry* next;
65} serverOnNetwork_hash_entry;
66
67#endif
68
69typedef struct {
70 LIST_HEAD(, periodicServerRegisterCallback_entry) periodicServerRegisterCallbacks;
75
76# ifdef UA_ENABLE_DISCOVERY_MULTICAST
77 mdns_daemon_t *mdnsDaemon;
78 UA_SOCKET mdnsSocket;
79 UA_Boolean mdnsMainSrvAdded;
80
81 /* Full Domain Name of server itself. Used to detect if received mDNS message was from itself */
82 UA_String selfFqdnMdnsRecord;
83
84 LIST_HEAD(, serverOnNetwork_list_entry) serverOnNetwork;
85
86 UA_UInt32 serverOnNetworkRecordIdCounter;
87 UA_DateTime serverOnNetworkRecordIdLastReset;
88
89 /* hash mapping domain name to serverOnNetwork list entry */
90 struct serverOnNetwork_hash_entry* serverOnNetworkHash[SERVER_ON_NETWORK_HASH_SIZE];
91
92 UA_Server_serverOnNetworkCallback serverOnNetworkCallback;
93 void* serverOnNetworkCallbackData;
94
95#if UA_MULTITHREADING >= 100
96 pthread_t mdnsThread;
97 UA_Boolean mdnsRunning;
98# endif
99# endif /* UA_ENABLE_DISCOVERY_MULTICAST */
101
104
105/** Checks if a registration timed out and removes that registration.
106 * Should be called periodically in main loop */
108
109#ifdef UA_ENABLE_DISCOVERY_MULTICAST
110
111
112void
113UA_Server_updateMdnsForDiscoveryUrl(UA_Server *server, const UA_String *serverName,
114 const UA_MdnsDiscoveryConfiguration *mdnsConfig,
115 const UA_String *discoveryUrl,
116 UA_Boolean isOnline, UA_Boolean updateTxt);
117
118void mdns_record_received(const struct resource *r, void *data);
119
120void mdns_create_txt(UA_Server *server, const char *fullServiceDomain,
121 const char *path, const UA_String *capabilites,
122 const size_t capabilitiesSize,
123 void (*conflict)(char *host, int type, void *arg));
124
125void mdns_set_address_record(UA_Server *server,
126 const char *fullServiceDomain,
127 const char *localDomain);
128
130mdns_find_record(mdns_daemon_t *mdnsDaemon, unsigned short type,
131 const char *host, const char *rdname);
132
134initMulticastDiscoveryServer(UA_DiscoveryManager *dm, UA_Server* server);
135
136void startMulticastDiscoveryServer(UA_Server *server);
137
138void stopMulticastDiscoveryServer(UA_Server *server);
139
141iterateMulticastDiscoveryServer(UA_Server* server, UA_DateTime *nextRepeat,
142 UA_Boolean processIn);
143
144typedef enum {
145 UA_DISCOVERY_TCP, /* OPC UA TCP mapping */
146 UA_DISCOVERY_TLS /* OPC UA HTTPS mapping */
147} UA_DiscoveryProtocol;
148
149/** Send a multicast probe to find any other OPC UA server on the network through mDNS. */
151UA_Discovery_multicastQuery(UA_Server* server);
152
153
155UA_Discovery_addRecord(UA_Server *server, const UA_String *servername,
156 const UA_String *hostname, UA_UInt16 port,
157 const UA_String *path, const UA_DiscoveryProtocol protocol,
158 UA_Boolean createTxt, const UA_String* capabilites,
159 const size_t capabilitiesSize,
160 UA_Boolean isSelf);
161
162
164UA_DiscoveryManager_addEntryToServersOnNetwork(UA_Server *server, const char *fqdnMdnsRecord, const char *serverName,
165 size_t serverNameLen, struct serverOnNetwork_list_entry **addedEntry);
166
167
169UA_Discovery_removeRecord(UA_Server *server, const UA_String *servername,
170 const UA_String *hostname, UA_UInt16 port,
171 UA_Boolean removeTxt);
172
173
175UA_DiscoveryManager_removeEntryFromServersOnNetwork(UA_Server *server, const char *fqdnMdnsRecord, const char *serverName,
176 size_t serverNameLen);
177
178
179#endif /* UA_ENABLE_DISCOVERY_MULTICAST */
180
181#endif /* UA_ENABLE_DISCOVERY */
182
184
185#endif /* UA_DISCOVERY_MANAGER_H_ */
#define _UA_BEGIN_DECLS
#undef UA_DEBUG_DUMP_PKGS
Definition config.h:89
#define _UA_END_DECLS
Definition config.h:96
struct mdns_record mdns_record_t
Record entry.
Definition mdnsd.h:68
struct mdns_daemon mdns_daemon_t
Main daemon data.
Definition mdnsd.h:66
#define LIST_HEAD(name, type)
#define LIST_ENTRY(type)
void(* UA_Server_registerServerCallback)(const UA_RegisteredServer *registeredServer, void *data)
Callback for RegisterServer.
Definition server.h:807
UA_Server_registerServerCallback registerServerCallback
LIST_HEAD(, periodicServerRegisterCallback_entry) periodicServerRegisterCallbacks
LIST_HEAD(, registeredServer_list_entry) registeredServers
struct PeriodicServerRegisterCallback * callback
LIST_ENTRY(periodicServerRegisterCallback_entry) pointers
This Source Code Form is subject to the terms of the Mozilla Public License, v.
UA_RegisteredServer registeredServer
UA_DateTime lastSeen
LIST_ENTRY(registeredServer_list_entry) pointers
_UA_BEGIN_DECLS typedef bool UA_Boolean
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition types.h:26
uint16_t UA_UInt16
Definition types.h:46
uint32_t UA_UInt32
Definition types.h:56
int64_t UA_DateTime
Definition types.h:144
uint32_t UA_StatusCode
Definition types.h:77
double UA_Double
Definition types.h:74
uint64_t UA_UInt64
Definition types.h:66
void UA_DiscoveryManager_init(UA_DiscoveryManager *dm, UA_Server *server)
_UA_BEGIN_DECLS struct registeredServer_list_entry registeredServer_list_entry
This Source Code Form is subject to the terms of the Mozilla Public License, v.
struct periodicServerRegisterCallback_entry periodicServerRegisterCallback_entry
void UA_DiscoveryManager_clear(UA_DiscoveryManager *dm, UA_Server *server)
void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic)
Checks if a registration timed out and removes that registration.
#define UA_SOCKET
Definition ua_lwip.h:31