xref: /dragonfly/contrib/wpa_supplicant/src/ap/vlan.c (revision a1626531)
1 /*
2  * hostapd / VLAN definition
3  * Copyright (c) 2016, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #include "utils/includes.h"
10 
11 #include "utils/common.h"
12 #include "ap/vlan.h"
13 
14 /* compare the two arguments, NULL is treated as empty
15  * return zero iff they are equal
16  */
17 int vlan_compare(struct vlan_description *a, struct vlan_description *b)
18 {
19 	int i;
20 	const int a_empty = !a || !a->notempty;
21 	const int b_empty = !b || !b->notempty;
22 
23 	if (a_empty && b_empty)
24 		return 0;
25 	if (a_empty || b_empty)
26 		return 1;
27 	if (a->untagged != b->untagged)
28 		return 1;
29 	for (i = 0; i < MAX_NUM_TAGGED_VLAN; i++) {
30 		if (a->tagged[i] != b->tagged[i])
31 			return 1;
32 	}
33 	return 0;
34 }
35