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, |
| 23 | handle_t tx_itf) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 24 | : rpc_cmd(item) |
| 25 | , m_mac(mac) |
| 26 | , m_bd(bd) |
| 27 | , m_tx_itf(tx_itf) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 32 | create_cmd::operator==(const create_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 33 | { |
| 34 | return ((m_mac == other.m_mac) && (m_tx_itf == other.m_tx_itf) && |
| 35 | (m_bd == other.m_bd)); |
| 36 | } |
| 37 | |
| 38 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 39 | create_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 40 | { |
| 41 | msg_t req(con.ctx(), std::ref(*this)); |
| 42 | |
| 43 | auto& payload = req.get_request().get_payload(); |
| 44 | payload.bd_id = m_bd; |
| 45 | payload.is_add = 1; |
Neale Ranns | f29e85f | 2017-11-01 03:29:13 -0700 | [diff] [blame] | 46 | m_mac.to_bytes(payload.mac, 6); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 47 | payload.sw_if_index = m_tx_itf.value(); |
| 48 | |
| 49 | VAPI_CALL(req.execute()); |
| 50 | |
| 51 | m_hw_item.set(wait()); |
| 52 | |
| 53 | return rc_t::OK; |
| 54 | } |
| 55 | |
| 56 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 57 | create_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 58 | { |
| 59 | std::ostringstream s; |
| 60 | s << "bridge-domain-entry-create: " << m_hw_item.to_string() << " bd:" << m_bd |
| 61 | << " mac:" << m_mac.to_string() << " tx:" << m_tx_itf; |
| 62 | |
| 63 | return (s.str()); |
| 64 | } |
| 65 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 66 | delete_cmd::delete_cmd(HW::item<bool>& item, |
| 67 | const mac_address_t& mac, |
| 68 | uint32_t bd) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 69 | : rpc_cmd(item) |
| 70 | , m_mac(mac) |
| 71 | , m_bd(bd) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 76 | delete_cmd::operator==(const delete_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 77 | { |
| 78 | return ((m_mac == other.m_mac) && (m_bd == other.m_bd)); |
| 79 | } |
| 80 | |
| 81 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 82 | delete_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 83 | { |
| 84 | msg_t req(con.ctx(), std::ref(*this)); |
| 85 | |
| 86 | auto& payload = req.get_request().get_payload(); |
| 87 | payload.bd_id = m_bd; |
| 88 | payload.is_add = 1; |
Neale Ranns | f29e85f | 2017-11-01 03:29:13 -0700 | [diff] [blame] | 89 | m_mac.to_bytes(payload.mac, 6); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 90 | payload.sw_if_index = ~0; |
| 91 | |
| 92 | VAPI_CALL(req.execute()); |
| 93 | |
| 94 | wait(); |
| 95 | m_hw_item.set(rc_t::NOOP); |
| 96 | |
| 97 | return rc_t::OK; |
| 98 | } |
| 99 | |
| 100 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 101 | delete_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 102 | { |
| 103 | std::ostringstream s; |
| 104 | s << "bridge-domain-entry-delete: " << m_hw_item.to_string() << " bd:" << m_bd |
| 105 | << " mac:" << m_mac.to_string(); |
| 106 | |
| 107 | return (s.str()); |
| 108 | } |
| 109 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 110 | dump_cmd::dump_cmd() |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 111 | { |
| 112 | } |
| 113 | |
| 114 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 115 | dump_cmd::operator==(const dump_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 116 | { |
| 117 | return (true); |
| 118 | } |
| 119 | |
| 120 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 121 | dump_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 122 | { |
| 123 | m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); |
| 124 | |
| 125 | auto& payload = m_dump->get_request().get_payload(); |
| 126 | payload.bd_id = ~0; |
| 127 | |
| 128 | VAPI_CALL(m_dump->execute()); |
| 129 | |
| 130 | wait(); |
| 131 | |
| 132 | return rc_t::OK; |
| 133 | } |
| 134 | |
| 135 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 136 | dump_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 137 | { |
| 138 | return ("bridge-domain-entry-dump"); |
| 139 | } |
| 140 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 141 | } |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 142 | |
| 143 | /* |
| 144 | * fd.io coding-style-patch-verification: ON |
| 145 | * |
| 146 | * Local Variables: |
| 147 | * eval: (c-set-style "mozilla") |
| 148 | * End: |
| 149 | */ |