Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
NetworkingHelper.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 2020 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#ifndef NETWORKINGHELPER_H
21#define NETWORKINGHELPER_H
22
23#include <netinet/in.h>
24#include <array>
25#include <string>
26#include "NetworkingPluginCommon.h"
27
29{
30public:
31 NetworkingHelper(bool ipv4Enabled, bool ipv6Enabled);
33
34public:
35 bool storeContainerInterface(in_addr_t addr, const std::string &vethName);
36 bool storeContainerVethPeerMac(const std::array<uint8_t, 6> &mac);
37
38 bool ipv4() const;
39 in_addr_t ipv4Addr() const;
40 std::string ipv4AddrStr() const;
41
42 bool ipv6() const;
43 struct in6_addr ipv6Addr() const;
44 std::string ipv6AddrStr() const;
45
46 std::string vethName() const;
47 std::array<uint8_t, 6> vethPeerMac() const;
48
49public:
50 static struct in6_addr in6addrCreate(const in_addr_t inaddr);
51
52private:
53 bool mIpv4Enabled;
54 in_addr_t mIpv4Addr;
55 std::string mIpv4AddrStr;
56
57 bool mIpv6Enabled;
58 struct in6_addr mIpv6Addr;
59 std::string mIpv6AddrStr;
60
61 std::string mVethName;
62 std::array<uint8_t, 6> mVethPeerMac;
63};
64
65#endif // !defined(NETWORKINGHELPER_H)
Definition NetworkingHelper.h:29
bool storeContainerInterface(in_addr_t addr, const std::string &vethName)
Constructs addresses for the container based on input address. Also stores the veth device used for t...
Definition NetworkingHelper.cpp:102
static struct in6_addr in6addrCreate(const in_addr_t inaddr)
Constructs an IPv6 address to be used by Dobby.
Definition NetworkingHelper.cpp:157
bool storeContainerVethPeerMac(const std::array< uint8_t, 6 > &mac)
Simply stores the MAC address of eth0 within the container.
Definition NetworkingHelper.cpp:137