1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16#pragma once 17 18#include <stdint.h> 19#include <string> 20 21#include "address.h" 22#include "socket.h" 23 24// A class that contains the information used by the proxy that is specific to a 25// single interface. This includes the name and index of the interface as well 26// as the sockets used to send and receive data on the interface. 27// 28// The class also contains the functionality needed to initialized and configure 29// the interface, sockets and addresses. 30class Interface { 31public: 32 explicit Interface(const std::string& name); 33 34 bool init(); 35 36 const std::string& name() const { return mName; } 37 uint32_t index() const { return mIndex; } 38 Socket& ipSocket() { return mIpSocket; } 39 Socket& icmpSocket() { return mIcmpSocket; } 40 const Address& linkAddr() const { return mLinkAddr; } 41 42private: 43 bool setAllMulti(); 44 bool resolveAddresses(); 45 bool configureIcmpSocket(); 46 bool configureIpSocket(); 47 48 std::string mName; 49 uint32_t mIndex; 50 Socket mIpSocket; 51 Socket mIcmpSocket; 52 Address mLinkAddr; 53}; 54 55