netifd interface RPC
netifd为每个interface object注册了一组相同的methods,如下:
1
2
3
4
5
6
7
8
9
10
11
|
static
struct
ubus_method
iface_object_methods
[
]
=
{
{
.
name
=
"up"
,
.
handler
=
netifd_handle_up
}
,
{
.
name
=
"down"
,
.
handler
=
netifd_handle_down
}
,
{
.
name
=
"status"
,
.
handler
=
netifd_handle_status
}
,
{
.
name
=
"prepare"
,
.
handler
=
netifd_handle_iface_prepare
}
,
UBUS_METHOD
(
"add_device"
,
netifd_iface_handle_device
,
dev_policy
)
,
UBUS_METHOD
(
"remove_device"
,
netifd_iface_handle_device
,
dev_policy
)
,
{
.
name
=
"notify_proto"
,
.
handler
=
netifd_iface_notify_proto
}
,
{
.
name
=
"remove"
,
.
handler
=
netifd_iface_remove
}
,
{
.
name
=
"set_data"
,
.
handler
=
netifd_handle_set_data
}
,
}
;
|
然后可以发现,netifd里面还有一个protocol handler的概念,也就是对不同的interface protocol,可以提供不同的handler,来响应各种可能的事件。最常见的static类型的protocol,内置在netifd中。而dhcp,pppoe等类型的协议,则以shell script的形式提供。
netifd protocol handler插件
netifd的protocol handler插件位于/lib/netifd/proto/目录下,名称统一为*.sh。