UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
upnp_device.cpp
Go to the documentation of this file.
1// Copyright (C) 2024+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
2// Redistribution only with this Copyright remark. Last modified: 2024-12-23
9#include <UPnPsdk/synclog.hpp>
11
12
13namespace UPnPsdk {
14
15// Constructor
16CRootdevice::CRootdevice(){
17 TRACE2(this, " Construct CRootdevice()") //
18}
19
20// Destructor
21CRootdevice::~CRootdevice() {
22 TRACE2(this, " Destruct CRootdevice()") //
23}
24
25// Bind rootdevice to local network interfaces
26void CRootdevice::bind(const std::string& a_ifname) {
27 TRACE2(this, " Executing CRootdevice::bind()")
28
29 CNetadapter nadaptObj; // Instantiate object
30 nadaptObj.get_first(); // May throw exception std::runtime_error
31
32 enum struct Found { none, name, index, addr } iface_found{};
33 do {
34 if (nadaptObj.name() == a_ifname) {
35 iface_found = Found::name;
36 break;
37 }
38 } while (nadaptObj.get_next());
39
40 switch (iface_found) {
41 case Found::none:
42 break;
43 case Found::name:
44 m_ifname = a_ifname;
45 break;
46 case Found::index:
47 break;
48 case Found::addr:
49 break;
50 }
51}
52
53// Get interface name
54std::string CRootdevice::ifname() const {
55 TRACE2(this, " Executing CRootdevice::ifname()")
56 return m_ifname;
57}
58
59} // namespace UPnPsdk
Get information from local network adapters.
UPnPsdk_API void get_first()
Load a list of network adapters from the operating system and select its first entry.
UPnPsdk_API std::string name() const
Get network adapter name from current selected list entry.
UPnPsdk_API bool get_next()
Select next entry from the network adapter list that was initial loaded with get_first().
std::string ifname() const
Get interface name.
void bind(const std::string &a_ifname)
Bind rootdevice to local network interfaces.
Reengineered Object Oriented UPnP+ program code.
Manage information about network adapters.
Define macro for synced logging to the console for detailed info and debug.
Manage UPnP devices.