2 * Copyright (c) 2008 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef NETLINK_PROTOCOL_H
18 #define NETLINK_PROTOCOL_H 1
20 /* Netlink protocol definitions.
22 * These definitions are equivalent to those in the Linux 2.6 kernel headers,
23 * without requiring those headers to be available. */
26 #include <sys/socket.h>
29 #define NETLINK_GENERIC 16
32 sa_family_t nl_family;
33 unsigned short int nl_pad;
37 BUILD_ASSERT_DECL(sizeof(struct sockaddr_nl) == 12);
39 /* nlmsg_flags bits. */
40 #define NLM_F_REQUEST 0x001
41 #define NLM_F_MULTI 0x002
42 #define NLM_F_ACK 0x004
43 #define NLM_F_ECHO 0x008
45 #define NLM_F_ROOT 0x100
46 #define NLM_F_MATCH 0x200
47 #define NLM_F_ATOMIC 0x400
48 #define NLM_F_DUMP (NLM_F_ROOT | NLM_F_MATCH)
50 /* nlmsg_type values. */
54 #define NLMSG_OVERRUN 4
56 #define NLMSG_MIN_TYPE 0x10
65 BUILD_ASSERT_DECL(sizeof(struct nlmsghdr) == 16);
67 #define NLMSG_ALIGNTO 4
68 #define NLMSG_ALIGN(SIZE) ROUND_UP(SIZE, NLMSG_ALIGNTO)
69 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
76 BUILD_ASSERT_DECL(sizeof(struct nlmsgerr) == 20);
78 #define NETLINK_ADD_MEMBERSHIP 1
79 #define NETLINK_DROP_MEMBERSHIP 2
80 #define NETLINK_PKTINFO 3
87 BUILD_ASSERT_DECL(sizeof(struct genlmsghdr) == 4);
89 #define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
95 BUILD_ASSERT_DECL(sizeof(struct nlattr) == 4);
98 #define NLA_ALIGN(SIZE) ROUND_UP(SIZE, NLA_ALIGNTO)
99 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
101 #define GENL_MIN_ID NLMSG_MIN_TYPE
102 #define GENL_MAX_ID 1023
104 #define GENL_ID_CTRL NLMSG_MIN_TYPE
117 #define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
122 CTRL_ATTR_FAMILY_NAME,
130 #define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
139 #define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
141 #endif /* netlink-protocol.h */