mirror of
https://github.com/openvswitch/ovs
synced 2025-08-29 05:18:13 +00:00
41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
|
/* Copyright (c) 2011 Nicira Networks
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at:
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
#ifndef VLAN_BITMAP_H
|
||
|
#define VLAN_BITMAP_H 1
|
||
|
|
||
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
#include "bitmap.h"
|
||
|
|
||
|
/* A "VLAN bitmap" is a 4096-bit bitmap that represents a set. A 1-bit
|
||
|
* indicates that the respective VLAN is a member of the set, a 0-bit indicates
|
||
|
* that it is not. There is one wrinkle: NULL indicates that every VLAN is a
|
||
|
* member of the set.
|
||
|
*
|
||
|
* This is empirically a useful data structure. */
|
||
|
|
||
|
unsigned long *vlan_bitmap_from_array(const int64_t *vlans, size_t n_vlans);
|
||
|
bool vlan_bitmap_equal(const unsigned long *a, const unsigned long *b);
|
||
|
|
||
|
/* Returns true if 'vid', in the range [0,4095], is a member of 'vlans'. */
|
||
|
static inline bool
|
||
|
vlan_bitmap_contains(const unsigned long *vlans, uint16_t vid)
|
||
|
{
|
||
|
return !vlans || bitmap_is_set(vlans, vid);
|
||
|
}
|
||
|
|
||
|
#endif /* lib/vlan-bitmap.h */
|