aqhome: added ipc message and calls to set acceptable msg groups for ipc endpoint.
this filters the messages which are copied to the ipc client.
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
msg_ipc_forward.h
|
msg_ipc_forward.h
|
||||||
msg_ipc_value.h
|
msg_ipc_value.h
|
||||||
msg_ipc_ping.h
|
msg_ipc_ping.h
|
||||||
|
msg_ipc_setaccmsggrps.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
|
|
||||||
@@ -70,6 +71,7 @@
|
|||||||
msg_ipc_forward.c
|
msg_ipc_forward.c
|
||||||
msg_ipc_value.c
|
msg_ipc_value.c
|
||||||
msg_ipc_ping.c
|
msg_ipc_ping.c
|
||||||
|
msg_ipc_setaccmsggrps.c
|
||||||
</sources>
|
</sources>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ GWEN_MSG_ENDPOINT *AQH_IpcNodeEndpoint_new(const char *name, int groupId)
|
|||||||
AQH_NodeEndpoint_Extend(ep);
|
AQH_NodeEndpoint_Extend(ep);
|
||||||
GWEN_MsgEndpoint_SetProcessOutMsgFn(ep, _processOutMessage);
|
GWEN_MsgEndpoint_SetProcessOutMsgFn(ep, _processOutMessage);
|
||||||
|
|
||||||
AQH_NodeEndpoint_SetAcceptedMsgGroups(ep, AQH_MSG_TYPEGROUP_ALL);
|
// AQH_NodeEndpoint_SetAcceptedMsgGroups(ep, AQH_MSG_TYPEGROUP_ALL);
|
||||||
|
|
||||||
return ep;
|
return ep;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,10 @@
|
|||||||
#define AQH_IPC_PROTOCOL_VERSION 1
|
#define AQH_IPC_PROTOCOL_VERSION 1
|
||||||
|
|
||||||
|
|
||||||
#define AQH_MSGTYPE_IPC_FORWARD 0x100
|
#define AQH_MSGTYPE_IPC_FORWARD 0x100
|
||||||
#define AQH_MSGTYPE_IPC_VALUE 0x200
|
#define AQH_MSGTYPE_IPC_VALUE 0x200
|
||||||
#define AQH_MSGTYPE_IPC_PING 0x300
|
#define AQH_MSGTYPE_IPC_PING 0x300
|
||||||
|
#define AQH_MSGTYPE_IPC_SETACCMSGGRPS 0x400
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,5 +27,3 @@ AQHOME_API void AQH_PingIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *db
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
72
aqhome/ipc/msg_ipc_setaccmsggrps.c
Normal file
72
aqhome/ipc/msg_ipc_setaccmsggrps.c
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <aqhome/ipc/msg_ipc_setaccmsggrps.h>
|
||||||
|
|
||||||
|
#include <gwenhywfar/msg.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
#include <gwenhywfar/misc.h>
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/error.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
#include <gwenhywfar/text.h>
|
||||||
|
#include <gwenhywfar/msg_ipc.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS 0 /* 4 bytes */
|
||||||
|
|
||||||
|
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t groups)
|
||||||
|
{
|
||||||
|
GWEN_MSG *msg;
|
||||||
|
uint8_t *ptr;
|
||||||
|
|
||||||
|
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_ID, AQH_IPC_PROTOCOL_VERSION, code, AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE, NULL);
|
||||||
|
ptr=GWEN_Msg_GetBuffer(msg);
|
||||||
|
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+0]=groups & 0xff;
|
||||||
|
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+1]=(groups>>8) & 0xff;
|
||||||
|
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+2]=(groups>>16) & 0xff;
|
||||||
|
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+3]=(groups>>24) & 0xff;
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(const GWEN_MSG *msg)
|
||||||
|
{
|
||||||
|
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_SetAcceptedMsgGroupsIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
|
{
|
||||||
|
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE) {
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
|
"SET_ACCEPTED_MSG_GROUPS (code=%d, proto=%d, proto version=%d, groups=%08x)\n",
|
||||||
|
GWEN_IpcMsg_GetCode(msg),
|
||||||
|
GWEN_IpcMsg_GetProtoId(msg),
|
||||||
|
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||||
|
AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
29
aqhome/ipc/msg_ipc_setaccmsggrps.h
Normal file
29
aqhome/ipc/msg_ipc_setaccmsggrps.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQH_MSGIPC_SETACCEPTEDMSGGRPS_H
|
||||||
|
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <aqhome/api.h>
|
||||||
|
#include <aqhome/ipc/msg_ipc.h>
|
||||||
|
|
||||||
|
#include <gwenhywfar/msg.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
AQHOME_API GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t groups);
|
||||||
|
|
||||||
|
AQHOME_API uint32_t AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(const GWEN_MSG *msg);
|
||||||
|
|
||||||
|
AQHOME_API void AQH_SetAcceptedMsgGroupsIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "aqhome/ipc/endpoint_ipc_tcpc.h"
|
#include "aqhome/ipc/endpoint_ipc_tcpc.h"
|
||||||
#include "aqhome/ipc/msg_ipc_ping.h"
|
#include "aqhome/ipc/msg_ipc_ping.h"
|
||||||
#include "aqhome/ipc/msg_ipc_forward.h"
|
#include "aqhome/ipc/msg_ipc_forward.h"
|
||||||
|
#include "aqhome/ipc/msg_ipc_setaccmsggrps.h"
|
||||||
#include "aqhome/mqtt/endpoint_mqttc.h"
|
#include "aqhome/mqtt/endpoint_mqttc.h"
|
||||||
#include "aqhome/mqtt/msg_mqtt_connect.h"
|
#include "aqhome/mqtt/msg_mqtt_connect.h"
|
||||||
#include "aqhome/mqtt/msg_mqtt_connack.h"
|
#include "aqhome/mqtt/msg_mqtt_connack.h"
|
||||||
@@ -289,8 +290,17 @@ int testIpcConnection()
|
|||||||
}
|
}
|
||||||
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTcp);
|
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTcp);
|
||||||
|
|
||||||
|
fprintf(stdout, "Sending SET_ACCEPTABLE_MSG_GROUPS\n");
|
||||||
|
msgOut=AQH_SetAcceptedMsgGroupsIpcMsg_new(AQH_MSGTYPE_IPC_SETACCMSGGRPS, AQH_MSG_TYPEGROUP_ALL);
|
||||||
|
if (msgOut==NULL) {
|
||||||
|
DBG_ERROR(NULL, "Error creating message");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
|
||||||
|
|
||||||
|
|
||||||
fprintf(stdout, "Sending PING\n");
|
fprintf(stdout, "Sending PING\n");
|
||||||
msgOut=AQH_PingIpcMsg_new(AQH_MSGTYPE_IPC_PING, 1);
|
msgOut=AQH_PingIpcMsg_new(AQH_MSGTYPE_IPC_PING, 2);
|
||||||
if (msgOut==NULL) {
|
if (msgOut==NULL) {
|
||||||
DBG_ERROR(NULL, "Error creating message");
|
DBG_ERROR(NULL, "Error creating message");
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
@@ -23,9 +23,11 @@
|
|||||||
#include "aqhome/msg/msg_device.h"
|
#include "aqhome/msg/msg_device.h"
|
||||||
#include "aqhome/msg/msg_ping.h"
|
#include "aqhome/msg/msg_ping.h"
|
||||||
#include "aqhome/msg/endpoint_tty.h"
|
#include "aqhome/msg/endpoint_tty.h"
|
||||||
|
#include "aqhome/msg/endpoint_node.h"
|
||||||
#include "aqhome/mqtt/endpoint_mqttc.h"
|
#include "aqhome/mqtt/endpoint_mqttc.h"
|
||||||
#include "aqhome/ipc/msg_ipc.h"
|
#include "aqhome/ipc/msg_ipc.h"
|
||||||
#include "aqhome/ipc/msg_ipc_ping.h"
|
#include "aqhome/ipc/msg_ipc_ping.h"
|
||||||
|
#include "aqhome/ipc/msg_ipc_setaccmsggrps.h"
|
||||||
|
|
||||||
#include <gwenhywfar/endpoint_tcpc.h>
|
#include <gwenhywfar/endpoint_tcpc.h>
|
||||||
#include <gwenhywfar/endpoint_connectable.h>
|
#include <gwenhywfar/endpoint_connectable.h>
|
||||||
@@ -53,6 +55,7 @@ static void _handleMsgComRecvStat(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT
|
|||||||
static void _handleMsgDevice(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
|
static void _handleMsgDevice(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
|
||||||
|
|
||||||
static void _handleIpcMsgPing(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
|
static void _handleIpcMsgPing(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
|
||||||
|
static void _handleIpcMsgSetAccMsgGrps(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
|
||||||
|
|
||||||
static AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(GWEN_MSG_ENDPOINT_MGR *emgr, const GWEN_MSG *msg, uint32_t uid);
|
static AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(GWEN_MSG_ENDPOINT_MGR *emgr, const GWEN_MSG *msg, uint32_t uid);
|
||||||
|
|
||||||
@@ -237,7 +240,8 @@ void _handleIpcMsg(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWE
|
|||||||
code=GWEN_IpcMsg_GetCode(msg);
|
code=GWEN_IpcMsg_GetCode(msg);
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet");
|
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet");
|
||||||
switch(code) {
|
switch(code) {
|
||||||
case AQH_MSGTYPE_IPC_PING: _handleIpcMsgPing(emgr, ep, msg); break;
|
case AQH_MSGTYPE_IPC_PING: _handleIpcMsgPing(emgr, ep, msg); break;
|
||||||
|
case AQH_MSGTYPE_IPC_SETACCMSGGRPS: _handleIpcMsgSetAccMsgGrps(emgr, ep, msg); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,6 +269,18 @@ void _handleIpcMsgPing(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _handleIpcMsgSetAccMsgGrps(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
|
||||||
|
{
|
||||||
|
uint32_t groups;
|
||||||
|
|
||||||
|
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC SET_ACCEPTED_MSG_GROUPS message");
|
||||||
|
groups=AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(msg);
|
||||||
|
AQH_NodeEndpoint_SetAcceptedMsgGroups(ep, groups);
|
||||||
|
// TODO: send response?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _handleMsgValue2(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
|
void _handleMsgValue2(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
|
||||||
{
|
{
|
||||||
AQH_MSG_MANAGER *xmgr;
|
AQH_MSG_MANAGER *xmgr;
|
||||||
|
|||||||
Reference in New Issue
Block a user