summaryrefslogtreecommitdiffstats
path: root/src/plugins/stn.am
AgeCommit message (Expand)AuthorFilesLines
2018-01-17stn: add vat supportFlorin Coras1-5/+14
2017-10-18Plugin for IP-Address to Interface PuntingPierre Pfister1-0/+26
f='#n62'>62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "vom/nat_binding_cmds.hpp"

namespace VOM {
namespace nat_binding_cmds {
bind_44_input_cmd::bind_44_input_cmd(HW::item<bool>& item,
                                     const handle_t& itf,
                                     const nat_binding::zone_t& zone)
  : rpc_cmd(item)
  , m_itf(itf)
  , m_zone(zone)
{
}

bool
bind_44_input_cmd::operator==(const bind_44_input_cmd& other) const
{
  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}

rc_t
bind_44_input_cmd::issue(connection& con)
{
  msg_t req(con.ctx(), std::ref(*this));

  auto& payload = req.get_request().get_payload();
  payload.is_add = 1;
  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
  payload.sw_if_index = m_itf.value();

  VAPI_CALL(req.execute());

  m_hw_item.set(wait());

  return rc_t::OK;
}

std::string
bind_44_input_cmd::to_string() const
{
  std::ostringstream s;
  s << "nat-44-input-binding-create: " << m_hw_item.to_string()
    << " itf:" << m_itf << " " << m_zone.to_string();

  return (s.str());
}

unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
                                         const handle_t& itf,
                                         const nat_binding::zone_t& zone)
  : rpc_cmd(item)
  , m_itf(itf)
  , m_zone(zone)
{
}

bool
unbind_44_input_cmd::operator==(const unbind_44_input_cmd& other) const
{
  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}

rc_t
unbind_44_input_cmd::issue(connection& con)
{
  msg_t req(con.ctx(), std::ref(*this));

  auto& payload = req.get_request().get_payload();
  payload.is_add = 0;
  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
  payload.sw_if_index = m_itf.value();

  VAPI_CALL(req.execute());

  m_hw_item.set(wait());

  return rc_t::OK;
}

std::string
unbind_44_input_cmd::to_string() const
{
  std::ostringstream s;
  s << "nat-44-input-binding-create: " << m_hw_item.to_string()
    << " itf:" << m_itf << " " << m_zone.to_string();

  return (s.str());
}

bind_44_output_cmd::bind_44_output_cmd(HW::item<bool>& item,
                                       const handle_t& itf,
                                       const nat_binding::zone_t& zone)
  : rpc_cmd(item)
  , m_itf(itf)
  , m_zone(zone)
{
}

bool
bind_44_output_cmd::operator==(const bind_44_output_cmd& other) const
{
  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}

rc_t
bind_44_output_cmd::issue(connection& con)
{
  msg_t req(con.ctx(), std::ref(*this));

  auto& payload = req.get_request().get_payload();
  payload.is_add = 1;
  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
  payload.sw_if_index = m_itf.value();

  VAPI_CALL(req.execute());

  m_hw_item.set(wait());

  return rc_t::OK;
}

std::string
bind_44_output_cmd::to_string() const
{
  std::ostringstream s;
  s << "nat-44-output-binding-create: " << m_hw_item.to_string()
    << " itf:" << m_itf << " " << m_zone.to_string();

  return (s.str());
}

unbind_44_output_cmd::unbind_44_output_cmd(HW::item<bool>& item,
                                           const handle_t& itf,
                                           const nat_binding::zone_t& zone)
  : rpc_cmd(item)
  , m_itf(itf)
  , m_zone(zone)
{
}

bool
unbind_44_output_cmd::operator==(const unbind_44_output_cmd& other) const
{
  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}

rc_t
unbind_44_output_cmd::issue(connection& con)
{
  msg_t req(con.ctx(), std::ref(*this));

  auto& payload = req.get_request().get_payload();
  payload.is_add = 0;
  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
  payload.sw_if_index = m_itf.value();

  VAPI_CALL(req.execute());

  m_hw_item.set(wait());

  return rc_t::OK;
}

std::string
unbind_44_output_cmd::to_string() const
{
  std::ostringstream s;
  s << "nat-44-output-binding-create: " << m_hw_item.to_string()
    << " itf:" << m_itf << " " << m_zone.to_string();

  return (s.str());
}

dump_input_44_cmd::dump_input_44_cmd()
{
}

dump_input_44_cmd::dump_input_44_cmd(const dump_input_44_cmd& d)
{
}

bool
dump_input_44_cmd::operator==(const dump_input_44_cmd& other) const
{
  return (true);
}

rc_t
dump_input_44_cmd::issue(connection& con)
{
  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));

  VAPI_CALL(m_dump->execute());

  wait();

  return rc_t::OK;
}

std::string
dump_input_44_cmd::to_string() const
{
  return ("nat-input-binding-dump");
}

dump_output_44_cmd::dump_output_44_cmd()
{
}

dump_output_44_cmd::dump_output_44_cmd(const dump_output_44_cmd& d)
{
}

bool
dump_output_44_cmd::operator==(const dump_output_44_cmd& other) const
{
  return (true);
}

rc_t
dump_output_44_cmd::issue(connection& con)
{
  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));

  VAPI_CALL(m_dump->execute());

  wait();

  return rc_t::OK;
}

std::string
dump_output_44_cmd::to_string() const
{
  return ("nat-output-binding-dump");
}

}; // namespace nat_binding_cmds
}; // namespace VOM

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "mozilla")
 * End:
 */