Jason Jeremy Iman | 429b079 | 2020-03-13 15:34:16 +0900 | [diff] [blame] | 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 5 | #ifndef PATCHPANEL_MULTICAST_PROXY_H_ |
| 6 | #define PATCHPANEL_MULTICAST_PROXY_H_ |
Jason Jeremy Iman | 429b079 | 2020-03-13 15:34:16 +0900 | [diff] [blame] | 7 | |
| 8 | #include <map> |
| 9 | #include <memory> |
| 10 | #include <string> |
| 11 | |
| 12 | #include <brillo/daemons/daemon.h> |
| 13 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 14 | #include "patchpanel/broadcast_forwarder.h" |
| 15 | #include "patchpanel/message_dispatcher.h" |
| 16 | #include "patchpanel/multicast_forwarder.h" |
Jason Jeremy Iman | 429b079 | 2020-03-13 15:34:16 +0900 | [diff] [blame] | 17 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 18 | namespace patchpanel { |
Jason Jeremy Iman | 429b079 | 2020-03-13 15:34:16 +0900 | [diff] [blame] | 19 | |
| 20 | // MulticastProxy manages multiple MulticastForwarder instances to forward |
| 21 | // multicast for multiple physical interfaces. |
| 22 | class MulticastProxy : public brillo::Daemon { |
| 23 | public: |
| 24 | explicit MulticastProxy(base::ScopedFD control_fd); |
| 25 | virtual ~MulticastProxy() = default; |
| 26 | |
| 27 | protected: |
| 28 | int OnInit() override; |
| 29 | |
| 30 | void OnParentProcessExit(); |
| 31 | void OnDeviceMessage(const DeviceMessage& msg); |
| 32 | |
| 33 | private: |
| 34 | void Reset(); |
| 35 | |
| 36 | MessageDispatcher msg_dispatcher_; |
| 37 | std::map<std::string, std::unique_ptr<MulticastForwarder>> mdns_fwds_; |
| 38 | std::map<std::string, std::unique_ptr<MulticastForwarder>> ssdp_fwds_; |
| 39 | std::map<std::string, std::unique_ptr<BroadcastForwarder>> bcast_fwds_; |
| 40 | |
| 41 | base::WeakPtrFactory<MulticastProxy> weak_factory_{this}; |
| 42 | DISALLOW_COPY_AND_ASSIGN(MulticastProxy); |
| 43 | }; |
| 44 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 45 | } // namespace patchpanel |
Jason Jeremy Iman | 429b079 | 2020-03-13 15:34:16 +0900 | [diff] [blame] | 46 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 47 | #endif // PATCHPANEL_MULTICAST_PROXY_H_ |