OpenVPN 3 Core Library
Loading...
Searching...
No Matches
iosactiveiface.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#include <string>
13
16
17#ifndef OPENVPN_APPLECRYPTO_UTIL_IOSACTIVEIFACE_H
18#define OPENVPN_APPLECRYPTO_UTIL_IOSACTIVEIFACE_H
19
20namespace openvpn {
21
23{
24 public:
25 Status reachable() const override
26 {
27 if (ei.iface_up("en0"))
28 return ReachableViaWiFi;
29 else if (ei.iface_up("pdp_ip0"))
30 return ReachableViaWWAN;
31 else
32 return NotReachable;
33 }
34
35 bool reachableVia(const std::string &net_type) const override
36 {
37 const Status r = reachable();
38 if (net_type == "cellular")
39 return r == ReachableViaWWAN;
40 else if (net_type == "wifi")
41 return r == ReachableViaWiFi;
42 else
43 return r != NotReachable;
44 }
45
46 std::string to_string() const override
47 {
48 switch (reachable())
49 {
51 return "ReachableViaWiFi";
53 return "ReachableViaWWAN";
54 case NotReachable:
55 return "NotReachable";
56 }
57 }
58
59 private:
61};
62
63} // namespace openvpn
64#endif
bool iface_up(const char *iface) const
Definition enumiface.hpp:56
Status reachable() const override
std::string to_string() const override
bool reachableVia(const std::string &net_type) const override