virtio-net.c (0b1eaa8803e680de9a05727355dfe3d306b81e17) virtio-net.c (f7bc8ef8091229a4bec0e2a40af90abb8dcb3834)
1/*
2 * Virtio Network Device
3 *
4 * Copyright IBM, Corp. 2007
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *

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

217}
218
219static char *mac_strdup_printf(const uint8_t *mac)
220{
221 return g_strdup_printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0],
222 mac[1], mac[2], mac[3], mac[4], mac[5]);
223}
224
1/*
2 * Virtio Network Device
3 *
4 * Copyright IBM, Corp. 2007
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *

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

217}
218
219static char *mac_strdup_printf(const uint8_t *mac)
220{
221 return g_strdup_printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0],
222 mac[1], mac[2], mac[3], mac[4], mac[5]);
223}
224
225static intList *get_vlan_table(VirtIONet *n)
226{
227 intList *list, *entry;
228 int i, j;
229
230 list = NULL;
231 for (i = 0; i < MAX_VLAN >> 5; i++) {
232 for (j = 0; n->vlans[i] && j <= 0x1f; j++) {
233 if (n->vlans[i] & (1U << j)) {
234 entry = g_malloc0(sizeof(*entry));
235 entry->value = (i << 5) + j;
236 entry->next = list;
237 list = entry;
238 }
239 }
240 }
241
242 return list;
243}
244
225static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
226{
227 VirtIONet *n = qemu_get_nic_opaque(nc);
245static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
246{
247 VirtIONet *n = qemu_get_nic_opaque(nc);
248 VirtIODevice *vdev = VIRTIO_DEVICE(n);
228 RxFilterInfo *info;
229 strList *str_list, *entry;
249 RxFilterInfo *info;
250 strList *str_list, *entry;
230 intList *int_list, *int_entry;
231 int i, j;
251 int i;
232
233 info = g_malloc0(sizeof(*info));
234 info->name = g_strdup(nc->name);
235 info->promiscuous = n->promisc;
236
237 if (n->nouni) {
238 info->unicast = RX_STATE_NONE;
239 } else if (n->alluni) {

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

268 str_list = NULL;
269 for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) {
270 entry = g_malloc0(sizeof(*entry));
271 entry->value = mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN);
272 entry->next = str_list;
273 str_list = entry;
274 }
275 info->multicast_table = str_list;
252
253 info = g_malloc0(sizeof(*info));
254 info->name = g_strdup(nc->name);
255 info->promiscuous = n->promisc;
256
257 if (n->nouni) {
258 info->unicast = RX_STATE_NONE;
259 } else if (n->alluni) {

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

288 str_list = NULL;
289 for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) {
290 entry = g_malloc0(sizeof(*entry));
291 entry->value = mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN);
292 entry->next = str_list;
293 str_list = entry;
294 }
295 info->multicast_table = str_list;
296 info->vlan_table = get_vlan_table(n);
276
297
277 int_list = NULL;
278 for (i = 0; i < MAX_VLAN >> 5; i++) {
279 for (j = 0; n->vlans[i] && j < 0x1f; j++) {
280 if (n->vlans[i] & (1U << j)) {
281 int_entry = g_malloc0(sizeof(*int_entry));
282 int_entry->value = (i << 5) + j;
283 int_entry->next = int_list;
284 int_list = int_entry;
285 }
286 }
298 if (!((1 << VIRTIO_NET_F_CTRL_VLAN) & vdev->guest_features)) {
299 info->vlan = RX_STATE_ALL;
300 } else if (!info->vlan_table) {
301 info->vlan = RX_STATE_NONE;
302 } else {
303 info->vlan = RX_STATE_NORMAL;
287 }
304 }
288 info->vlan_table = int_list;
289
290 /* enable event notification after query */
291 nc->rxfilter_notify_enabled = 1;
292
293 return info;
294}
295
296static void virtio_net_reset(VirtIODevice *vdev)

--- 1379 unchanged lines hidden ---
305
306 /* enable event notification after query */
307 nc->rxfilter_notify_enabled = 1;
308
309 return info;
310}
311
312static void virtio_net_reset(VirtIODevice *vdev)

--- 1379 unchanged lines hidden ---