LuCI基本概念
-
UCI 是 Openwrt 中为实现所有系统配置的一个统一接口,英文名
Unified Configuration Interface
,即统一配置接口。轻量级 LUA 语言的官方版本只包括一个精简的核心和最基本的库。这使得 LUA 体积小、启动速度快,从而适合嵌入在别的程序里。 LuCI 即是这两个项目的合体,可以实现路由的网页配置界面。
UCI 是 Openwrt 中为实现所有系统配置的一个统一接口,英文名 Unified Configuration Interface
,即统一配置接口。轻量级 LUA 语言的官方版本只包括一个精简的核心和最基本的库。这使得 LUA 体积小、启动速度快,从而适合嵌入在别的程序里。 LuCI 即是这两个项目的合体,可以实现路由的网页配置界面。
Netifd是OpenWrt中用于进行网络配置的守护进程,基本上所有网络接口设置以及内核的netlink事件都可以由netifd来处理完成。 在启动netifd之前用户需要将所需的配置写入uci配置文件/etc/config/network中,以告知netifd如何设置这些网络接口,如IP地址、上网类型等。如果在netifd运行过程中需要修改配置,则只需更新并保存/etc/config/network,执行/etc/init.d/network reload,netifd便可根据配置文件差异快速地完成网络接口的更新。
上一篇文章介绍了ubus的组件和实现原理,本文通过代码实例介绍使用ubus进行进程间通信的三种方式。
#ifndef __UBUS_INVOKE_H__
#define __UBUS_INVOKE_H__
#include <json/json.h>
#include <libubox/blobmsg_json.h>
struct prog_attr {
char name[64];
int chn_id;
};
#define PROG_MAX 8
#endif /* __UBUS_INVOKE_H__ */
invoke_server.c:
ubus为openwrt平台开发中的进程间通信提供了一个通用的框架。它让进程间通信的实现变得非常简单,并且ubus具有很强的可移植性,可以很方便的移植到其他linux平台上使用。本文描述了ubus的实现原理和整体框架。
From Wikipedia, the free encyclopedia
Jump to navigationJump to search
JSON-RPC is a remote procedure call protocol encoded in JSON. It is similar to the XML-RPC protocol, defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered asynchronously.
Version | Description | Dated |
---|---|---|
1.0 | Original version | 2005 |
1.1 WD | Working draft. Adds named parameters, adds specific error codes, and adds introspection functions. | 2006-08-07 |
1.1 Alt | Suggestion for a simple JSON-RPC 1.1. Alternative proposal to 1.1 WD. | 2007-05-06 |
1.1 Object Specification | Object Specification. Alternative proposal to 1.1 WD/1.1ALT. | 2007-07-30 |
1.2 | Proposal. A later revision of this document was renamed to 2.0. | 2007-12-27 |
2.0 | Specification proposal | 2009-05-24 |
2.0 (Revised-) | Specification | 2010-03-26 |
JSON-RPC works by sending a request to a server implementing this protocol. The client in that case is typically software intending to call a single method of a remote system. Multiple input parameters can be passed to the remote method as an array or object, whereas the method itself can return multiple output data as well. (This depends on the implemented version.)
function PrintTable(table, key, level)
level = level or 1
local indent = ""
for i = 1, level do
indent = indent.." "
end
if key ~= nil then
print(indent..key.." ".."=".." ".."{")
else
print(indent .. "{")
end
for k,v in pairs(table) do
if type(v) == "table" then
PrintTable(v, key, level + 1)
else
local content = string.format("%s%s = %s", indent .. " ",tostring(k), tostring(v))
print(content)
end
end
print(indent .. "}")
end
单行注释:使用“#”
多行注释:使用“#[[ ]]”
以下图为例
#include <time.h>
#include <stdio.h>
int
main(int argc, char *argv[]) {
time_t tt = time(0);
char buf[32] = {0};
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&tt));
return 0;
}