Christopher Ferris | 2598113 | 2017-11-14 16:53:49 -0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 2 | #ifndef _UAPI__LINUX_MROUTE_H |
| 3 | #define _UAPI__LINUX_MROUTE_H |
| 4 | |
| 5 | #include <linux/sockios.h> |
| 6 | #include <linux/types.h> |
Christopher Ferris | 0543f74 | 2017-07-26 13:09:46 -0700 | [diff] [blame] | 7 | #include <linux/in.h> /* For struct in_addr. */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 8 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 9 | /* Based on the MROUTING 3.5 defines primarily to keep |
| 10 | * source compatibility with BSD. |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 11 | * |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 12 | * See the mrouted code for the original history. |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 13 | * |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 14 | * Protocol Independent Multicast (PIM) data structures included |
| 15 | * Carlos Picoto (cap@di.fc.ul.pt) |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #define MRT_BASE 200 |
| 19 | #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */ |
| 20 | #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */ |
| 21 | #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */ |
| 22 | #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */ |
| 23 | #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */ |
| 24 | #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */ |
| 25 | #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */ |
| 26 | #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */ |
| 27 | #define MRT_PIM (MRT_BASE+8) /* enable PIM code */ |
| 28 | #define MRT_TABLE (MRT_BASE+9) /* Specify mroute table ID */ |
| 29 | #define MRT_ADD_MFC_PROXY (MRT_BASE+10) /* Add a (*,*|G) mfc entry */ |
| 30 | #define MRT_DEL_MFC_PROXY (MRT_BASE+11) /* Del a (*,*|G) mfc entry */ |
| 31 | #define MRT_MAX (MRT_BASE+11) |
| 32 | |
| 33 | #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */ |
| 34 | #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1) |
| 35 | #define SIOCGETRPF (SIOCPROTOPRIVATE+2) |
| 36 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 37 | #define MAXVIFS 32 |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 38 | typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */ |
| 39 | typedef unsigned short vifi_t; |
| 40 | #define ALL_VIFS ((vifi_t)(-1)) |
| 41 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 42 | /* Same idea as select */ |
| 43 | |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 44 | #define VIFM_SET(n,m) ((m)|=(1<<(n))) |
| 45 | #define VIFM_CLR(n,m) ((m)&=~(1<<(n))) |
| 46 | #define VIFM_ISSET(n,m) ((m)&(1<<(n))) |
| 47 | #define VIFM_CLRALL(m) ((m)=0) |
| 48 | #define VIFM_COPY(mfrom,mto) ((mto)=(mfrom)) |
| 49 | #define VIFM_SAME(m1,m2) ((m1)==(m2)) |
| 50 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 51 | /* Passed by mrouted for an MRT_ADD_VIF - again we use the |
| 52 | * mrouted 3.6 structures for compatibility |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 53 | */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 54 | struct vifctl { |
| 55 | vifi_t vifc_vifi; /* Index of VIF */ |
| 56 | unsigned char vifc_flags; /* VIFF_ flags */ |
| 57 | unsigned char vifc_threshold; /* ttl limit */ |
| 58 | unsigned int vifc_rate_limit; /* Rate limiter values (NI) */ |
| 59 | union { |
| 60 | struct in_addr vifc_lcl_addr; /* Local interface address */ |
| 61 | int vifc_lcl_ifindex; /* Local interface index */ |
| 62 | }; |
| 63 | struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */ |
| 64 | }; |
| 65 | |
| 66 | #define VIFF_TUNNEL 0x1 /* IPIP tunnel */ |
| 67 | #define VIFF_SRCRT 0x2 /* NI */ |
| 68 | #define VIFF_REGISTER 0x4 /* register vif */ |
| 69 | #define VIFF_USE_IFINDEX 0x8 /* use vifc_lcl_ifindex instead of |
| 70 | vifc_lcl_addr to find an interface */ |
| 71 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 72 | /* Cache manipulation structures for mrouted and PIMd */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 73 | struct mfcctl { |
| 74 | struct in_addr mfcc_origin; /* Origin of mcast */ |
| 75 | struct in_addr mfcc_mcastgrp; /* Group in question */ |
| 76 | vifi_t mfcc_parent; /* Where it arrived */ |
| 77 | unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */ |
| 78 | unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */ |
| 79 | unsigned int mfcc_byte_cnt; |
| 80 | unsigned int mfcc_wrong_if; |
| 81 | int mfcc_expire; |
| 82 | }; |
| 83 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 84 | /* Group count retrieval for mrouted */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 85 | struct sioc_sg_req { |
| 86 | struct in_addr src; |
| 87 | struct in_addr grp; |
| 88 | unsigned long pktcnt; |
| 89 | unsigned long bytecnt; |
| 90 | unsigned long wrong_if; |
| 91 | }; |
| 92 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 93 | /* To get vif packet counts */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 94 | struct sioc_vif_req { |
| 95 | vifi_t vifi; /* Which iface */ |
| 96 | unsigned long icount; /* In packets */ |
| 97 | unsigned long ocount; /* Out packets */ |
| 98 | unsigned long ibytes; /* In bytes */ |
| 99 | unsigned long obytes; /* Out bytes */ |
| 100 | }; |
| 101 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 102 | /* This is the format the mroute daemon expects to see IGMP control |
| 103 | * data. Magically happens to be like an IP packet as per the original |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 104 | */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 105 | struct igmpmsg { |
| 106 | __u32 unused1,unused2; |
| 107 | unsigned char im_msgtype; /* What is this */ |
| 108 | unsigned char im_mbz; /* Must be zero */ |
| 109 | unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */ |
| 110 | unsigned char unused3; |
| 111 | struct in_addr im_src,im_dst; |
| 112 | }; |
| 113 | |
Christopher Ferris | 2598113 | 2017-11-14 16:53:49 -0800 | [diff] [blame^] | 114 | /* ipmr netlink table attributes */ |
| 115 | enum { |
| 116 | IPMRA_TABLE_UNSPEC, |
| 117 | IPMRA_TABLE_ID, |
| 118 | IPMRA_TABLE_CACHE_RES_QUEUE_LEN, |
| 119 | IPMRA_TABLE_MROUTE_REG_VIF_NUM, |
| 120 | IPMRA_TABLE_MROUTE_DO_ASSERT, |
| 121 | IPMRA_TABLE_MROUTE_DO_PIM, |
| 122 | IPMRA_TABLE_VIFS, |
| 123 | __IPMRA_TABLE_MAX |
| 124 | }; |
| 125 | #define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1) |
| 126 | |
| 127 | /* ipmr netlink vif attribute format |
| 128 | * [ IPMRA_TABLE_VIFS ] - nested attribute |
| 129 | * [ IPMRA_VIF ] - nested attribute |
| 130 | * [ IPMRA_VIFA_xxx ] |
| 131 | */ |
| 132 | enum { |
| 133 | IPMRA_VIF_UNSPEC, |
| 134 | IPMRA_VIF, |
| 135 | __IPMRA_VIF_MAX |
| 136 | }; |
| 137 | #define IPMRA_VIF_MAX (__IPMRA_VIF_MAX - 1) |
| 138 | |
| 139 | /* vif-specific attributes */ |
| 140 | enum { |
| 141 | IPMRA_VIFA_UNSPEC, |
| 142 | IPMRA_VIFA_IFINDEX, |
| 143 | IPMRA_VIFA_VIF_ID, |
| 144 | IPMRA_VIFA_FLAGS, |
| 145 | IPMRA_VIFA_BYTES_IN, |
| 146 | IPMRA_VIFA_BYTES_OUT, |
| 147 | IPMRA_VIFA_PACKETS_IN, |
| 148 | IPMRA_VIFA_PACKETS_OUT, |
| 149 | IPMRA_VIFA_LOCAL_ADDR, |
| 150 | IPMRA_VIFA_REMOTE_ADDR, |
| 151 | IPMRA_VIFA_PAD, |
| 152 | __IPMRA_VIFA_MAX |
| 153 | }; |
| 154 | #define IPMRA_VIFA_MAX (__IPMRA_VIFA_MAX - 1) |
| 155 | |
| 156 | /* ipmr netlink cache report attributes */ |
| 157 | enum { |
| 158 | IPMRA_CREPORT_UNSPEC, |
| 159 | IPMRA_CREPORT_MSGTYPE, |
| 160 | IPMRA_CREPORT_VIF_ID, |
| 161 | IPMRA_CREPORT_SRC_ADDR, |
| 162 | IPMRA_CREPORT_DST_ADDR, |
| 163 | IPMRA_CREPORT_PKT, |
| 164 | __IPMRA_CREPORT_MAX |
| 165 | }; |
| 166 | #define IPMRA_CREPORT_MAX (__IPMRA_CREPORT_MAX - 1) |
| 167 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 168 | /* That's all usermode folks */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 169 | |
| 170 | #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */ |
| 171 | |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 172 | /* Pseudo messages used by mrouted */ |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 173 | #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */ |
| 174 | #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */ |
| 175 | #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */ |
| 176 | |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 177 | #endif /* _UAPI__LINUX_MROUTE_H */ |