deviceinfo.h
Go to the documentation of this file.
1 /*
2  * rcdiscover - the network discovery tool for Roboception devices
3  *
4  * Copyright (c) 2017 Roboception GmbH
5  * All rights reserved
6  *
7  * Author: Heiko Hirschmueller
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef RCDISCOVER_DEVICEINFO
37 #define RCDISCOVER_DEVICEINFO
38 
39 #include <string>
40 #include <tuple>
41 #include <stdint.h>
42 
43 namespace rcdiscover
44 {
45 
47 {
48  public:
49 
50  explicit DeviceInfo(std::string iface_name);
51 
60  void set(const uint8_t *raw, size_t len);
61 
66  void clear();
67 
72  bool isValid() const { return mac != 0; }
73 
80  int getMajorVersion() const { return major; }
81 
88  int getMinorVersion() const { return minor; }
89 
96  uint64_t getMAC() const { return mac; }
97 
104  uint32_t getIP() const { return ip; }
105 
112  uint32_t getSubnetMask() const { return subnet; }
113 
120  uint32_t getGateway() const { return gateway; }
121 
128  const std::string &getManufacturerName() const { return manufacturer_name; }
129 
136  const std::string &getModelName() const { return model_name; }
137 
144  const std::string &getDeviceVersion() const { return device_version; }
145 
152  const std::string &getManufacturerInfo() const { return manufacturer_info; }
153 
160  const std::string &getSerialNumber() const { return serial_number; }
161 
168  const std::string &getUserName() const { return user_name; }
169 
174  bool operator < (const DeviceInfo &info) const
175  { return std::tie(mac, iface_name) < std::tie(info.mac, info.iface_name); }
176 
180  const std::string &getIfaceName() const { return iface_name; }
181 
182  private:
183 
184  std::string iface_name;
185 
186  int major;
187  int minor;
188 
189  uint64_t mac;
190  uint32_t ip;
191  uint32_t subnet;
192  uint32_t gateway;
193 
194  std::string manufacturer_name;
195  std::string model_name;
196  std::string device_version;
197  std::string manufacturer_info;
198  std::string serial_number;
199  std::string user_name;
200 };
201 
202 }
203 
204 #endif
int getMajorVersion() const
Return major version of device.
Definition: deviceinfo.h:80
uint32_t getSubnetMask() const
Returns the current subnet mask of the device.
Definition: deviceinfo.h:112
const std::string & getManufacturerName() const
Returns the manufacturer name.
Definition: deviceinfo.h:128
std::string manufacturer_info
Definition: deviceinfo.h:197
std::string manufacturer_name
Definition: deviceinfo.h:194
void clear()
Clears all information.
Definition: deviceinfo.cc:125
std::string device_version
Definition: deviceinfo.h:196
uint32_t getGateway() const
Returns the current IP address of the devices gateway.
Definition: deviceinfo.h:120
std::string model_name
Definition: deviceinfo.h:195
const std::string & getDeviceVersion() const
Returns the device version.
Definition: deviceinfo.h:144
const std::string & getModelName() const
Returns the model name.
Definition: deviceinfo.h:136
uint32_t getIP() const
Returns the current IP address of the device.
Definition: deviceinfo.h:104
const std::string & getSerialNumber() const
Returns the serial number.
Definition: deviceinfo.h:160
const std::string & getManufacturerInfo() const
Returns manufacturer specific information.
Definition: deviceinfo.h:152
std::string user_name
Definition: deviceinfo.h:199
int getMinorVersion() const
Return minor version of device.
Definition: deviceinfo.h:88
DeviceInfo(std::string iface_name)
Definition: deviceinfo.cc:73
bool operator<(const DeviceInfo &info) const
First compares the MAC address, then the interface name.
Definition: deviceinfo.h:174
std::string serial_number
Definition: deviceinfo.h:198
uint64_t getMAC() const
Returns 6 bytes with the MAC address of the device.
Definition: deviceinfo.h:96
std::string iface_name
Definition: deviceinfo.h:184
bool isValid() const
Checks if the object contains useful information.
Definition: deviceinfo.h:72
const std::string & getUserName() const
Returns the user name.
Definition: deviceinfo.h:168
const std::string & getIfaceName() const
Returns the name of the interface on which this device was found.
Definition: deviceinfo.h:180


rcdiscover
Author(s): Heiko Hirschmueller , Raphael Schaller
autogenerated on Sun Apr 18 2021 02:16:32