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 FILLP_MGT_MSG_LOG_H 17 #define FILLP_MGT_MSG_LOG_H 18 19 #include "fillp.h" 20 #include "log.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #ifdef FILLP_MGT_MSG_LOG 27 enum { 28 FILLP_DIRECTION_TX, 29 FILLP_DIRECTION_RX, 30 }; 31 32 void FillpPktSimpleLog(FILLP_INT sockIndex, FILLP_CONST struct FillpPktHead *hdrInput, FILLP_INT direction); 33 void FillpConnReqLog(FILLP_INT sockIndex, FILLP_CONST struct FillpPktConnReq *req, FILLP_INT direction); 34 void FillpConnReqAckRxLog(FILLP_INT sockIndex, FILLP_CONST struct FillpPktHead *hdr, 35 FILLP_CONST struct FillpConnReqAckClient *ack, FILLP_CONST FILLP_UCHAR *extPara, FILLP_INT extParaLen); 36 void FillpConnReqAckTxLog(FILLP_INT sockIndex, FILLP_CONST struct FillpPktConnReqAck *ack, 37 FILLP_CONST FILLP_UCHAR *extPara, FILLP_INT extParaLen); 38 void FillpConnConfirmRxLog(FILLP_INT sockIndex, FILLP_CONST struct FillpPktConnConfirm *confirm, 39 FILLP_CONST FILLP_UCHAR *extPara, FILLP_INT extParaLen); 40 void FillpConnConfirmTxLog(FILLP_INT sockIndex, FILLP_CONST FILLP_UCHAR *data, FILLP_INT dataLen, 41 FILLP_INT extParaOffset); 42 void FillpConnConfirmAckLog(FILLP_INT sockIndex, 43 FILLP_CONST struct FillpPktConnConfirmAck *confirmAck, FILLP_INT direction); 44 void FillpConnFinLog(FILLP_INT sockIndex, FILLP_CONST struct FillpPktFin *fin, FILLP_INT direction); 45 46 #define FILLP_PKT_SIMPLE_LOG(_sockIndex, _hdr, _direction) do { \ 47 /* should check null, because the hdr would be null in tx data */ \ 48 if (_hdr != FILLP_NULL_PTR && g_fillpLmGlobal.mgtMsgLog) { \ 49 FillpPktSimpleLog(_sockIndex, _hdr, _direction); \ 50 } \ 51 } while (0) 52 53 #define FILLP_CONN_REQ_LOG(_sockIndex, _req, _direction) do { \ 54 if (g_fillpLmGlobal.mgtMsgLog) { \ 55 FillpConnReqLog(_sockIndex, _req, _direction); \ 56 } \ 57 } while (0) 58 59 #define FILLP_CONN_REQ_ACK_RX_LOG(_sockIndex, _hdr, _ack, _extParaBuf, _extParaBufLen) do { \ 60 if (g_fillpLmGlobal.mgtMsgLog) { \ 61 FillpConnReqAckRxLog(_sockIndex, _hdr, _ack, _extParaBuf, _extParaBufLen); \ 62 } \ 63 } while (0) 64 65 #define FILLP_CONN_REQ_ACK_TX_LOG(_sockIndex, _ack, _extParaBuf, _extParaBufLen) do { \ 66 if (g_fillpLmGlobal.mgtMsgLog) { \ 67 FillpConnReqAckTxLog(_sockIndex, _ack, _extParaBuf, _extParaBufLen); \ 68 } \ 69 } while (0) 70 71 #define FILLP_CONN_CONFIRM_RX_LOG(_sockIndex, _confirm, _extParaBuf, _extParaBufLen) do { \ 72 if (g_fillpLmGlobal.mgtMsgLog) { \ 73 FillpConnConfirmRxLog(_sockIndex, _confirm, _extParaBuf, _extParaBufLen); \ 74 } \ 75 } while (0) 76 77 #define FILLP_CONN_CONFIRM_TX_LOG(_sockIndex, _data, _dataLen, _extParaOffset) do { \ 78 if (g_fillpLmGlobal.mgtMsgLog) { \ 79 FillpConnConfirmTxLog(_sockIndex, _data, _dataLen, _extParaOffset); \ 80 } \ 81 } while (0) 82 83 #define FILLP_CONN_CONFIRM_ACK_LOG(_sockIndex, _confirmAck, _direction) do { \ 84 if (g_fillpLmGlobal.mgtMsgLog) { \ 85 FillpConnConfirmAckLog(_sockIndex, _confirmAck, _direction); \ 86 } \ 87 } while (0) 88 89 #define FILLP_CONN_FIN_LOG(_sockIndex, _fin, _direction) do { \ 90 if (g_fillpLmGlobal.mgtMsgLog) { \ 91 FillpConnFinLog(_sockIndex, _fin, _direction); \ 92 } \ 93 } while (0) 94 #else 95 #define FILLP_PKT_SIMPLE_LOG(_sockIndex, _hdr, _direction) 96 #define FILLP_CONN_REQ_LOG(_sockIndex, _req, _direction) 97 #define FILLP_CONN_REQ_ACK_RX_LOG(_sockIndex, _hdr, _ack, _extParaBuf, _extParaBufLen) 98 #define FILLP_CONN_REQ_ACK_TX_LOG(_sockIndex, _ack, _extParaBuf, _extParaBufLen) 99 #define FILLP_CONN_CONFIRM_RX_LOG(_sockIndex, _confirm, _extParaBuf, _extParaBufLen) 100 #define FILLP_CONN_CONFIRM_TX_LOG(_sockIndex, _data, _dataLen, _extParaOffset) FILLP_UNUSED_PARA(_extParaOffset) 101 #define FILLP_CONN_CONFIRM_ACK_LOG(_sockIndex, _confirmAck, _direction) 102 #define FILLP_CONN_FIN_LOG(_sockIndex, _fin, _direction) 103 #endif 104 105 #ifdef __cplusplus 106 } 107 #endif 108 109 #endif // FILLP_MGT_MSG_LOG_H