1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NETSYS_DNSRESOLV_DNS_RESOLV_LISTEN_H 17 #define NETSYS_DNSRESOLV_DNS_RESOLV_LISTEN_H 18 19 #include <cstdint> 20 21 #include "event_handler.h" 22 #include "ffrt.h" 23 24 namespace OHOS { 25 namespace nmd { 26 class DnsResolvListen { 27 public: 28 DnsResolvListen(); 29 ~DnsResolvListen(); 30 31 void StartListen(); 32 33 private: 34 static void ProcGetConfigCommand(int clientSockFd, uint16_t netId, uint32_t uid); 35 #ifdef FEATURE_NET_FIREWALL_ENABLE 36 static void ProcSetCacheCommand(int clientSockFd, uint16_t netId, uint32_t callingUid); 37 static void ProcGetCacheCommand(int clientSockFd, uint16_t netId, uint32_t callingUid); 38 #endif 39 static void ProcSetCacheCommand(int clientSockFd, uint16_t netId); 40 static void ProcGetCacheCommand(int clientSockFd, uint16_t netId); 41 static void ProcJudgeIpv6Command(int clientSockFd, uint16_t netId); 42 static void ProcPostDnsResultCommand(int clientSockFd, uint16_t netId); 43 static void ProcGetDefaultNetworkCommand(int clientSockFd, uint16_t netId); 44 static void ProcBindSocketCommand(int clientSockFd, uint16_t netId); 45 static void ProcCommand(int clientSockFd); 46 static int32_t ProcGetKeyForCache(int clientSockFd, char *name); 47 static bool ProcPostDnsThreadResult(int clientSockFd, uint32_t &uid, uint32_t &pid); 48 49 int32_t serverSockFd_; 50 }; 51 } // namespace nmd 52 } // namespace OHOS 53 #endif // NETSYS_DNSRESOLV_DNS_RESOLV_LISTEN_H 54