Open Lighting Architecture: include/ola/network/NetworkUtils.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
NetworkUtils.h
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 * NetworkUtils.h
17 * Abstract various network functions.
18 * Copyright (C) 2005 Simon Newton
19 */
20
21#ifndef INCLUDE_OLA_NETWORK_NETWORKUTILS_H_
22#define INCLUDE_OLA_NETWORK_NETWORKUTILS_H_
23
24#include <ola/network/Interface.h>
25#include <ola/network/IPV4Address.h>
26#include <string>
27#include <vector>
28
29
30namespace ola {
31namespace network {
32
33// We define uint8_t versions of these so we can call them with any type.
37 inline uint8_t NetworkToHost(uint8_t value) { return value; }
38
42uint16_t NetworkToHost(uint16_t value);
43
47uint32_t NetworkToHost(uint32_t value);
48
52 inline int8_t NetworkToHost(int8_t value) { return value; }
53
57int16_t NetworkToHost(int16_t value);
58
62int32_t NetworkToHost(int32_t value);
63
67 inline uint8_t HostToNetwork(uint8_t value) { return value; }
68
72uint16_t HostToNetwork(uint16_t value);
73
77uint32_t HostToNetwork(uint32_t value);
78
82 inline int8_t HostToNetwork(int8_t value) { return value; }
83
87int16_t HostToNetwork(int16_t value);
88
92int32_t HostToNetwork(int32_t value);
93
97 inline uint8_t HostToLittleEndian(uint8_t value) { return value; }
98
102uint16_t HostToLittleEndian(uint16_t value);
103
107uint32_t HostToLittleEndian(uint32_t value);
108
112 inline int8_t HostToLittleEndian(int8_t value) { return value; }
113
117int16_t HostToLittleEndian(int16_t value);
118
122int32_t HostToLittleEndian(int32_t value);
123
127 inline uint8_t LittleEndianToHost(uint8_t value) { return value; }
128
132uint16_t LittleEndianToHost(uint16_t value);
133
137uint32_t LittleEndianToHost(uint32_t value);
138
142 inline int8_t LittleEndianToHost(int8_t value) { return value; }
143
147int16_t LittleEndianToHost(int16_t value);
148
152int32_t LittleEndianToHost(int32_t value);
153
159std::string HostnameFromFQDN(const std::string &fqdn);
160
166std::string DomainNameFromFQDN(const std::string &fqdn);
167
171std::string DomainName();
172
173
177std::string FQDN();
178
179
184std::string FullHostname();
185
189std::string Hostname();
190
196bool NameServers(std::vector<ola::network::IPV4Address> *name_servers);
197
211bool DefaultRoute(int32_t *if_index,
212 ola::network::IPV4Address *default_gateway);
213} // namespace network
214} // namespace ola
215#endif // INCLUDE_OLA_NETWORK_NETWORKUTILS_H_
216
IPV4Address.h
Represents an IPv4 Address.
ola::network::IPV4Address
Represents a IPv4 Address.
Definition IPV4Address.h:55
ola::network
Code for network communication.
Definition AdvancedTCPConnector.cpp:28
ola::network::Hostname
string Hostname()
Definition NetworkUtils.cpp:286
ola::network::FullHostname
string FullHostname()
Definition NetworkUtils.cpp:281
ola::network::HostnameFromFQDN
string HostnameFromFQDN(const string &fqdn)
Definition NetworkUtils.cpp:242
ola::network::DomainName
string DomainName()
Definition NetworkUtils.cpp:260
ola::network::DefaultRoute
bool DefaultRoute(int32_t *if_index, IPV4Address *default_gateway)
Definition NetworkUtils.cpp:604
ola::network::NetworkToHost
uint16_t NetworkToHost(uint16_t value)
16-bit unsigned network to host conversion.
Definition NetworkUtils.cpp:143
ola::network::FQDN
string FQDN()
Definition NetworkUtils.cpp:265
ola::network::DomainNameFromFQDN
string DomainNameFromFQDN(const string &fqdn)
Definition NetworkUtils.cpp:250
ola::network::HostToLittleEndian
uint16_t HostToLittleEndian(uint16_t value)
16-bit unsigned host to little endian conversion.
Definition NetworkUtils.cpp:175
ola::network::LittleEndianToHost
uint16_t LittleEndianToHost(uint16_t value)
16-bit unsigned little endian to host conversion.
Definition NetworkUtils.cpp:207
ola::network::HostToNetwork
uint16_t HostToNetwork(uint16_t value)
16-bit unsigned host to network conversion.
Definition NetworkUtils.cpp:159
ola::network::NameServers
bool NameServers(vector< IPV4Address > *name_servers)
Definition NetworkUtils.cpp:291
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44