2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef SYSTEM_EXTRAS_MULTINETWORK_COMMON_H_
19 #define SYSTEM_EXTRAS_MULTINETWORK_COMMON_H_
21 #include <sys/cdefs.h>
22 #include <sys/socket.h>
25 #include <android/multinetwork.h>
34 Arguments() : nethandle(NETWORK_UNSPECIFIED),
35 api_mode(ApiMode::EXPLICIT),
40 bool parseArguments(int argc, const char* argv[]);
42 net_handle_t nethandle;
49 void printUsage(const char *progname);
51 // If port is non-zero returns strings of the form "192.0.2.1:port" or
52 // "[2001:db8::1]:port", else it returns the bare IP string literal.
53 std::string inetSockaddrToString(const sockaddr* sa);
57 FdAutoCloser() : fd(-1) {}
58 /* not explicit */ FdAutoCloser(int fd) : fd(fd) {}
69 #endif // SYSTEM_EXTRAS_MULTINETWORK_COMMON_H_