igmp.c (b5476022bbada3764609368f03329ca287528dc8) igmp.c (a46182b00290839fa3fa159d54fd3237bd8669f0)
1/*
2 * Linux NET3: Internet Group Management Protocol [IGMP]
3 *
4 * This code implements the IGMP protocol as defined in RFC1112. There has
5 * been a further revision of this protocol since which is now supported.
6 *
7 * If you have trouble with this module be careful what gcc you have used,
8 * the older version didn't come out right using gcc 2.5.8, the newer one

--- 75 unchanged lines hidden (view full) ---

84#include <linux/netdevice.h>
85#include <linux/skbuff.h>
86#include <linux/inetdevice.h>
87#include <linux/igmp.h>
88#include <linux/if_arp.h>
89#include <linux/rtnetlink.h>
90#include <linux/times.h>
91#include <linux/pkt_sched.h>
1/*
2 * Linux NET3: Internet Group Management Protocol [IGMP]
3 *
4 * This code implements the IGMP protocol as defined in RFC1112. There has
5 * been a further revision of this protocol since which is now supported.
6 *
7 * If you have trouble with this module be careful what gcc you have used,
8 * the older version didn't come out right using gcc 2.5.8, the newer one

--- 75 unchanged lines hidden (view full) ---

84#include <linux/netdevice.h>
85#include <linux/skbuff.h>
86#include <linux/inetdevice.h>
87#include <linux/igmp.h>
88#include <linux/if_arp.h>
89#include <linux/rtnetlink.h>
90#include <linux/times.h>
91#include <linux/pkt_sched.h>
92#include <linux/byteorder/generic.h>
92
93#include <net/net_namespace.h>
94#include <net/arp.h>
95#include <net/ip.h>
96#include <net/protocol.h>
97#include <net/route.h>
98#include <net/sock.h>
99#include <net/checksum.h>

--- 216 unchanged lines hidden (view full) ---

316 for (psf = pmc->sources; psf; psf = psf->sf_next) {
317 if (!is_in(pmc, psf, type, gdeleted, sdeleted))
318 continue;
319 scount++;
320 }
321 return scount;
322}
323
93
94#include <net/net_namespace.h>
95#include <net/arp.h>
96#include <net/ip.h>
97#include <net/protocol.h>
98#include <net/route.h>
99#include <net/sock.h>
100#include <net/checksum.h>

--- 216 unchanged lines hidden (view full) ---

317 for (psf = pmc->sources; psf; psf = psf->sf_next) {
318 if (!is_in(pmc, psf, type, gdeleted, sdeleted))
319 continue;
320 scount++;
321 }
322 return scount;
323}
324
325/* source address selection per RFC 3376 section 4.2.13 */
326static __be32 igmpv3_get_srcaddr(struct net_device *dev,
327 const struct flowi4 *fl4)
328{
329 struct in_device *in_dev = __in_dev_get_rcu(dev);
330
331 if (!in_dev)
332 return htonl(INADDR_ANY);
333
334 for_ifa(in_dev) {
335 if (inet_ifa_match(fl4->saddr, ifa))
336 return fl4->saddr;
337 } endfor_ifa(in_dev);
338
339 return htonl(INADDR_ANY);
340}
341
324static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)
325{
326 struct sk_buff *skb;
327 struct rtable *rt;
328 struct iphdr *pip;
329 struct igmpv3_report *pig;
330 struct net *net = dev_net(dev);
331 struct flowi4 fl4;

--- 31 unchanged lines hidden (view full) ---

363 skb_put(skb, sizeof(struct iphdr) + 4);
364
365 pip->version = 4;
366 pip->ihl = (sizeof(struct iphdr)+4)>>2;
367 pip->tos = 0xc0;
368 pip->frag_off = htons(IP_DF);
369 pip->ttl = 1;
370 pip->daddr = fl4.daddr;
342static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)
343{
344 struct sk_buff *skb;
345 struct rtable *rt;
346 struct iphdr *pip;
347 struct igmpv3_report *pig;
348 struct net *net = dev_net(dev);
349 struct flowi4 fl4;

--- 31 unchanged lines hidden (view full) ---

381 skb_put(skb, sizeof(struct iphdr) + 4);
382
383 pip->version = 4;
384 pip->ihl = (sizeof(struct iphdr)+4)>>2;
385 pip->tos = 0xc0;
386 pip->frag_off = htons(IP_DF);
387 pip->ttl = 1;
388 pip->daddr = fl4.daddr;
371 pip->saddr = fl4.saddr;
389 pip->saddr = igmpv3_get_srcaddr(dev, &fl4);
372 pip->protocol = IPPROTO_IGMP;
373 pip->tot_len = 0; /* filled in later */
374 ip_select_ident(net, skb, NULL);
375 ((u8 *)&pip[1])[0] = IPOPT_RA;
376 ((u8 *)&pip[1])[1] = 4;
377 ((u8 *)&pip[1])[2] = 0;
378 ((u8 *)&pip[1])[3] = 0;
379

--- 2676 unchanged lines hidden ---
390 pip->protocol = IPPROTO_IGMP;
391 pip->tot_len = 0; /* filled in later */
392 ip_select_ident(net, skb, NULL);
393 ((u8 *)&pip[1])[0] = IPOPT_RA;
394 ((u8 *)&pip[1])[1] = 4;
395 ((u8 *)&pip[1])[2] = 0;
396 ((u8 *)&pip[1])[3] = 0;
397

--- 2676 unchanged lines hidden ---