无线/无线自动软件更新(热代码加载)策略
拥有一个 Linux 系统(作为我的项目的一部分),我可能必须在其中进行热代码加载,即通过无线方式(通过 WiFi 下载软件)或通过网络更新部分软件(通过局域网)。该软件有两部分,一部分用 C++ 编写,另一部分用 Erlang 编写。 C++ 部分通过 TCP/IP(一组 6-7 个奇数专有协议)与一些外部实体进行通信。我主要需要进行热加载的部分是与这些外部实体对话的 C++ 部分。 C++ 部分通过端口与 Erlang 进行对话(目前正在开发中),但我想将其更改为 NIF(将来的某个时候)。
有人可以建议一些 C++ 功能的热代码加载策略吗?我知道 Erlang 的能力,但我的理解是该功能不会扩展到用 C++ 编写的部分。
另外,我需要确保包含专有协议实现的 C++ 模块来自“有效来源”。正确的策略是什么?
我想,我的要求并不罕见,所以如果存在这样的模块、框架、库,我会很乐意指出这些。
Have a Linux system (as part of my project), where I might have to do hot-code-loading, i.e. update parts of the software, over-the-air (s.a. downloading the software over WiFi) or over-the-wire (over LAN). There are 2 parts of this software, one part written in C++ and another in Erlang. The C++ part talks to some external entities over TCP/IP (a set of 6-7 odd proprietary protocols). The part which I need to mostly do hot-loading of, is the C++ part that talks to those external entities. The C++ part talks to Erlang over ports (under development currently), but I would like to change that to NIFs (sometime in future).
Can someone suggest some strategies for hot-code-loading of C++ functionality. I am aware of Erlang's ability to do, but my understanding is that the functionality doesn't extend over to the part written in C++.
Also, I need to ensure that the C++ module containing proprietary protocol implementation, is from "valid source". What might be the right strategy for that ?
I guess, my requirements are not uncommon, so if such modules, frameworks, libraries exist, would be happy to be pointed to those.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道是否有任何现有的库。在大多数情况下,C/C++ 中的代码加载是使用动态库完成的,您可以使用 dlopen 从代码中加载动态库。然后你可以使用 dlsym 找到符号的地址。请注意,C++ 确实会进行名称修改,这可能会导致很难找到符号。通常最好创建用 extern“C” 包装的普通函数,为您创建对象,然后您可以像使用任何其他对象一样使用这些对象。
如果您想确定代码有效,您可能应该研究公钥/私钥加密。您使用私钥对代码进行签名(基本上您创建了二进制文件的加密哈希),并且加载代码的软件使用公钥检查签名。
Don't know about any existing libraries for this. Code loading in C/C++ is in most cases done using dynamic libraries which you can load from code using dlopen. Then you can find addresses of symbols using dlsym. Notice that C++ does name mangling which can make it hard to find symbols. Often best to create normal functions wrapped in extern "C" that create objects for you which you can then use just as any other object.
If you want to be certain the code is valid you probably should look into public/private key cryptography. You sign the code with the private key (basically you create an encrypted hash of your binary) and the software loading the code checks the signature using the public key.