1 /* 2 * Copyright (c) 2022 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 COMMUNICATION_NETMANAGER_BASE_NEW_DNS_NETSYS_CLIENT_H 17 #define COMMUNICATION_NETMANAGER_BASE_NEW_DNS_NETSYS_CLIENT_H 18 19 #include <arpa/inet.h> 20 #include <errno.h> 21 #include <fcntl.h> 22 #include <netinet/in.h> 23 #include <poll.h> 24 #include <stdbool.h> 25 #include <stdio.h> 26 #include <string.h> 27 #include <sys/select.h> 28 #include <sys/socket.h> 29 #include <sys/un.h> 30 #include <unistd.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #define DEFAULT_CONNECT_TIMEOUT 2 37 #define DEFAULT_POLL_TIMEOUT 600 38 #define MAX_POLL_RETRY 2 39 40 #if NETSYS_CLIENT_DEBUG 41 #ifndef NETSYS_CLIENT_PRINT 42 #define NETSYS_CLIENT_PRINT(fmt, ...) printf(fmt "\n", ##__VA_ARGS__) 43 #endif 44 #else 45 #define NETSYS_CLIENT_PRINT(fmt, ...) 46 #endif 47 48 bool MakeNonBlock(int sock); 49 50 int64_t Poll(int sock, short event, int *retry); 51 52 bool PollSendData(int sock, const char *data, size_t size); 53 54 bool PollRecvData(int sock, char *data, size_t size); 55 56 int NetSysIsIpv6Enable(uint16_t netId); 57 #ifdef __cplusplus 58 } 59 #endif 60 61 #endif // COMMUNICATION_NETMANAGER_BASE_NEW_DNS_NETSYS_CLIENT_H 62