rtlink消息内存布局如下:
RTM_NEWLINK, RTM_DELLINK, RTM_GETLINK消息示例:
(规则: 每个 "|" 都需要4字节对齐)
+-----------------------------------------------------------------------------------------+
| struct nlmsghdr | struct ifinfomsg | struct rtattr | data | struct rtattr | data | ... |
+-----------------------------------------------------------------------------------------+
+----------------------------------------------+
| netlink socket 数据报(原始数据) |
+----------------------------------------------+
| netlink msg |
+-----------------+----------------------------+
| struct nlmsghdr | netlink data |
+-----------------+----------------------------+
| |
+--> 对齐 +--> 对齐
+----------------------------------------------+
| netlink data |
+----------------------------------------------+
| rtnetlink msg |
+------------------+---------------------------+
| struct ifinfomsg | rtnetlink data |
+------------------+---------------------------+
| |
+--> 对齐 +-->对齐
+---------------------------------------------------+
| rtnetlink data |
+---------------+------+---------------+------+-----+
| struct rtattr | data | struct rtattr | data | ... |
+---------------+------+---------------+------+-----+
| | | | |
| | | | +-->对齐
| | | +--> 对齐
| | +-->对齐
| +--> 对齐
+--> 对齐
图片格式防止乱码