xref: /aosp_15_r20/system/netd/server/DummyNetwork.cpp (revision 8542734a0dd1db395a4d42aae09c37f3c3c3e7a1)
1*8542734aSAndroid Build Coastguard Worker /*
2*8542734aSAndroid Build Coastguard Worker  * Copyright (C) 2014 The Android Open Source Project
3*8542734aSAndroid Build Coastguard Worker  *
4*8542734aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*8542734aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*8542734aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*8542734aSAndroid Build Coastguard Worker  *
8*8542734aSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*8542734aSAndroid Build Coastguard Worker  *
10*8542734aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*8542734aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*8542734aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*8542734aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*8542734aSAndroid Build Coastguard Worker  * limitations under the License.
15*8542734aSAndroid Build Coastguard Worker  */
16*8542734aSAndroid Build Coastguard Worker 
17*8542734aSAndroid Build Coastguard Worker #define LOG_TAG "Netd"
18*8542734aSAndroid Build Coastguard Worker 
19*8542734aSAndroid Build Coastguard Worker #include "DummyNetwork.h"
20*8542734aSAndroid Build Coastguard Worker 
21*8542734aSAndroid Build Coastguard Worker #include "errno.h"
22*8542734aSAndroid Build Coastguard Worker 
23*8542734aSAndroid Build Coastguard Worker namespace android {
24*8542734aSAndroid Build Coastguard Worker namespace net {
25*8542734aSAndroid Build Coastguard Worker 
26*8542734aSAndroid Build Coastguard Worker // The dummy network is used to blackhole or reject traffic.
27*8542734aSAndroid Build Coastguard Worker // It has an IPv4 and an IPv6 default route that point to a dummy interface
28*8542734aSAndroid Build Coastguard Worker // which drops packets. It is used for system purposes only. Applications
29*8542734aSAndroid Build Coastguard Worker // cannot use multinetwork APIs such as Network#bindSocket or
30*8542734aSAndroid Build Coastguard Worker // android_setsocknetwork to send packets on the dummy network.
31*8542734aSAndroid Build Coastguard Worker // Any attempt to do so will fail with ENETUNREACH.
32*8542734aSAndroid Build Coastguard Worker 
33*8542734aSAndroid Build Coastguard Worker const char* DummyNetwork::INTERFACE_NAME = "dummy0";
34*8542734aSAndroid Build Coastguard Worker 
DummyNetwork(unsigned netId)35*8542734aSAndroid Build Coastguard Worker DummyNetwork::DummyNetwork(unsigned netId) : Network(netId) {
36*8542734aSAndroid Build Coastguard Worker     mInterfaces.insert(INTERFACE_NAME);
37*8542734aSAndroid Build Coastguard Worker }
38*8542734aSAndroid Build Coastguard Worker 
~DummyNetwork()39*8542734aSAndroid Build Coastguard Worker DummyNetwork::~DummyNetwork() {
40*8542734aSAndroid Build Coastguard Worker }
41*8542734aSAndroid Build Coastguard Worker 
42*8542734aSAndroid Build Coastguard Worker }  // namespace net
43*8542734aSAndroid Build Coastguard Worker }  // namespace android
44