This source file includes following definitions.
- dev_mc_upload
- dev_mc_delete
- dev_mc_add
- dev_mc_discard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <asm/segment.h>
24 #include <asm/system.h>
25 #include <asm/bitops.h>
26 #include <linux/types.h>
27 #include <linux/kernel.h>
28 #include <linux/sched.h>
29 #include <linux/string.h>
30 #include <linux/mm.h>
31 #include <linux/socket.h>
32 #include <linux/sockios.h>
33 #include <linux/in.h>
34 #include <linux/errno.h>
35 #include <linux/interrupt.h>
36 #include <linux/if_ether.h>
37 #include <linux/inet.h>
38 #include <linux/netdevice.h>
39 #include <linux/etherdevice.h>
40 #include <net/ip.h>
41 #include <net/route.h>
42 #include <linux/skbuff.h>
43 #include <net/sock.h>
44 #include <net/arp.h>
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 void dev_mc_upload(struct device *dev)
63 {
64
65
66
67
68 if(!(dev->flags&IFF_UP))
69 return;
70
71
72
73
74
75 if(dev->set_multicast_list==NULL)
76 return;
77
78 dev->set_multicast_list(dev);
79 }
80
81
82
83
84
85 void dev_mc_delete(struct device *dev, void *addr, int alen, int all)
86 {
87 struct dev_mc_list **dmi;
88 for(dmi=&dev->mc_list;*dmi!=NULL;dmi=&(*dmi)->next)
89 {
90 if(memcmp((*dmi)->dmi_addr,addr,(*dmi)->dmi_addrlen)==0 && alen==(*dmi)->dmi_addrlen)
91 {
92 struct dev_mc_list *tmp= *dmi;
93 if(--(*dmi)->dmi_users && !all)
94 return;
95 *dmi=(*dmi)->next;
96 dev->mc_count--;
97 kfree_s(tmp,sizeof(*tmp));
98 dev_mc_upload(dev);
99 return;
100 }
101 }
102 }
103
104
105
106
107
108 void dev_mc_add(struct device *dev, void *addr, int alen, int newonly)
109 {
110 struct dev_mc_list *dmi;
111 for(dmi=dev->mc_list;dmi!=NULL;dmi=dmi->next)
112 {
113 if(memcmp(dmi->dmi_addr,addr,dmi->dmi_addrlen)==0 && dmi->dmi_addrlen==alen)
114 {
115 if(!newonly)
116 dmi->dmi_users++;
117 return;
118 }
119 }
120 dmi=(struct dev_mc_list *)kmalloc(sizeof(*dmi),GFP_KERNEL);
121 if(dmi==NULL)
122 return;
123 memcpy(dmi->dmi_addr, addr, alen);
124 dmi->dmi_addrlen=alen;
125 dmi->next=dev->mc_list;
126 dmi->dmi_users=1;
127 dev->mc_list=dmi;
128 dev->mc_count++;
129 dev_mc_upload(dev);
130 }
131
132
133
134
135
136 void dev_mc_discard(struct device *dev)
137 {
138 while(dev->mc_list!=NULL)
139 {
140 struct dev_mc_list *tmp=dev->mc_list;
141 dev->mc_list=dev->mc_list->next;
142 kfree_s(tmp,sizeof(*tmp));
143 }
144 dev->mc_count=0;
145 }