16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _UAPI__LINUX_MROUTE6_H 3607ca46eSDavid Howells #define _UAPI__LINUX_MROUTE6_H 4607ca46eSDavid Howells 5a85cbe61SPetr Vorel #include <linux/const.h> 6607ca46eSDavid Howells #include <linux/types.h> 7607ca46eSDavid Howells #include <linux/sockios.h> 872aa107dSDmitry V. Levin #include <linux/in6.h> /* For struct sockaddr_in6. */ 9607ca46eSDavid Howells 10607ca46eSDavid Howells /* 11607ca46eSDavid Howells * Based on the MROUTING 3.5 defines primarily to keep 12607ca46eSDavid Howells * source compatibility with BSD. 13607ca46eSDavid Howells * 14607ca46eSDavid Howells * See the pim6sd code for the original history. 15607ca46eSDavid Howells * 16607ca46eSDavid Howells * Protocol Independent Multicast (PIM) data structures included 17607ca46eSDavid Howells * Carlos Picoto (cap@di.fc.ul.pt) 18607ca46eSDavid Howells * 19607ca46eSDavid Howells */ 20607ca46eSDavid Howells 21607ca46eSDavid Howells #define MRT6_BASE 200 22607ca46eSDavid Howells #define MRT6_INIT (MRT6_BASE) /* Activate the kernel mroute code */ 23607ca46eSDavid Howells #define MRT6_DONE (MRT6_BASE+1) /* Shutdown the kernel mroute */ 24607ca46eSDavid Howells #define MRT6_ADD_MIF (MRT6_BASE+2) /* Add a virtual interface */ 25607ca46eSDavid Howells #define MRT6_DEL_MIF (MRT6_BASE+3) /* Delete a virtual interface */ 26607ca46eSDavid Howells #define MRT6_ADD_MFC (MRT6_BASE+4) /* Add a multicast forwarding entry */ 27607ca46eSDavid Howells #define MRT6_DEL_MFC (MRT6_BASE+5) /* Delete a multicast forwarding entry */ 28607ca46eSDavid Howells #define MRT6_VERSION (MRT6_BASE+6) /* Get the kernel multicast version */ 29607ca46eSDavid Howells #define MRT6_ASSERT (MRT6_BASE+7) /* Activate PIM assert mode */ 30607ca46eSDavid Howells #define MRT6_PIM (MRT6_BASE+8) /* enable PIM code */ 31607ca46eSDavid Howells #define MRT6_TABLE (MRT6_BASE+9) /* Specify mroute table ID */ 32660b26dcSNicolas Dichtel #define MRT6_ADD_MFC_PROXY (MRT6_BASE+10) /* Add a (*,*|G) mfc entry */ 33660b26dcSNicolas Dichtel #define MRT6_DEL_MFC_PROXY (MRT6_BASE+11) /* Del a (*,*|G) mfc entry */ 34ca8d4794SCallum Sinclair #define MRT6_FLUSH (MRT6_BASE+12) /* Flush all mfc entries and/or vifs */ 35ca8d4794SCallum Sinclair #define MRT6_MAX (MRT6_BASE+12) 36607ca46eSDavid Howells 37607ca46eSDavid Howells #define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE /* IP protocol privates */ 38607ca46eSDavid Howells #define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE+1) 39607ca46eSDavid Howells #define SIOCGETRPF (SIOCPROTOPRIVATE+2) 40607ca46eSDavid Howells 41ca8d4794SCallum Sinclair /* MRT6_FLUSH optional flags */ 42ca8d4794SCallum Sinclair #define MRT6_FLUSH_MFC 1 /* Flush multicast entries */ 43ca8d4794SCallum Sinclair #define MRT6_FLUSH_MFC_STATIC 2 /* Flush static multicast entries */ 44ca8d4794SCallum Sinclair #define MRT6_FLUSH_MIFS 4 /* Flushing multicast vifs */ 45ca8d4794SCallum Sinclair #define MRT6_FLUSH_MIFS_STATIC 8 /* Flush static multicast vifs */ 46ca8d4794SCallum Sinclair 47607ca46eSDavid Howells #define MAXMIFS 32 48607ca46eSDavid Howells typedef unsigned long mifbitmap_t; /* User mode code depends on this lot */ 49607ca46eSDavid Howells typedef unsigned short mifi_t; 50607ca46eSDavid Howells #define ALL_MIFS ((mifi_t)(-1)) 51607ca46eSDavid Howells 52607ca46eSDavid Howells #ifndef IF_SETSIZE 53607ca46eSDavid Howells #define IF_SETSIZE 256 54607ca46eSDavid Howells #endif 55607ca46eSDavid Howells 56607ca46eSDavid Howells typedef __u32 if_mask; 57607ca46eSDavid Howells #define NIFBITS (sizeof(if_mask) * 8) /* bits per mask */ 58607ca46eSDavid Howells 59607ca46eSDavid Howells typedef struct if_set { 60b5d3755aSNicolas Dichtel if_mask ifs_bits[__KERNEL_DIV_ROUND_UP(IF_SETSIZE, NIFBITS)]; 61607ca46eSDavid Howells } if_set; 62607ca46eSDavid Howells 63607ca46eSDavid Howells #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS))) 64607ca46eSDavid Howells #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS))) 65607ca46eSDavid Howells #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS))) 66607ca46eSDavid Howells #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f))) 67607ca46eSDavid Howells #define IF_ZERO(p) bzero(p, sizeof(*(p))) 68607ca46eSDavid Howells 69607ca46eSDavid Howells /* 70607ca46eSDavid Howells * Passed by mrouted for an MRT_ADD_MIF - again we use the 71607ca46eSDavid Howells * mrouted 3.6 structures for compatibility 72607ca46eSDavid Howells */ 73607ca46eSDavid Howells 74607ca46eSDavid Howells struct mif6ctl { 75607ca46eSDavid Howells mifi_t mif6c_mifi; /* Index of MIF */ 76607ca46eSDavid Howells unsigned char mif6c_flags; /* MIFF_ flags */ 77607ca46eSDavid Howells unsigned char vifc_threshold; /* ttl limit */ 78607ca46eSDavid Howells __u16 mif6c_pifi; /* the index of the physical IF */ 79607ca46eSDavid Howells unsigned int vifc_rate_limit; /* Rate limiter values (NI) */ 80607ca46eSDavid Howells }; 81607ca46eSDavid Howells 82607ca46eSDavid Howells #define MIFF_REGISTER 0x1 /* register vif */ 83607ca46eSDavid Howells 84607ca46eSDavid Howells /* 85607ca46eSDavid Howells * Cache manipulation structures for mrouted and PIMd 86607ca46eSDavid Howells */ 87607ca46eSDavid Howells 88607ca46eSDavid Howells struct mf6cctl { 89607ca46eSDavid Howells struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */ 90607ca46eSDavid Howells struct sockaddr_in6 mf6cc_mcastgrp; /* Group in question */ 91607ca46eSDavid Howells mifi_t mf6cc_parent; /* Where it arrived */ 92607ca46eSDavid Howells struct if_set mf6cc_ifset; /* Where it is going */ 93607ca46eSDavid Howells }; 94607ca46eSDavid Howells 95607ca46eSDavid Howells /* 96607ca46eSDavid Howells * Group count retrieval for pim6sd 97607ca46eSDavid Howells */ 98607ca46eSDavid Howells 99607ca46eSDavid Howells struct sioc_sg_req6 { 100607ca46eSDavid Howells struct sockaddr_in6 src; 101607ca46eSDavid Howells struct sockaddr_in6 grp; 102607ca46eSDavid Howells unsigned long pktcnt; 103607ca46eSDavid Howells unsigned long bytecnt; 104607ca46eSDavid Howells unsigned long wrong_if; 105607ca46eSDavid Howells }; 106607ca46eSDavid Howells 107607ca46eSDavid Howells /* 108607ca46eSDavid Howells * To get vif packet counts 109607ca46eSDavid Howells */ 110607ca46eSDavid Howells 111607ca46eSDavid Howells struct sioc_mif_req6 { 112607ca46eSDavid Howells mifi_t mifi; /* Which iface */ 113607ca46eSDavid Howells unsigned long icount; /* In packets */ 114607ca46eSDavid Howells unsigned long ocount; /* Out packets */ 115607ca46eSDavid Howells unsigned long ibytes; /* In bytes */ 116607ca46eSDavid Howells unsigned long obytes; /* Out bytes */ 117607ca46eSDavid Howells }; 118607ca46eSDavid Howells 119607ca46eSDavid Howells /* 120607ca46eSDavid Howells * That's all usermode folks 121607ca46eSDavid Howells */ 122607ca46eSDavid Howells 123607ca46eSDavid Howells 124607ca46eSDavid Howells 125607ca46eSDavid Howells /* 126607ca46eSDavid Howells * Structure used to communicate from kernel to multicast router. 127607ca46eSDavid Howells * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{} 128607ca46eSDavid Howells * used for IPv4 implementation). This is because this structure will be passed via an 129607ca46eSDavid Howells * IPv6 raw socket, on which an application will only receiver the payload i.e the data after 130607ca46eSDavid Howells * the IPv6 header and all the extension headers. (See section 3 of RFC 3542) 131607ca46eSDavid Howells */ 132607ca46eSDavid Howells 133607ca46eSDavid Howells struct mrt6msg { 134607ca46eSDavid Howells #define MRT6MSG_NOCACHE 1 135607ca46eSDavid Howells #define MRT6MSG_WRONGMIF 2 136607ca46eSDavid Howells #define MRT6MSG_WHOLEPKT 3 /* used for use level encap */ 137*4b340a5aSMobashshera Rasool #define MRT6MSG_WRMIFWHOLE 4 /* For PIM Register and assert processing */ 138607ca46eSDavid Howells __u8 im6_mbz; /* must be zero */ 139607ca46eSDavid Howells __u8 im6_msgtype; /* what type of message */ 140607ca46eSDavid Howells __u16 im6_mif; /* mif rec'd on */ 141607ca46eSDavid Howells __u32 im6_pad; /* padding for 64 bit arch */ 142607ca46eSDavid Howells struct in6_addr im6_src, im6_dst; 143607ca46eSDavid Howells }; 144607ca46eSDavid Howells 145dd12d15cSJulien Gomes /* ip6mr netlink cache report attributes */ 146dd12d15cSJulien Gomes enum { 147dd12d15cSJulien Gomes IP6MRA_CREPORT_UNSPEC, 148dd12d15cSJulien Gomes IP6MRA_CREPORT_MSGTYPE, 149dd12d15cSJulien Gomes IP6MRA_CREPORT_MIF_ID, 150dd12d15cSJulien Gomes IP6MRA_CREPORT_SRC_ADDR, 151dd12d15cSJulien Gomes IP6MRA_CREPORT_DST_ADDR, 152dd12d15cSJulien Gomes IP6MRA_CREPORT_PKT, 153dd12d15cSJulien Gomes __IP6MRA_CREPORT_MAX 154dd12d15cSJulien Gomes }; 155dd12d15cSJulien Gomes #define IP6MRA_CREPORT_MAX (__IP6MRA_CREPORT_MAX - 1) 156dd12d15cSJulien Gomes 157607ca46eSDavid Howells #endif /* _UAPI__LINUX_MROUTE6_H */ 158