Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 16 | #include "vom/bridge_domain_entry_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 17 | |
| 18 | namespace VOM { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 19 | namespace bridge_domain_entry_cmds { |
| 20 | create_cmd::create_cmd(HW::item<bool>& item, |
| 21 | const mac_address_t& mac, |
| 22 | uint32_t bd, |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 23 | handle_t tx_itf, |
| 24 | bool is_bvi) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 25 | : rpc_cmd(item) |
| 26 | , m_mac(mac) |
| 27 | , m_bd(bd) |
| 28 | , m_tx_itf(tx_itf) |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 29 | , m_is_bvi(is_bvi) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 30 | { |
| 31 | } |
| 32 | |
| 33 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 34 | create_cmd::operator==(const create_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 35 | { |
| 36 | return ((m_mac == other.m_mac) && (m_tx_itf == other.m_tx_itf) && |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 37 | (m_bd == other.m_bd) && (m_is_bvi == other.m_is_bvi)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 41 | create_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 42 | { |
| 43 | msg_t req(con.ctx(), std::ref(*this)); |
| 44 | |
| 45 | auto& payload = req.get_request().get_payload(); |
| 46 | payload.bd_id = m_bd; |
| 47 | payload.is_add = 1; |
Neale Ranns | f29e85f | 2017-11-01 03:29:13 -0700 | [diff] [blame] | 48 | m_mac.to_bytes(payload.mac, 6); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 49 | payload.sw_if_index = m_tx_itf.value(); |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 50 | payload.bvi_mac = m_is_bvi; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 51 | |
| 52 | VAPI_CALL(req.execute()); |
| 53 | |
| 54 | m_hw_item.set(wait()); |
| 55 | |
| 56 | return rc_t::OK; |
| 57 | } |
| 58 | |
| 59 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 60 | create_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 61 | { |
| 62 | std::ostringstream s; |
| 63 | s << "bridge-domain-entry-create: " << m_hw_item.to_string() << " bd:" << m_bd |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 64 | << " mac:" << m_mac.to_string() << " tx:" << m_tx_itf |
| 65 | << " bvi:" << m_is_bvi; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 66 | |
| 67 | return (s.str()); |
| 68 | } |
| 69 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 70 | delete_cmd::delete_cmd(HW::item<bool>& item, |
| 71 | const mac_address_t& mac, |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 72 | uint32_t bd, |
| 73 | bool is_bvi) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 74 | : rpc_cmd(item) |
| 75 | , m_mac(mac) |
| 76 | , m_bd(bd) |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 77 | , m_is_bvi(is_bvi) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 78 | { |
| 79 | } |
| 80 | |
| 81 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 82 | delete_cmd::operator==(const delete_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 83 | { |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 84 | return ((m_mac == other.m_mac) && (m_bd == other.m_bd) && |
| 85 | (m_is_bvi == other.m_is_bvi)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 89 | delete_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 90 | { |
| 91 | msg_t req(con.ctx(), std::ref(*this)); |
| 92 | |
| 93 | auto& payload = req.get_request().get_payload(); |
| 94 | payload.bd_id = m_bd; |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 95 | payload.is_add = 0; |
Neale Ranns | f29e85f | 2017-11-01 03:29:13 -0700 | [diff] [blame] | 96 | m_mac.to_bytes(payload.mac, 6); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 97 | payload.sw_if_index = ~0; |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 98 | payload.bvi_mac = m_is_bvi; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 99 | |
| 100 | VAPI_CALL(req.execute()); |
| 101 | |
| 102 | wait(); |
| 103 | m_hw_item.set(rc_t::NOOP); |
| 104 | |
| 105 | return rc_t::OK; |
| 106 | } |
| 107 | |
| 108 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 109 | delete_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 110 | { |
| 111 | std::ostringstream s; |
| 112 | s << "bridge-domain-entry-delete: " << m_hw_item.to_string() << " bd:" << m_bd |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 113 | << " mac:" << m_mac.to_string() << " bvi:" << m_is_bvi; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 114 | |
| 115 | return (s.str()); |
| 116 | } |
| 117 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 118 | dump_cmd::dump_cmd() |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 119 | { |
| 120 | } |
| 121 | |
| 122 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 123 | dump_cmd::operator==(const dump_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 124 | { |
| 125 | return (true); |
| 126 | } |
| 127 | |
| 128 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 129 | dump_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 130 | { |
| 131 | m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); |
| 132 | |
| 133 | auto& payload = m_dump->get_request().get_payload(); |
| 134 | payload.bd_id = ~0; |
| 135 | |
| 136 | VAPI_CALL(m_dump->execute()); |
| 137 | |
| 138 | wait(); |
| 139 | |
| 140 | return rc_t::OK; |
| 141 | } |
| 142 | |
| 143 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 144 | dump_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 145 | { |
| 146 | return ("bridge-domain-entry-dump"); |
| 147 | } |
| 148 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 149 | } |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 150 | |
| 151 | /* |
| 152 | * fd.io coding-style-patch-verification: ON |
| 153 | * |
| 154 | * Local Variables: |
| 155 | * eval: (c-set-style "mozilla") |
| 156 | * End: |
| 157 | */ |