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 #ifndef NETD_INCLUDE_NETD_CLIENT_H 18*8542734aSAndroid Build Coastguard Worker #define NETD_INCLUDE_NETD_CLIENT_H 19*8542734aSAndroid Build Coastguard Worker 20*8542734aSAndroid Build Coastguard Worker #include <stdbool.h> 21*8542734aSAndroid Build Coastguard Worker #include <sys/cdefs.h> 22*8542734aSAndroid Build Coastguard Worker #include <sys/types.h> 23*8542734aSAndroid Build Coastguard Worker 24*8542734aSAndroid Build Coastguard Worker __BEGIN_DECLS 25*8542734aSAndroid Build Coastguard Worker 26*8542734aSAndroid Build Coastguard Worker // All functions below that return an int return 0 on success or a negative errno value on failure. 27*8542734aSAndroid Build Coastguard Worker 28*8542734aSAndroid Build Coastguard Worker int getNetworkForSocket(unsigned* netId, int socketFd); 29*8542734aSAndroid Build Coastguard Worker int setNetworkForSocket(unsigned netId, int socketFd); 30*8542734aSAndroid Build Coastguard Worker 31*8542734aSAndroid Build Coastguard Worker unsigned getNetworkForProcess(void); 32*8542734aSAndroid Build Coastguard Worker 33*8542734aSAndroid Build Coastguard Worker int setNetworkForProcess(unsigned netId); 34*8542734aSAndroid Build Coastguard Worker 35*8542734aSAndroid Build Coastguard Worker int setNetworkForResolv(unsigned netId); 36*8542734aSAndroid Build Coastguard Worker 37*8542734aSAndroid Build Coastguard Worker int protectFromVpn(int socketFd); 38*8542734aSAndroid Build Coastguard Worker 39*8542734aSAndroid Build Coastguard Worker int setNetworkForUser(uid_t uid, int socketFd); 40*8542734aSAndroid Build Coastguard Worker 41*8542734aSAndroid Build Coastguard Worker int queryUserAccess(uid_t uid, unsigned netId); 42*8542734aSAndroid Build Coastguard Worker 43*8542734aSAndroid Build Coastguard Worker void setAllowNetworkingForProcess(bool allowNetworking); 44*8542734aSAndroid Build Coastguard Worker 45*8542734aSAndroid Build Coastguard Worker int tagSocket(int socketFd, uint32_t tag, uid_t uid); 46*8542734aSAndroid Build Coastguard Worker 47*8542734aSAndroid Build Coastguard Worker int untagSocket(int socketFd); 48*8542734aSAndroid Build Coastguard Worker 49*8542734aSAndroid Build Coastguard Worker int resNetworkQuery(unsigned netId, const char* dname, int ns_class, int ns_type, uint32_t flags); 50*8542734aSAndroid Build Coastguard Worker 51*8542734aSAndroid Build Coastguard Worker int resNetworkResult(int query_fd, int* rcode, uint8_t* answer, size_t anslen); 52*8542734aSAndroid Build Coastguard Worker 53*8542734aSAndroid Build Coastguard Worker int resNetworkSend(unsigned netId, const uint8_t* msg, size_t msglen, uint32_t flags); 54*8542734aSAndroid Build Coastguard Worker 55*8542734aSAndroid Build Coastguard Worker void resNetworkCancel(int nsend_fd); 56*8542734aSAndroid Build Coastguard Worker 57*8542734aSAndroid Build Coastguard Worker int getNetworkForDns(unsigned* dnsNetId); 58*8542734aSAndroid Build Coastguard Worker __END_DECLS 59*8542734aSAndroid Build Coastguard Worker 60*8542734aSAndroid Build Coastguard Worker #endif // NETD_INCLUDE_NETD_CLIENT_H 61