From e039251521aafbee673b0de71e289a95e2cce6cb Mon Sep 17 00:00:00 2001 From: Prakash Bailkeri Date: Thu, 8 Dec 2016 11:10:11 +0530 Subject: [PATCH] Add Mobility info to xmpp enet and inet message To support mobility extended community, add sequence number and sticky bit to xmpp route messages. Xmpp message xml message will carry a tag "mobility" with "seqno" and "sticky" as attribute. Example: Change-Id: Ife4909cff8e2febe349c44b48c5cae7abf0440f9 Related-bug: #1645092 --- src/schema/test/xmpp_unicast_test.cc | 32 ++++++++++++++++++++- src/schema/testdata/bgp_l3vpn_unicast_3.xml | 26 +++++++++++++++++ src/schema/xmpp_enet.xsd | 8 +++++- src/schema/xmpp_unicast.xsd | 8 +++++- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 src/schema/testdata/bgp_l3vpn_unicast_3.xml diff --git a/src/schema/test/xmpp_unicast_test.cc b/src/schema/test/xmpp_unicast_test.cc index 3d71b4cd0ed..8b550b2f8bc 100644 --- a/src/schema/test/xmpp_unicast_test.cc +++ b/src/schema/test/xmpp_unicast_test.cc @@ -55,10 +55,39 @@ TEST_F(QueryTest, Decode) { xdoc_.reset(); } +TEST_F(QueryTest, Decode_1) { + pugi::xml_parse_result result = + xdoc_.load_file("controller/src/schema/testdata/bgp_l3vpn_unicast_3.xml"); + EXPECT_TRUE(result); + + pugi::xml_node node = xdoc_.first_child(); + if (node.type() != pugi::node_null) { + EntryType::XmlParseProperty(node, &xparser_); + + EntryType *entryp_; + entryp_ = (static_cast(xparser_.get())); + + EXPECT_EQ(entryp_->nlri.af, 1); + ASSERT_STREQ(entryp_->nlri.address.c_str(), "10.1.2.1/32"); + + EXPECT_EQ(entryp_->next_hops.next_hop[0].af, 1); + ASSERT_STREQ(entryp_->next_hops.next_hop[0].address.c_str(), + "infrastructure-ip-address"); + EXPECT_EQ(entryp_->next_hops.next_hop[0].label, 10000); + EXPECT_EQ(entryp_->version, 1); + EXPECT_EQ(entryp_->mobility.seqno, 5); + EXPECT_EQ(entryp_->mobility.sticky, false); + } + xdoc_.reset(); +} + + TEST_F(QueryTest, Encode) { EntryType entryp_; entryp_.version = 2; + entryp_.mobility.seqno = 2; + entryp_.mobility.sticky = true; entryp_.nlri.af = 1; entryp_.nlri.address = "10.2.2.2"; @@ -72,7 +101,6 @@ TEST_F(QueryTest, Encode) { pugi::xml_node node = xdoc_.root(); pugi::xml_node node_p = node.append_child("entry"); entryp_.Encode(&node_p); - node = xdoc_.first_child(); if (node.type() != pugi::node_null) { EntryType::XmlParseProperty(node, &xparser_); @@ -86,6 +114,8 @@ TEST_F(QueryTest, Encode) { ASSERT_STREQ(entryp2_->next_hops.next_hop[0].address.c_str(), "20.2.2.2"); EXPECT_EQ(entryp2_->version, 2); + EXPECT_EQ(entryp2_->mobility.seqno, 2); + EXPECT_EQ(entryp2_->mobility.sticky, true); EXPECT_EQ(entryp2_->next_hops.next_hop[0].label, 1000); } xdoc_.reset(); diff --git a/src/schema/testdata/bgp_l3vpn_unicast_3.xml b/src/schema/testdata/bgp_l3vpn_unicast_3.xml new file mode 100644 index 00000000000..8f3af84a7ee --- /dev/null +++ b/src/schema/testdata/bgp_l3vpn_unicast_3.xml @@ -0,0 +1,26 @@ + + + 1 +
10.1.2.1/32
+
+ 1 + + + + 1 +
infrastructure-ip-address
+ +
+
+
+ + + diff --git a/src/schema/xmpp_enet.xsd b/src/schema/xmpp_enet.xsd index 3891f96b904..f830d020981 100644 --- a/src/schema/xmpp_enet.xsd +++ b/src/schema/xmpp_enet.xsd @@ -46,14 +46,20 @@ xsd:targetNamespace="http://www.contrailsystems.com/xmpp-enet-cfg.xsd"> + + + + + + + - diff --git a/src/schema/xmpp_unicast.xsd b/src/schema/xmpp_unicast.xsd index 5d8a1e75b34..a116518ba55 100644 --- a/src/schema/xmpp_unicast.xsd +++ b/src/schema/xmpp_unicast.xsd @@ -71,14 +71,20 @@ xsd:targetNamespace="http://www.contrailsystems.com/bgp-l3vpn-unicast-cfg.xsd"> + + + + + + + -