packets: Create global helper is_ip_any().
[sliver-openvswitch.git] / lib / packets.c
index fa73b50..fa73282 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
 
 #include <config.h>
 #include "packets.h"
-#include <assert.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -273,12 +272,12 @@ ip_count_cidr_bits(ovs_be32 netmask)
 void
 ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *s)
 {
-    ds_put_format(s, IP_FMT, IP_ARGS(&ip));
+    ds_put_format(s, IP_FMT, IP_ARGS(ip));
     if (mask != htonl(UINT32_MAX)) {
         if (ip_is_cidr(mask)) {
             ds_put_format(s, "/%d", ip_count_cidr_bits(mask));
         } else {
-            ds_put_format(s, "/"IP_FMT, IP_ARGS(&mask));
+            ds_put_format(s, "/"IP_FMT, IP_ARGS(mask));
         }
     }
 }
@@ -711,9 +710,7 @@ packet_set_udp_port(struct ofpbuf *packet, ovs_be16 src, ovs_be16 dst)
 uint8_t
 packet_get_tcp_flags(const struct ofpbuf *packet, const struct flow *flow)
 {
-    if ((flow->dl_type == htons(ETH_TYPE_IP) ||
-         flow->dl_type == htons(ETH_TYPE_IPV6)) &&
-        flow->nw_proto == IPPROTO_TCP && packet->l7) {
+    if (is_ip_any(flow) && flow->nw_proto == IPPROTO_TCP && packet->l7) {
         const struct tcp_header *tcp = packet->l4;
         return TCP_FLAGS(tcp->tcp_ctl);
     } else {