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 SOCKET_COMMON_H
17 #define SOCKET_COMMON_H
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 #define MAX_APP_DATA_LENGTH_FOR_CAL_COST (30 * 1024)
24
25 void EpollEventCallback(struct FtSocket *sock, FILLP_UINT32 upEvent);
26
FillpValidateFuncPtr(void * ptr,FILLP_UINT32 size)27 static inline FILLP_INT FillpValidateFuncPtr(void *ptr, FILLP_UINT32 size)
28 {
29 FILLP_UINT32 index;
30 void **sysFunction = (void **)ptr;
31
32 size /= sizeof(void *);
33 for (index = 0; index < size; index++) {
34 if (sysFunction[index] == FILLP_NULL_PTR) {
35 return -1;
36 }
37 }
38
39 return ERR_OK;
40 }
41
42 extern struct GlobalAppResource g_appResource;
43
44 void InitGlobalAppResourceDefault(void);
45 void SockFreeSocket(struct FtSocket *sock);
46 struct FtSocket *SockAllocSocket(void);
47 struct FtSocket *SockGetSocket(FILLP_INT sockIndex);
48 FILLP_BOOL SockCanSendData(FILLP_CONST struct FtSocket *sock);
49 FILLP_BOOL SockCanRecvData(struct FtSocket *sock);
50 struct FtSocket *SockApiGetAndCheck(int sockIdx);
51 FILLP_INT SockUpdatePktDataOpt(struct FtSocket *sock, FILLP_UINT16 addFlag, FILLP_UINT16 delFlag);
52
53 #ifdef __cplusplus
54 }
55 #endif
56
57 #endif /* SOCKET_COMMON_H */