Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
TapInterface.h
1/*
2* If not stated otherwise in this file or this component's LICENSE file the
3* following copyright and licenses apply:
4*
5* Copyright 2021 Sky UK
6*
7* Licensed under the Apache License, Version 2.0 (the "License");
8* you may not use this file except in compliance with the License.
9* You may obtain a copy of the License at
10*
11* http://www.apache.org/licenses/LICENSE-2.0
12*
13* Unless required by applicable law or agreed to in writing, software
14* distributed under the License is distributed on an "AS IS" BASIS,
15* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16* See the License for the specific language governing permissions and
17* limitations under the License.
18*/
19
20/*
21 * File: TapInterface.h
22 *
23 */
24#ifndef TAPINTERFACE_H
25#define TAPINTERFACE_H
26
27#include <string>
28#include <memory>
29#include <array>
30#include <arpa/inet.h>
31
32class Netlink;
33// -----------------------------------------------------------------------------
37namespace TapInterface
38{
40 bool createTapInterface(const std::shared_ptr<Netlink> &netlink);
41 bool destroyTapInterface(const std::shared_ptr<Netlink> &netlink);
42 bool isValid();
43 const std::string name();
44 bool up(const std::shared_ptr<Netlink> &netlink);
45 bool down(const std::shared_ptr<Netlink> &netlink);
46 std::array<uint8_t, 6> macAddress(const std::shared_ptr<Netlink> &netlink);
47 bool setMACAddress(const std::shared_ptr<Netlink> &netlink,
48 const std::array<uint8_t, 6> &address);
49 static bool valid = false;
50}; // namespace TapInterface
51
52#endif // !defined(TAPINTERFACE_H)
Definition TapInterface.h:38
bool down(const std::shared_ptr< Netlink > &netlink)
Takes an interface down.
Definition TapInterface.cpp:199
bool destroyTapInterface(const std::shared_ptr< Netlink > &netlink)
Destroys the Dobby tap device if it exists.
Definition TapInterface.cpp:115
bool platformSupportsTapInterface()
Returns true if the platform has the TUN/TAP device driver and therefore can create tap devices.
Definition TapInterface.cpp:52
bool setMACAddress(const std::shared_ptr< Netlink > &netlink, const std::array< uint8_t, 6 > &address)
Sets the MAC address of the tap device.
Definition TapInterface.cpp:235
bool up(const std::shared_ptr< Netlink > &netlink)
Brings an interface up.
Definition TapInterface.cpp:177
bool createTapInterface(const std::shared_ptr< Netlink > &netlink)
Creates the Dobby tap device.
Definition TapInterface.cpp:66
std::array< uint8_t, 6 > macAddress(const std::shared_ptr< Netlink > &netlink)
Gets the MAC address of the tap device.
Definition TapInterface.cpp:221