Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
NetworkingPluginCommon.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 NETWORKINGPLUGINCOMMON_H
21#define NETWORKINGPLUGINCOMMON_H
22
23#include <netinet/in.h>
24
25#define BRIDGE_NAME "dobby0"
26
27#if defined(DEV_VM)
28#define PEER_NAME "enp0s3"
29#else
30#define PEER_NAME "eth0"
31#endif
32
33// -----------------------------------------------------------------------------
34// IPv4 address macros
35
36// creates an in_addr_t type from ip address
37#define INADDR_CREATE(a, b, c, d) \
38 ( ((((in_addr_t)(a)) << 24) & 0xff000000) | \
39 ((((in_addr_t)(b)) << 16) & 0x00ff0000) | \
40 ((((in_addr_t)(c)) << 8) & 0x0000ff00) | \
41 ((((in_addr_t)(d)) << 0) & 0x000000ff) )
42
43// commonly used ip addresses created as in_addr_t type
44#define INADDR_BRIDGE INADDR_CREATE( 100, 64, 11, 1 )
45#define INADDR_BRIDGE_NETMASK INADDR_CREATE( 255, 255, 255, 0 )
46#define INADDR_LO INADDR_CREATE( 127, 0, 0, 1 )
47#define INADDR_LO_NETMASK INADDR_CREATE( 255, 0, 0, 0 )
48
49// commonly used ip address string literals for iptables rules
50// NB: the bridge addresses must work with the above INADDR_* addresses
51#define BRIDGE_ADDRESS_RANGE "100.64.11.0"
52#define BRIDGE_ADDRESS "100.64.11.1"
53#define LOCALHOST "127.0.0.1"
54
55
56// -----------------------------------------------------------------------------
57// IPv6 address helpers
58
59// 2080:d0bb:1e::
60static const struct in6_addr IN6ADDR_BASE = {{
61 0x20, 0x80, 0xd0, 0xbb,
62 0x00, 0x1e, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x00,
65}};
66
67// 0000:0000:0000:0000:0000:0000:0000:0000
68static const struct in6_addr IN6ADDR_ANY = {{
69 0x00, 0x00, 0x00, 0x00,
70 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00,
73}};
74
75#define BRIDGE_ADDRESS_RANGE_IPV6 "2080:d0bb:1e::6440:b00"
76#define BRIDGE_ADDRESS_IPV6 "2080:d0bb:1e::6440:b01"
77#define LOCALHOST_IPV6 "::1"
78
79
80enum class NetworkType { None, Nat, Open };
81
82#endif // !defined(NETWORKINGPLUGINCOMMON_H)