~thestr4ng3r/chiaki

ref: 796a12845684afe5c4b194d4111bcdcf5b04aca2 chiaki/switch/include/discoverymanager.h -rw-r--r-- 975 bytes
796a1284Florian Märkl Fix fec.c extension 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL

#ifndef CHIAKI_DISCOVERYMANAGER_H
#define CHIAKI_DISCOVERYMANAGER_H

#include <map>
#include <string>

#include <chiaki/discoveryservice.h>
#include <chiaki/log.h>

#include "host.h"
#include "settings.h"

static void Discovery(ChiakiDiscoveryHost *, void *);

class DiscoveryManager
{
	private:
		Settings * settings = nullptr;
		ChiakiLog * log = nullptr;
		ChiakiDiscoveryService service;
		ChiakiDiscovery discovery;
		struct sockaddr * host_addr = nullptr;
		size_t host_addr_len = 0;
		uint32_t GetIPv4BroadcastAddr();
		bool service_enable = false;

	public:
		typedef enum hoststate
		{
			UNKNOWN,
			READY,
			STANDBY,
			SHUTDOWN,
		} HostState;

		DiscoveryManager();
		~DiscoveryManager();
		void SetService(bool);
		int Send();
		int Send(struct sockaddr * host_addr, size_t host_addr_len);
		int Send(const char *);
		void DiscoveryCB(ChiakiDiscoveryHost *);
};

#endif //CHIAKI_DISCOVERYMANAGER_H