summaryrefslogtreecommitdiff
path: root/lib/cfm.c
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2011-05-13 18:11:43 -0700
committerEthan Jackson <ethan@nicira.com>2011-05-20 15:53:29 -0700
commitc0a2e71d110ad2af474232e03ea9ad94cbbae46f (patch)
treeca166b7090da798a243e4dfde7ff500554f28675 /lib/cfm.c
parenta56104575c4db202bfc5db3079ea969820d77867 (diff)
downloadopenvswitch-c0a2e71d110ad2af474232e03ea9ad94cbbae46f.tar.gz
cfm: Remove packet definition from CFM header file.
This patch makes a stylistic improvement by removing CFM protocol information from cfm.h. In the process it changes cfm_compose_ccm() to populate an ofpbuf instead of a struct ccm.
Diffstat (limited to 'lib/cfm.c')
-rw-r--r--lib/cfm.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/cfm.c b/lib/cfm.c
index 85af22c42..46481507a 100644
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -36,7 +36,28 @@
VLOG_DEFINE_THIS_MODULE(cfm);
-#define CCM_OPCODE 1 /* CFM message opcode meaning CCM. */
+/* Ethernet destination address of CCM packets. */
+static const uint8_t eth_addr_ccm[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x30 };
+
+#define ETH_TYPE_CFM 0x8902
+
+/* A 'ccm' represents a Continuity Check Message from the 802.1ag
+ * specification. Continuity Check Messages are broadcast periodically so that
+ * hosts can determine whom they have connectivity to. */
+#define CCM_LEN 74
+#define CCM_MAID_LEN 48
+#define CCM_OPCODE 1 /* CFM message opcode meaning CCM. */
+struct ccm {
+ uint8_t mdlevel_version; /* MD Level and Version */
+ uint8_t opcode;
+ uint8_t flags;
+ uint8_t tlv_offset;
+ ovs_be32 seq;
+ ovs_be16 mpid;
+ uint8_t maid[CCM_MAID_LEN];
+ uint8_t zero[16]; /* Defined by ITU-T Y.1731 should be zero */
+} __attribute__((packed));
+BUILD_ASSERT_DECL(CCM_LEN == sizeof(struct ccm));
struct cfm {
uint16_t mpid;
@@ -249,13 +270,18 @@ cfm_should_send_ccm(struct cfm *cfm)
return timer_expired(&cfm->tx_timer);
}
-/* Composes a CCM message into 'ccm'. Messages generated with this function
+/* 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 ccm *ccm)
+cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
+ uint8_t eth_src[ETH_ADDR_LEN])
{
+ struct ccm *ccm;
+
timer_set_duration(&cfm->tx_timer, cfm->ccm_interval_ms);
+ ccm = eth_compose(packet, eth_addr_ccm, eth_src, ETH_TYPE_CFM,
+ sizeof *ccm);
ccm->mdlevel_version = 0;
ccm->opcode = CCM_OPCODE;
ccm->tlv_offset = 70;