netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / lib / vlan-bitmap.h
1 /* Copyright (c) 2011 Nicira, Inc.
2  *
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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15
16 #ifndef VLAN_BITMAP_H
17 #define VLAN_BITMAP_H 1
18
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "bitmap.h"
22
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.
27  *
28  * This is empirically a useful data structure. */
29
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);
33
34 bool vlan_bitmap_equal(const unsigned long *a, const unsigned long *b);
35
36 /* Returns a new copy of 'vlans'. */
37 static inline unsigned long *
38 vlan_bitmap_clone(const unsigned long *vlans)
39 {
40     return vlans ? bitmap_clone(vlans, 4096) : NULL;
41 }
42
43 #endif /* lib/vlan-bitmap.h */