odp-util: Reuse UUID marshalling for UFID.
[cascardo/ovs.git] / lib / cfm.c
index 23c1c6f..6a507a1 100644 (file)
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #include "byte-order.h"
 #include "connectivity.h"
+#include "dp-packet.h"
 #include "dynamic-string.h"
 #include "flow.h"
 #include "hash.h"
 #include "hmap.h"
 #include "netdev.h"
-#include "ofpbuf.h"
+#include "ovs-atomic.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "random.h"
@@ -563,8 +564,8 @@ cfm_should_send_ccm(struct cfm *cfm) OVS_EXCLUDED(mutex)
 /* Composes a CCM message into 'packet'.  Messages generated with this function
  * should be sent whenever cfm_should_send_ccm() indicates. */
 void
-cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
-                uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
+cfm_compose_ccm(struct cfm *cfm, struct dp_packet *packet,
+                const uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
 {
     uint16_t ccm_vlan;
     struct ccm *ccm;
@@ -586,7 +587,7 @@ cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
 
     atomic_read_relaxed(&cfm->extended, &extended);
 
-    ccm = ofpbuf_l3(packet);
+    ccm = dp_packet_l3(packet);
     ccm->mdlevel_version = 0;
     ccm->opcode = CCM_OPCODE;
     ccm->tlv_offset = 70;
@@ -629,10 +630,12 @@ cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
     ovs_mutex_unlock(&mutex);
 }
 
-void
+long long int
 cfm_wait(struct cfm *cfm) OVS_EXCLUDED(mutex)
 {
-    poll_timer_wait_until(cfm_wake_time(cfm));
+    long long int wake_time = cfm_wake_time(cfm);
+    poll_timer_wait_until(wake_time);
+    return wake_time;
 }
 
 
@@ -747,7 +750,7 @@ cfm_should_process_flow(const struct cfm *cfm_, const struct flow *flow,
  * every packet whose flow returned true when passed to
  * cfm_should_process_flow. */
 void
-cfm_process_heartbeat(struct cfm *cfm, const struct ofpbuf *p)
+cfm_process_heartbeat(struct cfm *cfm, const struct dp_packet *p)
     OVS_EXCLUDED(mutex)
 {
     struct ccm *ccm;
@@ -758,8 +761,8 @@ cfm_process_heartbeat(struct cfm *cfm, const struct ofpbuf *p)
 
     atomic_read_relaxed(&cfm->extended, &extended);
 
-    eth = ofpbuf_l2(p);
-    ccm = ofpbuf_at(p, (uint8_t *)ofpbuf_l3(p) - (uint8_t *)ofpbuf_data(p),
+    eth = dp_packet_l2(p);
+    ccm = dp_packet_at(p, (uint8_t *)dp_packet_l3(p) - (uint8_t *)dp_packet_data(p),
                     CCM_ACCEPT_LEN);
 
     if (!ccm) {