blob: 10f9ff9426a220b700ea4c50219412e6389817d1 [file] [log] [blame]
Christopher Ferris25981132017-11-14 16:53:49 -08001/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Ben Cheng30692c62013-10-15 18:26:18 -07002#ifndef _UAPI__LINUX_MROUTE_H
3#define _UAPI__LINUX_MROUTE_H
4
5#include <linux/sockios.h>
6#include <linux/types.h>
Christopher Ferris0543f742017-07-26 13:09:46 -07007#include <linux/in.h> /* For struct in_addr. */
Ben Cheng30692c62013-10-15 18:26:18 -07008
Christopher Ferrisccfaccd2016-08-24 12:11:31 -07009/* Based on the MROUTING 3.5 defines primarily to keep
10 * source compatibility with BSD.
Ben Cheng30692c62013-10-15 18:26:18 -070011 *
Christopher Ferrisccfaccd2016-08-24 12:11:31 -070012 * See the mrouted code for the original history.
Ben Cheng30692c62013-10-15 18:26:18 -070013 *
Christopher Ferrisccfaccd2016-08-24 12:11:31 -070014 * Protocol Independent Multicast (PIM) data structures included
15 * Carlos Picoto (cap@di.fc.ul.pt)
Ben Cheng30692c62013-10-15 18:26:18 -070016 */
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 Ferrisccfaccd2016-08-24 12:11:31 -070037#define MAXVIFS 32
Ben Cheng30692c62013-10-15 18:26:18 -070038typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */
39typedef unsigned short vifi_t;
40#define ALL_VIFS ((vifi_t)(-1))
41
Christopher Ferrisccfaccd2016-08-24 12:11:31 -070042/* Same idea as select */
43
Ben Cheng30692c62013-10-15 18:26:18 -070044#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 Ferrisccfaccd2016-08-24 12:11:31 -070051/* Passed by mrouted for an MRT_ADD_VIF - again we use the
52 * mrouted 3.6 structures for compatibility
Ben Cheng30692c62013-10-15 18:26:18 -070053 */
Ben Cheng30692c62013-10-15 18:26:18 -070054struct 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 Ferrisccfaccd2016-08-24 12:11:31 -070072/* Cache manipulation structures for mrouted and PIMd */
Ben Cheng30692c62013-10-15 18:26:18 -070073struct 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 Ferrisccfaccd2016-08-24 12:11:31 -070084/* Group count retrieval for mrouted */
Ben Cheng30692c62013-10-15 18:26:18 -070085struct 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 Ferrisccfaccd2016-08-24 12:11:31 -070093/* To get vif packet counts */
Ben Cheng30692c62013-10-15 18:26:18 -070094struct 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 Ferrisccfaccd2016-08-24 12:11:31 -0700102/* 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 Cheng30692c62013-10-15 18:26:18 -0700104 */
Ben Cheng30692c62013-10-15 18:26:18 -0700105struct 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 Ferris25981132017-11-14 16:53:49 -0800114/* ipmr netlink table attributes */
115enum {
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 */
132enum {
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 */
140enum {
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 */
157enum {
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 Ferrisccfaccd2016-08-24 12:11:31 -0700168/* That's all usermode folks */
Ben Cheng30692c62013-10-15 18:26:18 -0700169
170#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
171
Christopher Ferrisccfaccd2016-08-24 12:11:31 -0700172/* Pseudo messages used by mrouted */
Ben Cheng30692c62013-10-15 18:26:18 -0700173#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 Cheng30692c62013-10-15 18:26:18 -0700177#endif /* _UAPI__LINUX_MROUTE_H */