/**************************************************************************** * This file is part of the project AqHome. * AqHome (c) by 2023 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. ****************************************************************************/ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include GWEN_MSG *AQH_ForwardMsg_new(uint16_t code, const uint8_t *ptr, uint32_t len) { return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_ID, AQH_IPC_PROTOCOL_VERSION, code, len, ptr); } const uint8_t *AQH_ForwardMsg_GetMsgPtr(const GWEN_MSG *msg) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FORWARD_MINSIZE) return GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_FORWARD_MSG; return NULL; } uint32_t AQH_ForwardMsg_GetMsgLen(const GWEN_MSG *msg) { uint32_t len; len=GWEN_Msg_GetBytesInBuffer(msg); if (len>AQH_MSG_FORWARD_MINSIZE) { return len-AQH_MSG_OFFS_FORWARD_MSG; } return 0; } void AQH_ForwardMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FORWARD_MINSIZE) { const uint8_t *ptr; uint32_t len; ptr=AQH_ForwardMsg_GetMsgPtr(msg); len=AQH_ForwardMsg_GetMsgLen(msg); GWEN_Buffer_AppendArgs(dbuf, "FORWARD (code=%d, protocol=%d, protocol version=%d)\n", GWEN_IpcMsg_GetCode(msg), GWEN_IpcMsg_GetProtoId(msg), GWEN_IpcMsg_GetProtoVersion(msg)); if (ptr && len) { GWEN_Text_DumpString2Buffer(ptr, len, dbuf, 2); GWEN_Buffer_AppendByte(dbuf, '\n'); } } }