struct netlink_sock {

/* struct sock has to be the first member of netlink_sock */ struct sock sk; u32 pid; u32 dst_pid;

void (*netlink_rcv)(struct sk_buff *skb);

In reality, there are many more netlink-specific elements, and the above code is a selection of the most essential ones.

The sock instance is directly embedded into netlink_sock. Given an instance of struct sock for netlink sockets, the associated netlink-specific structure netlink_socket can be obtained using the auxiliary function nlk_sk. The port IDs of both ends of the connection are kept in pid and dst_pid. netlink_rcv points to a function that is called to receive data.

Message Format

Netlink messages need to obey a certain format as depicted in Figure 12-35.

Message 1

Message 2

struct nlmsg_hdr




Header t t Figure 12-35: Format of a netlink message.


Each message consists of two components: the header and the payload. While the header is required to be represented by struct nlmsghdr, the payload can be arbitrary.37 The required contents of the header are given by the following data structure:

Continue reading here: Info

Was this article helpful?

0 0