Jetson Inference
DNN Vision Library
Networking.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __NETWORKING_H_
24 #define __NETWORKING_H_
25 
26 #include <string>
27 #include <vector>
28 
29 #include "IPv4.h"
30 #include "IPv6.h"
31 
32 
38 std::string getHostname();
39 
40 
51 std::string getHostByName( const char* name, uint32_t retries=10 );
52 
53 
70 uint32_t getHostByName( const char* name, void* ipAddress, uint32_t size, uint32_t retries=10 );
71 
72 
79 {
80  std::string name;
81  bool up;
83  struct IPv4
84  {
85  std::string address;
86  std::string netmask;
87  std::string broadcast;
88  } ipv4;
89 
90  struct IPv6
91  {
92  std::string address;
93  std::string prefix;
94  } ipv6;
95 };
96 
97 
104 std::vector<NetworkInterface> getNetworkInterfaces();
105 
110 int findNetworkInterface( const std::vector<NetworkInterface>& interfaces, const char* name );
111 
116 void printNetworkInterfaces( const std::vector<NetworkInterface>& interfaces );
117 
118 
123 #define LOG_NETWORK "[network] "
124 
125 #endif
NetworkInterface::ipv6
struct NetworkInterface::IPv6 ipv6
getNetworkInterfaces
std::vector< NetworkInterface > getNetworkInterfaces()
Retrieve info about the different IPv4/IPv6 network interfaces of the system.
NetworkInterface::IPv4
Definition: Networking.h:83
NetworkInterface::IPv6::prefix
std::string prefix
IPv6 prefix.
Definition: Networking.h:93
NetworkInterface::up
bool up
true if the interface is up, false if down
Definition: Networking.h:81
getHostByName
std::string getHostByName(const char *name, uint32_t retries=10)
Resolve the IP address of a given hostname or domain using DNS lookup, and return it as a string.
printNetworkInterfaces
void printNetworkInterfaces(const std::vector< NetworkInterface > &interfaces)
Print out a list of network interfaces.
findNetworkInterface
int findNetworkInterface(const std::vector< NetworkInterface > &interfaces, const char *name)
Find the index of a network interface by name from the list of interfaces.
NetworkInterface::IPv4::broadcast
std::string broadcast
IPv4 broadcast.
Definition: Networking.h:87
getHostname
std::string getHostname()
Retrieve the host system's network hostname.
NetworkInterface::IPv4::netmask
std::string netmask
IPv4 netmask.
Definition: Networking.h:86
NetworkInterface::IPv4::address
std::string address
IPv4 address.
Definition: Networking.h:85
NetworkInterface
Info about a particular network interface.
Definition: Networking.h:78
NetworkInterface::IPv6
Definition: Networking.h:90
NetworkInterface::ipv4
struct NetworkInterface::IPv4 ipv4
NetworkInterface::name
std::string name
name of the network interface (e.g.
Definition: Networking.h:80
IPv4.h
IPv6.h
NetworkInterface::IPv6::address
std::string address
IPv6 address.
Definition: Networking.h:92