cpp-d1064d
[cross.git] / i686-linux-gnu-4.7 / usr / include / linux / mroute.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_MROUTE_H
3 #define __LINUX_MROUTE_H
4
5 #include <linux/sockios.h>
6 #include <linux/types.h>
7 #include <linux/in.h>           /* For struct in_addr. */
8
9 /* Based on the MROUTING 3.5 defines primarily to keep
10  * source compatibility with BSD.
11  *
12  * See the mrouted code for the original history.
13  *
14  * Protocol Independent Multicast (PIM) data structures included
15  * Carlos Picoto (cap@di.fc.ul.pt)
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
37 #define MAXVIFS         32
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
42 /* Same idea as select */
43
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
51 /* Passed by mrouted for an MRT_ADD_VIF - again we use the
52  * mrouted 3.6 structures for compatibility
53  */
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
72 /* Cache manipulation structures for mrouted and PIMd */
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
84 /*  Group count retrieval for mrouted */
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
93 /* To get vif packet counts */
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
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
104  */
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
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_MROUTE_DO_WRVIFWHOLE,
124         __IPMRA_TABLE_MAX
125 };
126 #define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1)
127
128 /* ipmr netlink vif attribute format
129  * [ IPMRA_TABLE_VIFS ] - nested attribute
130  *   [ IPMRA_VIF ] - nested attribute
131  *     [ IPMRA_VIFA_xxx ]
132  */
133 enum {
134         IPMRA_VIF_UNSPEC,
135         IPMRA_VIF,
136         __IPMRA_VIF_MAX
137 };
138 #define IPMRA_VIF_MAX (__IPMRA_VIF_MAX - 1)
139
140 /* vif-specific attributes */
141 enum {
142         IPMRA_VIFA_UNSPEC,
143         IPMRA_VIFA_IFINDEX,
144         IPMRA_VIFA_VIF_ID,
145         IPMRA_VIFA_FLAGS,
146         IPMRA_VIFA_BYTES_IN,
147         IPMRA_VIFA_BYTES_OUT,
148         IPMRA_VIFA_PACKETS_IN,
149         IPMRA_VIFA_PACKETS_OUT,
150         IPMRA_VIFA_LOCAL_ADDR,
151         IPMRA_VIFA_REMOTE_ADDR,
152         IPMRA_VIFA_PAD,
153         __IPMRA_VIFA_MAX
154 };
155 #define IPMRA_VIFA_MAX (__IPMRA_VIFA_MAX - 1)
156
157 /* ipmr netlink cache report attributes */
158 enum {
159         IPMRA_CREPORT_UNSPEC,
160         IPMRA_CREPORT_MSGTYPE,
161         IPMRA_CREPORT_VIF_ID,
162         IPMRA_CREPORT_SRC_ADDR,
163         IPMRA_CREPORT_DST_ADDR,
164         IPMRA_CREPORT_PKT,
165         __IPMRA_CREPORT_MAX
166 };
167 #define IPMRA_CREPORT_MAX (__IPMRA_CREPORT_MAX - 1)
168
169 /* That's all usermode folks */
170
171 #define MFC_ASSERT_THRESH (3*HZ)                /* Maximal freq. of asserts */
172
173 /* Pseudo messages used by mrouted */
174 #define IGMPMSG_NOCACHE         1               /* Kern cache fill request to mrouted */
175 #define IGMPMSG_WRONGVIF        2               /* For PIM assert processing (unused) */
176 #define IGMPMSG_WHOLEPKT        3               /* For PIM Register processing */
177 #define IGMPMSG_WRVIFWHOLE      4               /* For PIM Register and assert processing */
178
179 #endif /* __LINUX_MROUTE_H */