/* $FreeBSD$ */ /*- * Copyright (c) 2007 Bruce M. Simpson. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Netlink Protocol [RFC 3549]. * * This is an implementation of the Netlink Protocol for FreeBSD as * documented within RFC 3549. * * BSD's struct sockaddr_nl is not byte-for-byte compatible with that * of Linux, as BSD must be able to type-pun pointers to struct sockaddr. */ #ifndef _NET_NETLINK_H_ #define _NET_NETLINK_H_ #include #include #define NETLINK_ROUTE 0 #define NETLINK_UNUSED 1 #define MAX_LINKS 32 struct sockaddr_nl { unsigned char snl_len; /* sizeof(struct sockaddr_nl) */ sa_family_t snl_family; /* AF_NETLINK */ uint16_t snl_pad; /* zero */ uint32_t snl_pid; /* Port ID */ uint32_t snl_groups; /* Group membership mask */ }; struct nlmsghdr { uint32_t nlmsg_len; uint16_t nlmsg_type; uint16_t nlmsg_flags; uint32_t nlmsg_seq; uint32_t nlmsg_pid; }; #define NLM_F_REQUEST 0x0001 #define NLM_F_MULTI 0x0002 #define NLM_F_ACK 0x0004 #define NLM_F_ECHO 0x0008 #define NLM_F_ROOT 0x0100 #define NLM_F_MATCH 0x0200 #define NLM_F_ATOMIC 0x0400 #define NLM_F_REPLACE 0x0100 #define NLM_F_EXCL 0x0200 #define NLM_F_CREATE 0x0400 #define NLM_F_APPEND 0x0800 #define NLMSG_ALIGNTO sizeof(uint32_t) #define NLMSG_ALIGN(x) (((x) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1)) /* TODO alignment stuff a la CMSG */ #define NLMSG_NOOP 0x01 #define NLMSG_ERROR 0x02 #define NLMSG_DONE 0x03 #define NLMSG_OVERRUN 0x04 #define NLMSG_MIN_TYPE 0x10 struct nlmsgerr { int error; struct nlmsghdr msg; }; #define NETLINK_ADD_MEMBERSHIP 1 #define NETLINK_DROP_MEMBERSHIP 2 #define NETLINK_PKTINFO 3 struct nl_pktinfo { uint32_t group; }; struct nlattr { uint16_t nla_len; uint16_t nla_type; }; #ifdef _KERNEL /* Kernel internals go here. mbufs, not skbufs. */ #endif /* _KERNEL */ #endif /* _NET_NETLINK_H_ */