cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

igmp.h (4433B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2/*
      3 *	Linux NET3:	Internet Group Management Protocol  [IGMP]
      4 *
      5 *	Authors:
      6 *		Alan Cox <alan@lxorguk.ukuu.org.uk>
      7 *
      8 *	Extended to talk the BSD extended IGMP protocol of mrouted 3.6
      9 */
     10#ifndef _LINUX_IGMP_H
     11#define _LINUX_IGMP_H
     12
     13#include <linux/skbuff.h>
     14#include <linux/timer.h>
     15#include <linux/in.h>
     16#include <linux/ip.h>
     17#include <linux/refcount.h>
     18#include <uapi/linux/igmp.h>
     19
     20static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
     21{
     22	return (struct igmphdr *)skb_transport_header(skb);
     23}
     24
     25static inline struct igmpv3_report *
     26			igmpv3_report_hdr(const struct sk_buff *skb)
     27{
     28	return (struct igmpv3_report *)skb_transport_header(skb);
     29}
     30
     31static inline struct igmpv3_query *
     32			igmpv3_query_hdr(const struct sk_buff *skb)
     33{
     34	return (struct igmpv3_query *)skb_transport_header(skb);
     35}
     36
     37struct ip_sf_socklist {
     38	unsigned int		sl_max;
     39	unsigned int		sl_count;
     40	struct rcu_head		rcu;
     41	__be32			sl_addr[];
     42};
     43
     44#define IP_SFBLOCK	10	/* allocate this many at once */
     45
     46/* ip_mc_socklist is real list now. Speed is not argument;
     47   this list never used in fast path code
     48 */
     49
     50struct ip_mc_socklist {
     51	struct ip_mc_socklist __rcu *next_rcu;
     52	struct ip_mreqn		multi;
     53	unsigned int		sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
     54	struct ip_sf_socklist __rcu	*sflist;
     55	struct rcu_head		rcu;
     56};
     57
     58struct ip_sf_list {
     59	struct ip_sf_list	*sf_next;
     60	unsigned long		sf_count[2];	/* include/exclude counts */
     61	__be32			sf_inaddr;
     62	unsigned char		sf_gsresp;	/* include in g & s response? */
     63	unsigned char		sf_oldin;	/* change state */
     64	unsigned char		sf_crcount;	/* retrans. left to send */
     65};
     66
     67struct ip_mc_list {
     68	struct in_device	*interface;
     69	__be32			multiaddr;
     70	unsigned int		sfmode;
     71	struct ip_sf_list	*sources;
     72	struct ip_sf_list	*tomb;
     73	unsigned long		sfcount[2];
     74	union {
     75		struct ip_mc_list *next;
     76		struct ip_mc_list __rcu *next_rcu;
     77	};
     78	struct ip_mc_list __rcu *next_hash;
     79	struct timer_list	timer;
     80	int			users;
     81	refcount_t		refcnt;
     82	spinlock_t		lock;
     83	char			tm_running;
     84	char			reporter;
     85	char			unsolicit_count;
     86	char			loaded;
     87	unsigned char		gsquery;	/* check source marks? */
     88	unsigned char		crcount;
     89	struct rcu_head		rcu;
     90};
     91
     92/* V3 exponential field decoding */
     93#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
     94#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
     95	((value) < (thresh) ? (value) : \
     96        ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \
     97         (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
     98
     99#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
    100#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
    101
    102static inline int ip_mc_may_pull(struct sk_buff *skb, unsigned int len)
    103{
    104	if (skb_transport_offset(skb) + ip_transport_len(skb) < len)
    105		return 0;
    106
    107	return pskb_may_pull(skb, len);
    108}
    109
    110extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto);
    111extern int igmp_rcv(struct sk_buff *);
    112extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
    113extern int ip_mc_join_group_ssm(struct sock *sk, struct ip_mreqn *imr,
    114				unsigned int mode);
    115extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
    116extern void ip_mc_drop_socket(struct sock *sk);
    117extern int ip_mc_source(int add, int omode, struct sock *sk,
    118		struct ip_mreq_source *mreqs, int ifindex);
    119extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
    120extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
    121		struct ip_msfilter __user *optval, int __user *optlen);
    122extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
    123			struct sockaddr_storage __user *p);
    124extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt,
    125			  int dif, int sdif);
    126extern void ip_mc_init_dev(struct in_device *);
    127extern void ip_mc_destroy_dev(struct in_device *);
    128extern void ip_mc_up(struct in_device *);
    129extern void ip_mc_down(struct in_device *);
    130extern void ip_mc_unmap(struct in_device *);
    131extern void ip_mc_remap(struct in_device *);
    132extern void __ip_mc_dec_group(struct in_device *in_dev, __be32 addr, gfp_t gfp);
    133static inline void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
    134{
    135	return __ip_mc_dec_group(in_dev, addr, GFP_KERNEL);
    136}
    137extern void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
    138			      gfp_t gfp);
    139extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
    140int ip_mc_check_igmp(struct sk_buff *skb);
    141
    142#endif