Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI__LINUX_MROUTE_H
0003 #define _UAPI__LINUX_MROUTE_H
0004 
0005 #include <linux/sockios.h>
0006 #include <linux/types.h>
0007 #include <linux/in.h>       /* For struct in_addr. */
0008 
0009 /* Based on the MROUTING 3.5 defines primarily to keep
0010  * source compatibility with BSD.
0011  *
0012  * See the mrouted code for the original history.
0013  *
0014  * Protocol Independent Multicast (PIM) data structures included
0015  * Carlos Picoto (cap@di.fc.ul.pt)
0016  */
0017 
0018 #define MRT_BASE    200
0019 #define MRT_INIT    (MRT_BASE)  /* Activate the kernel mroute code  */
0020 #define MRT_DONE    (MRT_BASE+1)    /* Shutdown the kernel mroute       */
0021 #define MRT_ADD_VIF (MRT_BASE+2)    /* Add a virtual interface      */
0022 #define MRT_DEL_VIF (MRT_BASE+3)    /* Delete a virtual interface       */
0023 #define MRT_ADD_MFC (MRT_BASE+4)    /* Add a multicast forwarding entry */
0024 #define MRT_DEL_MFC (MRT_BASE+5)    /* Delete a multicast forwarding entry  */
0025 #define MRT_VERSION (MRT_BASE+6)    /* Get the kernel multicast version */
0026 #define MRT_ASSERT  (MRT_BASE+7)    /* Activate PIM assert mode     */
0027 #define MRT_PIM     (MRT_BASE+8)    /* enable PIM code          */
0028 #define MRT_TABLE   (MRT_BASE+9)    /* Specify mroute table ID      */
0029 #define MRT_ADD_MFC_PROXY   (MRT_BASE+10)   /* Add a (*,*|G) mfc entry  */
0030 #define MRT_DEL_MFC_PROXY   (MRT_BASE+11)   /* Del a (*,*|G) mfc entry  */
0031 #define MRT_FLUSH   (MRT_BASE+12)   /* Flush all mfc entries and/or vifs    */
0032 #define MRT_MAX     (MRT_BASE+12)
0033 
0034 #define SIOCGETVIFCNT   SIOCPROTOPRIVATE    /* IP protocol privates */
0035 #define SIOCGETSGCNT    (SIOCPROTOPRIVATE+1)
0036 #define SIOCGETRPF  (SIOCPROTOPRIVATE+2)
0037 
0038 /* MRT_FLUSH optional flags */
0039 #define MRT_FLUSH_MFC   1   /* Flush multicast entries */
0040 #define MRT_FLUSH_MFC_STATIC    2   /* Flush static multicast entries */
0041 #define MRT_FLUSH_VIFS  4   /* Flush multicast vifs */
0042 #define MRT_FLUSH_VIFS_STATIC   8   /* Flush static multicast vifs */
0043 
0044 #define MAXVIFS     32
0045 typedef unsigned long vifbitmap_t;  /* User mode code depends on this lot */
0046 typedef unsigned short vifi_t;
0047 #define ALL_VIFS    ((vifi_t)(-1))
0048 
0049 /* Same idea as select */
0050 
0051 #define VIFM_SET(n,m)   ((m)|=(1<<(n)))
0052 #define VIFM_CLR(n,m)   ((m)&=~(1<<(n)))
0053 #define VIFM_ISSET(n,m) ((m)&(1<<(n)))
0054 #define VIFM_CLRALL(m)  ((m)=0)
0055 #define VIFM_COPY(mfrom,mto)    ((mto)=(mfrom))
0056 #define VIFM_SAME(m1,m2)    ((m1)==(m2))
0057 
0058 /* Passed by mrouted for an MRT_ADD_VIF - again we use the
0059  * mrouted 3.6 structures for compatibility
0060  */
0061 struct vifctl {
0062     vifi_t  vifc_vifi;      /* Index of VIF */
0063     unsigned char vifc_flags;   /* VIFF_ flags */
0064     unsigned char vifc_threshold;   /* ttl limit */
0065     unsigned int vifc_rate_limit;   /* Rate limiter values (NI) */
0066     union {
0067         struct in_addr vifc_lcl_addr;     /* Local interface address */
0068         int            vifc_lcl_ifindex;  /* Local interface index   */
0069     };
0070     struct in_addr vifc_rmt_addr;   /* IPIP tunnel addr */
0071 };
0072 
0073 #define VIFF_TUNNEL     0x1 /* IPIP tunnel */
0074 #define VIFF_SRCRT      0x2 /* NI */
0075 #define VIFF_REGISTER       0x4 /* register vif */
0076 #define VIFF_USE_IFINDEX    0x8 /* use vifc_lcl_ifindex instead of
0077                        vifc_lcl_addr to find an interface */
0078 
0079 /* Cache manipulation structures for mrouted and PIMd */
0080 struct mfcctl {
0081     struct in_addr mfcc_origin;     /* Origin of mcast  */
0082     struct in_addr mfcc_mcastgrp;       /* Group in question    */
0083     vifi_t  mfcc_parent;            /* Where it arrived */
0084     unsigned char mfcc_ttls[MAXVIFS];   /* Where it is going    */
0085     unsigned int mfcc_pkt_cnt;      /* pkt count for src-grp */
0086     unsigned int mfcc_byte_cnt;
0087     unsigned int mfcc_wrong_if;
0088     int      mfcc_expire;
0089 };
0090 
0091 /*  Group count retrieval for mrouted */
0092 struct sioc_sg_req {
0093     struct in_addr src;
0094     struct in_addr grp;
0095     unsigned long pktcnt;
0096     unsigned long bytecnt;
0097     unsigned long wrong_if;
0098 };
0099 
0100 /* To get vif packet counts */
0101 struct sioc_vif_req {
0102     vifi_t  vifi;       /* Which iface */
0103     unsigned long icount;   /* In packets */
0104     unsigned long ocount;   /* Out packets */
0105     unsigned long ibytes;   /* In bytes */
0106     unsigned long obytes;   /* Out bytes */
0107 };
0108 
0109 /* This is the format the mroute daemon expects to see IGMP control
0110  * data. Magically happens to be like an IP packet as per the original
0111  */
0112 struct igmpmsg {
0113     __u32 unused1,unused2;
0114     unsigned char im_msgtype;       /* What is this */
0115     unsigned char im_mbz;           /* Must be zero */
0116     unsigned char im_vif;           /* Low 8 bits of Interface */
0117     unsigned char im_vif_hi;        /* High 8 bits of Interface */
0118     struct in_addr im_src,im_dst;
0119 };
0120 
0121 /* ipmr netlink table attributes */
0122 enum {
0123     IPMRA_TABLE_UNSPEC,
0124     IPMRA_TABLE_ID,
0125     IPMRA_TABLE_CACHE_RES_QUEUE_LEN,
0126     IPMRA_TABLE_MROUTE_REG_VIF_NUM,
0127     IPMRA_TABLE_MROUTE_DO_ASSERT,
0128     IPMRA_TABLE_MROUTE_DO_PIM,
0129     IPMRA_TABLE_VIFS,
0130     IPMRA_TABLE_MROUTE_DO_WRVIFWHOLE,
0131     __IPMRA_TABLE_MAX
0132 };
0133 #define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1)
0134 
0135 /* ipmr netlink vif attribute format
0136  * [ IPMRA_TABLE_VIFS ] - nested attribute
0137  *   [ IPMRA_VIF ] - nested attribute
0138  *     [ IPMRA_VIFA_xxx ]
0139  */
0140 enum {
0141     IPMRA_VIF_UNSPEC,
0142     IPMRA_VIF,
0143     __IPMRA_VIF_MAX
0144 };
0145 #define IPMRA_VIF_MAX (__IPMRA_VIF_MAX - 1)
0146 
0147 /* vif-specific attributes */
0148 enum {
0149     IPMRA_VIFA_UNSPEC,
0150     IPMRA_VIFA_IFINDEX,
0151     IPMRA_VIFA_VIF_ID,
0152     IPMRA_VIFA_FLAGS,
0153     IPMRA_VIFA_BYTES_IN,
0154     IPMRA_VIFA_BYTES_OUT,
0155     IPMRA_VIFA_PACKETS_IN,
0156     IPMRA_VIFA_PACKETS_OUT,
0157     IPMRA_VIFA_LOCAL_ADDR,
0158     IPMRA_VIFA_REMOTE_ADDR,
0159     IPMRA_VIFA_PAD,
0160     __IPMRA_VIFA_MAX
0161 };
0162 #define IPMRA_VIFA_MAX (__IPMRA_VIFA_MAX - 1)
0163 
0164 /* ipmr netlink cache report attributes */
0165 enum {
0166     IPMRA_CREPORT_UNSPEC,
0167     IPMRA_CREPORT_MSGTYPE,
0168     IPMRA_CREPORT_VIF_ID,
0169     IPMRA_CREPORT_SRC_ADDR,
0170     IPMRA_CREPORT_DST_ADDR,
0171     IPMRA_CREPORT_PKT,
0172     IPMRA_CREPORT_TABLE,
0173     __IPMRA_CREPORT_MAX
0174 };
0175 #define IPMRA_CREPORT_MAX (__IPMRA_CREPORT_MAX - 1)
0176 
0177 /* That's all usermode folks */
0178 
0179 #define MFC_ASSERT_THRESH (3*HZ)        /* Maximal freq. of asserts */
0180 
0181 /* Pseudo messages used by mrouted */
0182 #define IGMPMSG_NOCACHE     1       /* Kern cache fill request to mrouted */
0183 #define IGMPMSG_WRONGVIF    2       /* For PIM assert processing (unused) */
0184 #define IGMPMSG_WHOLEPKT    3       /* For PIM Register processing */
0185 #define IGMPMSG_WRVIFWHOLE  4       /* For PIM Register and assert processing */
0186 
0187 #endif /* _UAPI__LINUX_MROUTE_H */