Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI__LINUX_MROUTE6_H
0003 #define _UAPI__LINUX_MROUTE6_H
0004 
0005 #include <linux/const.h>
0006 #include <linux/types.h>
0007 #include <linux/sockios.h>
0008 #include <linux/in6.h>      /* For struct sockaddr_in6. */
0009 
0010 /*
0011  *  Based on the MROUTING 3.5 defines primarily to keep
0012  *  source compatibility with BSD.
0013  *
0014  *  See the pim6sd code for the original history.
0015  *
0016  *      Protocol Independent Multicast (PIM) data structures included
0017  *      Carlos Picoto (cap@di.fc.ul.pt)
0018  *
0019  */
0020 
0021 #define MRT6_BASE   200
0022 #define MRT6_INIT   (MRT6_BASE) /* Activate the kernel mroute code  */
0023 #define MRT6_DONE   (MRT6_BASE+1)   /* Shutdown the kernel mroute       */
0024 #define MRT6_ADD_MIF    (MRT6_BASE+2)   /* Add a virtual interface      */
0025 #define MRT6_DEL_MIF    (MRT6_BASE+3)   /* Delete a virtual interface       */
0026 #define MRT6_ADD_MFC    (MRT6_BASE+4)   /* Add a multicast forwarding entry */
0027 #define MRT6_DEL_MFC    (MRT6_BASE+5)   /* Delete a multicast forwarding entry  */
0028 #define MRT6_VERSION    (MRT6_BASE+6)   /* Get the kernel multicast version */
0029 #define MRT6_ASSERT (MRT6_BASE+7)   /* Activate PIM assert mode     */
0030 #define MRT6_PIM    (MRT6_BASE+8)   /* enable PIM code          */
0031 #define MRT6_TABLE  (MRT6_BASE+9)   /* Specify mroute table ID      */
0032 #define MRT6_ADD_MFC_PROXY  (MRT6_BASE+10)  /* Add a (*,*|G) mfc entry  */
0033 #define MRT6_DEL_MFC_PROXY  (MRT6_BASE+11)  /* Del a (*,*|G) mfc entry  */
0034 #define MRT6_FLUSH  (MRT6_BASE+12)  /* Flush all mfc entries and/or vifs    */
0035 #define MRT6_MAX    (MRT6_BASE+12)
0036 
0037 #define SIOCGETMIFCNT_IN6   SIOCPROTOPRIVATE    /* IP protocol privates */
0038 #define SIOCGETSGCNT_IN6    (SIOCPROTOPRIVATE+1)
0039 #define SIOCGETRPF  (SIOCPROTOPRIVATE+2)
0040 
0041 /* MRT6_FLUSH optional flags */
0042 #define MRT6_FLUSH_MFC  1   /* Flush multicast entries */
0043 #define MRT6_FLUSH_MFC_STATIC   2   /* Flush static multicast entries */
0044 #define MRT6_FLUSH_MIFS 4   /* Flushing multicast vifs */
0045 #define MRT6_FLUSH_MIFS_STATIC  8   /* Flush static multicast vifs */
0046 
0047 #define MAXMIFS     32
0048 typedef unsigned long mifbitmap_t;  /* User mode code depends on this lot */
0049 typedef unsigned short mifi_t;
0050 #define ALL_MIFS    ((mifi_t)(-1))
0051 
0052 #ifndef IF_SETSIZE
0053 #define IF_SETSIZE  256
0054 #endif
0055 
0056 typedef __u32       if_mask;
0057 #define NIFBITS (sizeof(if_mask) * 8)        /* bits per mask */
0058 
0059 typedef struct if_set {
0060     if_mask ifs_bits[__KERNEL_DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
0061 } if_set;
0062 
0063 #define IF_SET(n, p)    ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
0064 #define IF_CLR(n, p)    ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
0065 #define IF_ISSET(n, p)  ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
0066 #define IF_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
0067 #define IF_ZERO(p)      bzero(p, sizeof(*(p)))
0068 
0069 /*
0070  *  Passed by mrouted for an MRT_ADD_MIF - again we use the
0071  *  mrouted 3.6 structures for compatibility
0072  */
0073 
0074 struct mif6ctl {
0075     mifi_t  mif6c_mifi;     /* Index of MIF */
0076     unsigned char mif6c_flags;  /* MIFF_ flags */
0077     unsigned char vifc_threshold;   /* ttl limit */
0078     __u16    mif6c_pifi;        /* the index of the physical IF */
0079     unsigned int vifc_rate_limit;   /* Rate limiter values (NI) */
0080 };
0081 
0082 #define MIFF_REGISTER   0x1 /* register vif */
0083 
0084 /*
0085  *  Cache manipulation structures for mrouted and PIMd
0086  */
0087 
0088 struct mf6cctl {
0089     struct sockaddr_in6 mf6cc_origin;       /* Origin of mcast  */
0090     struct sockaddr_in6 mf6cc_mcastgrp;     /* Group in question    */
0091     mifi_t  mf6cc_parent;           /* Where it arrived */
0092     struct if_set mf6cc_ifset;      /* Where it is going */
0093 };
0094 
0095 /*
0096  *  Group count retrieval for pim6sd
0097  */
0098 
0099 struct sioc_sg_req6 {
0100     struct sockaddr_in6 src;
0101     struct sockaddr_in6 grp;
0102     unsigned long pktcnt;
0103     unsigned long bytecnt;
0104     unsigned long wrong_if;
0105 };
0106 
0107 /*
0108  *  To get vif packet counts
0109  */
0110 
0111 struct sioc_mif_req6 {
0112     mifi_t  mifi;       /* Which iface */
0113     unsigned long icount;   /* In packets */
0114     unsigned long ocount;   /* Out packets */
0115     unsigned long ibytes;   /* In bytes */
0116     unsigned long obytes;   /* Out bytes */
0117 };
0118 
0119 /*
0120  *  That's all usermode folks
0121  */
0122 
0123 
0124 
0125 /*
0126  * Structure used to communicate from kernel to multicast router.
0127  * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{}
0128  * used for IPv4 implementation). This is because this structure will be passed via an
0129  * IPv6 raw socket, on which an application will only receiver the payload i.e the data after
0130  * the IPv6 header and all the extension headers. (See section 3 of RFC 3542)
0131  */
0132 
0133 struct mrt6msg {
0134 #define MRT6MSG_NOCACHE     1
0135 #define MRT6MSG_WRONGMIF    2
0136 #define MRT6MSG_WHOLEPKT    3       /* used for use level encap */
0137 #define MRT6MSG_WRMIFWHOLE  4       /* For PIM Register and assert processing */
0138     __u8        im6_mbz;        /* must be zero        */
0139     __u8        im6_msgtype;        /* what type of message    */
0140     __u16       im6_mif;        /* mif rec'd on        */
0141     __u32       im6_pad;        /* padding for 64 bit arch */
0142     struct in6_addr im6_src, im6_dst;
0143 };
0144 
0145 /* ip6mr netlink cache report attributes */
0146 enum {
0147     IP6MRA_CREPORT_UNSPEC,
0148     IP6MRA_CREPORT_MSGTYPE,
0149     IP6MRA_CREPORT_MIF_ID,
0150     IP6MRA_CREPORT_SRC_ADDR,
0151     IP6MRA_CREPORT_DST_ADDR,
0152     IP6MRA_CREPORT_PKT,
0153     __IP6MRA_CREPORT_MAX
0154 };
0155 #define IP6MRA_CREPORT_MAX (__IP6MRA_CREPORT_MAX - 1)
0156 
0157 #endif /* _UAPI__LINUX_MROUTE6_H */