1 /* Copyright (c) 2011 Nicira Networks
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #define VLAN_BITMAP_H 1
23 /* A "VLAN bitmap" is a 4096-bit bitmap that represents a set. A 1-bit
24 * indicates that the respective VLAN is a member of the set, a 0-bit indicates
25 * that it is not. There is one wrinkle: NULL is a valid value that indicates
26 * either that all VLANs are or are not members, depending on the vlan_bitmap.
28 * This is empirically a useful data structure. */
30 unsigned long *vlan_bitmap_from_array(const int64_t *vlans, size_t n_vlans);
31 int vlan_bitmap_from_array__(const int64_t *vlans, size_t n_vlans,
32 unsigned long int *b);
34 bool vlan_bitmap_equal(const unsigned long *a, const unsigned long *b);
36 /* Returns a new copy of 'vlans'. */
37 static inline unsigned long *
38 vlan_bitmap_clone(const unsigned long *vlans)
40 return vlans ? bitmap_clone(vlans, 4096) : NULL;
43 #endif /* lib/vlan-bitmap.h */