2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-19 14:37:21 +00:00
Files
openvswitch/lib/vlan-bitmap.h
Ben Pfaff 2a4ae6357e mac-learning: Change mac_learning_set_flood_vlans() to not take ownership.
These new semantics are less efficient in the case where the flood_vlans
actually changed, but that should be very rare.

There are no advantages to this change on its own, but upcoming commits
will add multiple layers between the code supplying the flood_vlans and
actually calling mac_learning_set_flood_vlans().  Consistency in this
multilayered interface seems valuable, and the rest of it does not transfer
ownership from the caller to the callee.
2011-04-25 17:11:29 -07:00

48 lines
1.5 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);
}
/* Returns a new copy of 'vlans'. */
static inline unsigned long *
vlan_bitmap_clone(const unsigned long *vlans)
{
return vlans ? bitmap_clone(vlans, 4096) : NULL;
}
#endif /* lib/vlan-bitmap.h */