| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 4 | * 2013-2022 by the Falcon Player Developers. | ||
| 5 | * | ||
| 6 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 7 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 8 | * file for descriptions of what files are covered by each license. | ||
| 9 | * | ||
| 10 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 11 | * included LICENSE.LGPL file. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <functional> | ||
| 15 | #include <map> | ||
| 16 | #include <string> | ||
| 17 | |||
| 18 | #include "MultiSync.h" | ||
| 19 | |||
| 20 | class NetworkController { | ||
| 21 | public: | ||
| 22 | NetworkController(const std::string& ipStr); | ||
| 23 | 261 | ~NetworkController(){}; | |
| 24 | |||
| 25 | // Works out what is answering at `ip` from the page it served, asking the | ||
| 26 | // device follow-up questions where the HTML alone cannot tell (most vendors | ||
| 27 | // need one; the Experience line needs up to three, in sequence). Those all | ||
| 28 | // go through CurlManager, so nothing here blocks. | ||
| 29 | // | ||
| 30 | // `callback` is invoked exactly once, with a heap-allocated | ||
| 31 | // NetworkController the callback owns and must delete, or nullptr if | ||
| 32 | // nothing claimed the device. It may run inline, before this returns -- | ||
| 33 | // that is the normal path for the vendors the HTML alone identifies | ||
| 34 | // (SanDevices, AlphaPix, HinksPix, DIYLEDExpress) and for a page no | ||
| 35 | // detector recognised, neither of which needs a request. So a caller | ||
| 36 | // keeping an in-flight count must not hold a lock across the call. | ||
| 37 | static void DetectControllerViaHTML(const std::string& ip, const std::string& html, | ||
| 38 | std::function<void(NetworkController*)>&& callback); | ||
| 39 | |||
| 40 | // Deprecated blocking form, kept only so out-of-tree plugins compiled | ||
| 41 | // against the pre-async signature still build and behave as they did: the | ||
| 42 | // same detector walk, driven with the synchronous curl helpers, returning | ||
| 43 | // the heap-allocated NetworkController the caller owns and must delete (or | ||
| 44 | // nullptr). It blocks the calling thread for up to three sequential HTTP | ||
| 45 | // requests, so nothing in FPP should use it -- use the callback form above. | ||
| 46 | static NetworkController* DetectControllerViaHTML(const std::string& ip, const std::string& html); | ||
| 47 | |||
| 48 | std::string ip; | ||
| 49 | std::string hostname; | ||
| 50 | std::string vendor; | ||
| 51 | std::string vendorURL; | ||
| 52 | systemType typeId; | ||
| 53 | std::string typeStr; | ||
| 54 | std::string ranges; | ||
| 55 | std::string version; | ||
| 56 | std::string uuid; | ||
| 57 | // Identities this device reported for OTHER addresses. Some vendors | ||
| 58 | // describe their neighbours but not themselves, so an identity can only be | ||
| 59 | // learned second-hand; the caller applies these to systems discovery has | ||
| 60 | // already found. Keyed by address. | ||
| 61 | std::map<std::string, std::string> peerUUIDs; | ||
| 62 | unsigned int majorVersion; | ||
| 63 | unsigned int minorVersion; | ||
| 64 | FPPMode systemMode; | ||
| 65 | bool sendingMultiSync = false; | ||
| 66 | |||
| 67 | private: | ||
| 68 | // One in-progress detection: the page, the controller being filled in, and | ||
| 69 | // how far down the detector list we have got. Heap-allocated for the life | ||
| 70 | // of the walk because a detector that has to ask the device something | ||
| 71 | // resumes in a curl callback long after its caller returned. Defined in | ||
| 72 | // NetworkController.cpp. | ||
| 73 | class Detection; | ||
| 74 | friend class Detection; | ||
| 75 | |||
| 76 | // Each detector decides from the HTML whether the device is plausibly its | ||
| 77 | // vendor, and where that is not conclusive asks the device. Exactly one of | ||
| 78 | // st->matched(), st->noMatch() or st->fetch() must be reached on every path | ||
| 79 | // -- anything else strands the Detection and leaks it. | ||
| 80 | void DetectFalconController(Detection* st); | ||
| 81 | void DetectSanDevicesController(Detection* st); | ||
| 82 | void DetectESPixelStickController(Detection* st); | ||
| 83 | void DetectBaldrickController(Detection* st); | ||
| 84 | void ParseBaldrickVersion(const std::string& fw); | ||
| 85 | void DetectAlphaPixController(Detection* st); | ||
| 86 | void DetectHinksPixController(Detection* st); | ||
| 87 | void DetectDIYLEDExpressController(Detection* st); | ||
| 88 | void DetectWLEDController(Detection* st); | ||
| 89 | void DetectTwinklyController(Detection* st); | ||
| 90 | void DetectExperienceController(Detection* st); | ||
| 91 | void DetectFPP(Detection* st); | ||
| 92 | |||
| 93 | void DumpControllerInfo(void); | ||
| 94 | }; | ||
| 95 |