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