[ovs-dev] [PATCHv2 1/2] packets: Adds ethernet-matching helper functions

Ben Pfaff blp at nicira.com
Tue May 29 18:08:44 UTC 2012


On Tue, May 29, 2012 at 12:38:11AM +1200, Joe Stringer wrote:
> With OpenFlow 1.1 requiring arbitrary ethernet match support, it simplifies
> other code if we have some extra helper functions. This patch adds
> eth_mask_is_exact(mask), eth_addr_bitand(src, mask, dst),
> eth_addr_equal_except(a, b, mask) and eth_format_masked(eth, mask, output).
> 
> Signed-off-by: Joe Stringer <joe at wand.net.nz>

Thank you!  I applied this to master.  I made the following tweak to
better fit the existing style elsewhere.  I also added you to AUTHORS.

diff --git a/lib/packets.c b/lib/packets.c
index be36f29..b385128 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -158,12 +158,14 @@ eth_format_masked(const uint8_t eth[ETH_ADDR_LEN],
     }
 }
 
-void eth_addr_bitand(const uint8_t src[ETH_ADDR_LEN],
-                     const uint8_t mask[ETH_ADDR_LEN],
-                     uint8_t dst[ETH_ADDR_LEN])
+void
+eth_addr_bitand(const uint8_t src[ETH_ADDR_LEN],
+                const uint8_t mask[ETH_ADDR_LEN],
+                uint8_t dst[ETH_ADDR_LEN])
 {
-    int i = 0;
-    for (; i < ETH_ADDR_LEN; ++i) {
+    int i;
+
+    for (i = 0; i < ETH_ADDR_LEN; i++) {
         dst[i] = src[i] & mask[i];
     }
 }



More information about the dev mailing list