-
Notifications
You must be signed in to change notification settings - Fork 220
Expand file tree
/
Copy pathAmsRouter.h
More file actions
54 lines (45 loc) · 1.74 KB
/
AmsRouter.h
File metadata and controls
54 lines (45 loc) · 1.74 KB
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
48
49
50
51
52
53
54
// SPDX-License-Identifier: MIT
/**
Copyright (c) 2015 - 2022 Beckhoff Automation GmbH & Co. KG
*/
#pragma once
#include "AmsConnection.h"
#include <atomic>
#include <unordered_set>
struct AmsRouter : Router {
AmsRouter(AmsNetId netId = AmsNetId{});
uint16_t OpenPort();
long ClosePort(uint16_t port);
long GetLocalAddress(uint16_t port, AmsAddr *pAddr);
void SetLocalAddress(AmsNetId netId);
long GetTimeout(uint16_t port, uint32_t &timeout);
long SetTimeout(uint16_t port, uint32_t timeout);
long AddNotification(AmsRequest &request, uint32_t *pNotification,
std::shared_ptr<Notification> notify);
long DelNotification(uint16_t port, const AmsAddr *pAddr,
uint32_t hNotification);
long AddSyntheticNotification(uint16_t port, const AmsAddr &addr, uint32_t *pNotification,
std::shared_ptr<SyntheticNotification> notify);
long DelSyntheticNotification(uint16_t port, const AmsAddr *pAddr,
uint32_t hNotification);
uint32_t AllocateNotifyId();
[[deprecated]]
long AddRoute(AmsNetId ams, const IpV4 &ip);
long AddRoute(AmsNetId ams, const std::string &host);
void DelRoute(const AmsNetId &ams);
AmsConnection *GetConnection(const AmsNetId &pAddr);
long AdsRequest(AmsRequest &request);
private:
AmsNetId localAddr;
std::recursive_mutex mutex;
std::condition_variable_any connection_attempt_events;
std::map<AmsNetId, std::tuple<> > connection_attempts;
std::unordered_set<std::unique_ptr<AmsConnection> > connections;
std::map<AmsNetId, AmsConnection *> mapping;
void
AwaitConnectionAttempts(const AmsNetId &ams,
std::unique_lock<std::recursive_mutex> &lock);
void DeleteIfLastConnection(const AmsConnection *conn);
std::array<AmsPort, NUM_PORTS_MAX> ports;
std::atomic<uint32_t> nextNotifyId;
};