linux netlink

好风 发表于 2016-11-30T06:31:36.952209Z
引用地址:https://plus.ooclab.com/note/article/1307

参考

编程接口

C/C++

python

golang

数据格式

struct msghdr

struct msghdr {
    void         *msg_name;       /* optional address */
    socklen_t     msg_namelen;    /* size of address */
    struct iovec *msg_iov;        /* scatter/gather array */
    size_t        msg_iovlen;     /* # elements in msg_iov */
    void         *msg_control;    /* ancillary data, see below */
    size_t        msg_controllen; /* ancillary data buffer len */
    int           msg_flags;      /* flags on received message */
};

struct iovec

struct iovec {                    /* Scatter/gather array items */
    void  *iov_base;              /* Starting address */
    size_t iov_len;               /* Number of bytes to transfer */
};

FAQ

sendto / sendmsg

发送netlink消息的方式, C/C++ 示例多用 sendmsg (具体查看 man sendmsg)。而 golang 示例多用 syscall.Sendto 。这两个发送方式,提供数据是不一样的,请注意!