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 SPUNGE_MESSAGE_H 17 #define SPUNGE_MESSAGE_H 18 19 #include "spunge.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif /* __cplusplus */ 24 25 struct SpungeSocketMsg { 26 void *sock; 27 FILLP_INT domain; 28 FILLP_INT type; 29 FILLP_INT protocol; 30 }; 31 32 struct SpungeBindMsg { 33 void *sock; 34 struct sockaddr_in *addr; 35 socklen_t addrLen; 36 }; 37 38 struct SpungeShutdownMsg { 39 void *sock; 40 FILLP_INT how; 41 }; 42 43 struct SpungeConnectMsg { 44 void *sock; 45 struct sockaddr_in *addr; 46 socklen_t addrLen; 47 }; 48 49 struct SpungeAcceptMsg { 50 void *listenSock; 51 void *netconn; 52 }; 53 54 struct SpungeEvtInfoMsg { 55 void *sock; 56 FtEventCbkInfo *info; 57 }; 58 59 struct SpungeHiEventCbMsg { 60 void *softObj; 61 FillpDfxEventCb cb; 62 }; 63 64 struct SpungeMsg { 65 void *value; 66 int msgType; 67 FILLP_BOOL block; 68 SYS_ARCH_SEM syncSem; 69 }; 70 71 /* If you want to add/del some message type here, please check the macro MAX_SPUNGE_TYPE_NUM in sockets.h */ 72 enum SpungeMsgType { 73 MSG_TYPE_ALLOC_SOCK, 74 MSG_TYPE_FREE_SOCK_EAGAIN, /* free sock failed before, now try again */ 75 MSG_TYPE_DO_LISTEN, 76 MSG_TYPE_DO_CONNECT, 77 MSG_TYPE_DO_BIND, 78 MSG_TYPE_NETCONN_ACCPETED, 79 MSG_TYPE_DO_CLOSE, 80 MSG_TYPE_DO_SHUTDOWN, 81 MSG_TYPE_SET_SEND_BUF, 82 MSG_TYPE_SET_RECV_BUF, 83 MSG_TYPE_SET_NACK_DELAY, 84 MSG_TYPE_GET_EVENT_INFO, 85 MSG_TYPE_SET_KEEP_ALIVE, 86 MSG_TYPE_SET_HIEVENT_CB, 87 MSG_TYPE_END 88 }; 89 90 FillpErrorType SpungePostMsg(struct SpungeInstance *inst, void *value, FILLP_INT type, FILLP_BOOL block); 91 92 typedef void (*spungeMsgHandler)(void *value, struct SpungeInstance *inst); 93 extern spungeMsgHandler g_msgHandler[MSG_TYPE_END]; 94 95 void *SpungeMsgCreatePool(int initSize, int maxSize); 96 void SpungeMsgPoolDestroy(DympoolType *msgPool); 97 98 #ifdef __cplusplus 99 } 100 #endif /* __cplusplus */ 101 102 #endif /* SPUNGE_MESSAGE_H */