1b1b8bc3fSopenharmony_ci/*
2b1b8bc3fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3b1b8bc3fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4b1b8bc3fSopenharmony_ci * you may not use this file except in compliance with the License.
5b1b8bc3fSopenharmony_ci * You may obtain a copy of the License at
6b1b8bc3fSopenharmony_ci *
7b1b8bc3fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8b1b8bc3fSopenharmony_ci *
9b1b8bc3fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10b1b8bc3fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11b1b8bc3fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12b1b8bc3fSopenharmony_ci * See the License for the specific language governing permissions and
13b1b8bc3fSopenharmony_ci * limitations under the License.
14b1b8bc3fSopenharmony_ci */
15b1b8bc3fSopenharmony_ci
16b1b8bc3fSopenharmony_ci#ifndef COMMUNICATION_NETMANAGER_BASE_NEW_DNS_NETSYS_CLIENT_H
17b1b8bc3fSopenharmony_ci#define COMMUNICATION_NETMANAGER_BASE_NEW_DNS_NETSYS_CLIENT_H
18b1b8bc3fSopenharmony_ci
19b1b8bc3fSopenharmony_ci#include <arpa/inet.h>
20b1b8bc3fSopenharmony_ci#include <errno.h>
21b1b8bc3fSopenharmony_ci#include <fcntl.h>
22b1b8bc3fSopenharmony_ci#include <netinet/in.h>
23b1b8bc3fSopenharmony_ci#include <poll.h>
24b1b8bc3fSopenharmony_ci#include <stdbool.h>
25b1b8bc3fSopenharmony_ci#include <stdio.h>
26b1b8bc3fSopenharmony_ci#include <string.h>
27b1b8bc3fSopenharmony_ci#include <sys/select.h>
28b1b8bc3fSopenharmony_ci#include <sys/socket.h>
29b1b8bc3fSopenharmony_ci#include <sys/un.h>
30b1b8bc3fSopenharmony_ci#include <unistd.h>
31b1b8bc3fSopenharmony_ci
32b1b8bc3fSopenharmony_ci#ifdef __cplusplus
33b1b8bc3fSopenharmony_ciextern "C" {
34b1b8bc3fSopenharmony_ci#endif
35b1b8bc3fSopenharmony_ci
36b1b8bc3fSopenharmony_ci#define DEFAULT_CONNECT_TIMEOUT 2
37b1b8bc3fSopenharmony_ci#define DEFAULT_POLL_TIMEOUT 600
38b1b8bc3fSopenharmony_ci#define MAX_POLL_RETRY 2
39b1b8bc3fSopenharmony_ci
40b1b8bc3fSopenharmony_ci#if NETSYS_CLIENT_DEBUG
41b1b8bc3fSopenharmony_ci#ifndef NETSYS_CLIENT_PRINT
42b1b8bc3fSopenharmony_ci#define NETSYS_CLIENT_PRINT(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
43b1b8bc3fSopenharmony_ci#endif
44b1b8bc3fSopenharmony_ci#else
45b1b8bc3fSopenharmony_ci#define NETSYS_CLIENT_PRINT(fmt, ...)
46b1b8bc3fSopenharmony_ci#endif
47b1b8bc3fSopenharmony_ci
48b1b8bc3fSopenharmony_cibool MakeNonBlock(int sock);
49b1b8bc3fSopenharmony_ci
50b1b8bc3fSopenharmony_ciint64_t Poll(int sock, short event, int *retry);
51b1b8bc3fSopenharmony_ci
52b1b8bc3fSopenharmony_cibool PollSendData(int sock, const char *data, size_t size);
53b1b8bc3fSopenharmony_ci
54b1b8bc3fSopenharmony_cibool PollRecvData(int sock, char *data, size_t size);
55b1b8bc3fSopenharmony_ci
56b1b8bc3fSopenharmony_ciint NetSysIsIpv6Enable(uint16_t netId);
57b1b8bc3fSopenharmony_ci#ifdef __cplusplus
58b1b8bc3fSopenharmony_ci}
59b1b8bc3fSopenharmony_ci#endif
60b1b8bc3fSopenharmony_ci
61b1b8bc3fSopenharmony_ci#endif // COMMUNICATION_NETMANAGER_BASE_NEW_DNS_NETSYS_CLIENT_H
62