-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add shared library for sniffing message queue traffic #461
Conversation
This approach is very clever and I think that it's enough to ensure that all messagges are received by the sniffer. |
Hi @roleoroleo, I could rewrite the |
Or we could multiplex to ipc_dispatch_x directly in your lib and remove ipc_multiplexer. There is a "problem" with the new mq_receive: dispatch process opens a lot of queues (/ipc_dispatch, /ipc_rmm, /ipc_cloud, etc...) and receives from /ipc_dispatch and /ipc_dispatch_worker |
I think this should be possible. Every message seems to have a prefix (at least two bytes) indicating its target.
Integrating the librarie's code into
I could try implementing this if it looks good enough for you. |
Yes, check this repo about MID_* defines: https://github.com/roleoroleo/cmd_srv/blob/master/cmd_srv.h
Yes, please. |
40dd664
to
f703517
Compare
Hi, I implemented the mentioned changes. Using a lookup table failed, because the message type is an unsigned short which would result in a huge lookup table. I switched to a simple array and a binary search for finding the message name belonging to a specific message id. The mappings can be adjusted inside The MQTT process should receive the same messages as before on Unfortunately, I won't have time until end of next week to try it out on a device. If you have time and a spare device, you could try it out and leave some feedback 🙂 |
Thank you. EDIT In the meantime I have looked at the code and it is ok. |
f0de989
to
d44c941
Compare
I updated the code for this scenario. Now, the injected shared library just resends the buffer without modifying anything. The receiving side is now responsible for parsing/interpreting the message. I tried it out on a real device, and it seems to work quite well, so far. |
Thank you very much for your code. |
I noticed that sometimes IPC messages were not received in time because another process received them before
ipc_multiplexer
could (race condition). Therefore I implemented a small shared library, which overrides themq_receive
function in such a way, that all messages are also forwarded to a specialipc_sniff
queue, which can later be processed by my previous (modified)ipc_notify
program from #451 .For this to work
dispatch
needs to be started withLD_PRELOAD=/tmp/sd/yi-hack/lib/ipc_sniff.so
prepended.After this step the
ipc_notify
program can be started with a custom script.echo_event.sh
Please note that the parameter to the script is no longer the event name (like in #451) but the raw hex string (e.g
010000000800000081000100000000005
). This means, the script needs to parse the hex message. This way the binary does not have to be recompiled once someone discovers a new type of message.