1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022 Alexander V. Chernikov <melifaro@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 /* 29 * Neighbors-related (RTM_<NEW|DEL|GET>NEIGH) message header and attributes. 30 */ 31 32 #ifndef _NETLINK_ROUTE_NEIGH_H_ 33 #define _NETLINK_ROUTE_NEIGH_H_ 34 35 /* Base header for all of the relevant messages */ 36 struct ndmsg { 37 uint8_t ndm_family; 38 uint8_t ndm_pad1; 39 uint16_t ndm_pad2; 40 int32_t ndm_ifindex; 41 uint16_t ndm_state; 42 uint8_t ndm_flags; 43 uint8_t ndm_type; 44 }; 45 46 /* Attributes */ 47 enum { 48 NDA_UNSPEC, 49 NDA_DST, /* binary: neigh l3 address */ 50 NDA_LLADDR, /* binary: neigh link-level address */ 51 NDA_CACHEINFO, /* binary, struct nda_cacheinfo */ 52 NDA_PROBES, /* u32: number of probes sent */ 53 NDA_VLAN, /* upper 802.1Q tag */ 54 NDA_PORT, /* not supported */ 55 NDA_VNI, /* not supported */ 56 NDA_IFINDEX, /* interface index */ 57 NDA_MASTER, /* not supported */ 58 NDA_LINK_NETNSID, /* not supported */ 59 NDA_SRC_VNI, /* not supported */ 60 NDA_PROTOCOL, /* XXX */ 61 NDA_NH_ID, /* not supported */ 62 NDA_FDB_EXT_ATTRS, /* not supported */ 63 NDA_FLAGS_EXT, /* u32: ndm_flags */ 64 NDA_NDM_STATE_MASK, /* XXX */ 65 NDA_NDM_FLAGS_MASK, /* XXX */ 66 NDA_FREEBSD, /* nested: FreeBSD-specific */ 67 __NDA_MAX 68 }; 69 70 #define NDA_MAX (__NDA_MAX - 1) 71 72 enum { 73 NDAF_UNSPEC, 74 NDAF_NEXT_STATE_TS, /* (u32) seconds from time_uptime when moving to the next state */ 75 }; 76 77 78 /* ndm_flags / NDA_FLAGS_EXT */ 79 #define NTF_USE 0x0001 /* XXX */ 80 #define NTF_SELF 0x0002 /* local station */ 81 #define NTF_MASTER 0x0004 /* XXX */ 82 #define NTF_PROXY 0x0008 /* proxy entry */ 83 #define NTF_EXT_LEARNED 0x0010 /* not used */ 84 #define NTF_OFFLOADED 0x0020 /* not used */ 85 #define NTF_STICKY 0x0040 /* permament entry */ 86 #define NTF_ROUTER 0x0080 /* dst indicated itself as a router */ 87 /* start of NDA_FLAGS_EXT */ 88 #define NTF_EXT_MANAGED 0x0100 /* not used */ 89 90 /* ndm_state */ 91 #define NUD_INCOMPLETE 0x01 /* No lladdr, address resolution in progress */ 92 #define NUD_REACHABLE 0x02 /* reachable & recently resolved */ 93 #define NUD_STALE 0x04 /* has lladdr but it's stale */ 94 #define NUD_DELAY 0x08 /* has lladdr, is stale, probes delayed */ 95 #define NUD_PROBE 0x10 /* has lladdr, is stale, probes sent */ 96 #define NUD_FAILED 0x20 /* unused */ 97 98 /* Dummy states */ 99 #define NUD_NOARP 0x40 /* not used */ 100 #define NUD_PERMANENT 0x80 /* not flushed */ 101 #define NUD_NONE 0x00 102 103 /* NDA_CACHEINFO */ 104 struct nda_cacheinfo { 105 uint32_t ndm_confirmed; /* seconds since ARP/ND was received from neigh */ 106 uint32_t ndm_used; /* seconds since last used (not provided) */ 107 uint32_t ndm_updated; /* seconds since state was updated last */ 108 uint32_t ndm_refcnt; /* number of references held */ 109 }; 110 111 #endif 112