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 <cstdint>
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
rcdiscover::DeviceInfo::getIP
uint32_t getIP() const
Returns the current IP address of the device.
Definition: deviceinfo.h:104
rcdiscover::DeviceInfo::clear
void clear()
Clears all information.
Definition: deviceinfo.cc:125
rcdiscover::DeviceInfo::device_version
std::string device_version
Definition: deviceinfo.h:196
rcdiscover::DeviceInfo::isValid
bool isValid() const
Checks if the object contains useful information.
Definition: deviceinfo.h:72
rcdiscover::DeviceInfo::set
void set(const uint8_t *raw, size_t len)
Extracts the RAW GigE Vision information according to the given DISCOVERY_ACK package.
Definition: deviceinfo.cc:79
rcdiscover::DeviceInfo::getMinorVersion
int getMinorVersion() const
Return minor version of device.
Definition: deviceinfo.h:88
rcdiscover::DeviceInfo::iface_name
std::string iface_name
Definition: deviceinfo.h:184
rcdiscover::DeviceInfo::ip
uint32_t ip
Definition: deviceinfo.h:190
rcdiscover::DeviceInfo::getSubnetMask
uint32_t getSubnetMask() const
Returns the current subnet mask of the device.
Definition: deviceinfo.h:112
rcdiscover::DeviceInfo::getManufacturerInfo
const std::string & getManufacturerInfo() const
Returns manufacturer specific information.
Definition: deviceinfo.h:152
rcdiscover::DeviceInfo::manufacturer_info
std::string manufacturer_info
Definition: deviceinfo.h:197
rcdiscover::DeviceInfo::getIfaceName
const std::string & getIfaceName() const
Returns the name of the interface on which this device was found.
Definition: deviceinfo.h:180
rcdiscover::DeviceInfo::operator<
bool operator<(const DeviceInfo &info) const
First compares the MAC address, then the interface name.
Definition: deviceinfo.h:174
rcdiscover::DeviceInfo::getDeviceVersion
const std::string & getDeviceVersion() const
Returns the device version.
Definition: deviceinfo.h:144
rcdiscover::DeviceInfo::user_name
std::string user_name
Definition: deviceinfo.h:199
rcdiscover::DeviceInfo::getManufacturerName
const std::string & getManufacturerName() const
Returns the manufacturer name.
Definition: deviceinfo.h:128
rcdiscover::DeviceInfo::getSerialNumber
const std::string & getSerialNumber() const
Returns the serial number.
Definition: deviceinfo.h:160
rcdiscover::DeviceInfo::getMAC
uint64_t getMAC() const
Returns 6 bytes with the MAC address of the device.
Definition: deviceinfo.h:96
rcdiscover
Definition: deviceinfo.cc:40
rcdiscover::DeviceInfo::minor
int minor
Definition: deviceinfo.h:187
rcdiscover::DeviceInfo::DeviceInfo
DeviceInfo(std::string iface_name)
Definition: deviceinfo.cc:73
rcdiscover::DeviceInfo::model_name
std::string model_name
Definition: deviceinfo.h:195
rcdiscover::DeviceInfo::serial_number
std::string serial_number
Definition: deviceinfo.h:198
rcdiscover::DeviceInfo::getModelName
const std::string & getModelName() const
Returns the model name.
Definition: deviceinfo.h:136
rcdiscover::DeviceInfo::gateway
uint32_t gateway
Definition: deviceinfo.h:192
rcdiscover::DeviceInfo::mac
uint64_t mac
Definition: deviceinfo.h:189
rcdiscover::DeviceInfo::getUserName
const std::string & getUserName() const
Returns the user name.
Definition: deviceinfo.h:168
rcdiscover::DeviceInfo::getGateway
uint32_t getGateway() const
Returns the current IP address of the devices gateway.
Definition: deviceinfo.h:120
rcdiscover::DeviceInfo::subnet
uint32_t subnet
Definition: deviceinfo.h:191
rcdiscover::DeviceInfo::major
int major
Definition: deviceinfo.h:186
rcdiscover::DeviceInfo::getMajorVersion
int getMajorVersion() const
Return major version of device.
Definition: deviceinfo.h:80
rcdiscover::DeviceInfo
Definition: deviceinfo.h:46
rcdiscover::DeviceInfo::manufacturer_name
std::string manufacturer_name
Definition: deviceinfo.h:194


rcdiscover
Author(s): Heiko Hirschmueller , Raphael Schaller
autogenerated on Thu Aug 1 2024 02:55:56