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