Index: src/internet/model/flowi.cc |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/src/internet/model/flowi.cc |
@@ -0,0 +1,182 @@ |
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
+/* |
+ * Copyright (c) 2012 |
+ * |
+ * This program is free software; you can redistribute it and/or modify |
+ * it under the terms of the GNU General Public License version 2 as |
+ * published by the Free Software Foundation; |
+ * |
+ * This program is distributed in the hope that it will be useful, |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ * GNU General Public License for more details. |
+ * |
+ * You should have received a copy of the GNU General Public License |
+ * along with this program; if not, write to the Free Software |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ * |
+ * Authors: Rodrigo Campiolo <campiolo@ime.usp.br> |
+ * Frank Helbert <frank@ime.usp.br> |
+ * Luiz Arthur Feitosa Santos <luizsan@ime.usp.br> |
+ * |
+ */ |
+ |
+ |
+#include "flowi.h" |
+ |
+namespace ns3 { |
+ |
+FlowI::FlowI () |
+ : m_sport (0), |
+ m_dport (0), |
+ m_proto (0), |
+ m_saddr (Address()), |
+ m_daddr (Address()), |
+ m_iif (0), |
+ m_oif (0) |
+{ |
+} |
+ |
+FlowI::~FlowI() |
+{ |
+} |
+ |
+void |
+FlowI::SetSourcePort(uint16_t port) |
+{ |
+ m_sport = port; |
+} |
+ |
+uint16_t |
+FlowI::GetSourcePort (void) const |
+{ |
+ return m_sport; |
+} |
+ |
+void |
+FlowI::SetDestinationPort (uint16_t port) |
+{ |
+ m_dport = port; |
+} |
+ |
+uint16_t |
+FlowI::GetDestinationPort (void) const |
+{ |
+ return m_dport; |
+} |
+ |
+void |
+FlowI::SetProtocol (uint8_t proto) |
+{ |
+ m_proto = proto; |
+} |
+ |
+uint8_t |
+FlowI::GetProtocol (void) const |
+{ |
+ return m_proto; |
+} |
+ |
+void |
+FlowI::SetSourceAddress (Address addr) |
+{ |
+ m_saddr = addr; |
+} |
+ |
+Address |
+FlowI::GetSourceAddress (void) const |
+{ |
+ return m_saddr; |
+} |
+ |
+void |
+FlowI::SetDestinationAddress (Address addr) |
+{ |
+ m_daddr = addr; |
+} |
+ |
+Address |
+FlowI::GetDestinationAddress (void) const |
+{ |
+ return m_daddr; |
+} |
+ |
+void |
+FlowI::SetInputIf (Ptr<NetDevice> iif) |
+{ |
+ m_iif = iif; |
+} |
+ |
+Ptr<NetDevice> |
+FlowI::GetInputIf (void) const |
+{ |
+ return m_iif; |
+} |
+ |
+void |
+FlowI::SetOutputIf (Ptr<NetDevice> oif) |
+{ |
+ m_oif = oif; |
+} |
+ |
+Ptr<NetDevice> |
+FlowI::GetOutputIf (void) const |
+{ |
+ return m_oif; |
+} |
+ |
+// Class Ipv4FlowI |
+ |
+Ipv4Address |
+Ipv4FlowI::GetSourceAddress (void) const |
+{ |
+ return Ipv4Address::ConvertFrom(m_saddr); |
+} |
+ |
+Ipv4Address |
+Ipv4FlowI::GetDestinationAddress (void) const |
+{ |
+ return Ipv4Address::ConvertFrom(m_daddr); |
+} |
+ |
+void |
+Ipv4FlowI::Print (std::ostream &os) const |
+{ |
+ os << "Ipv4FlowI [Source Port: " << m_sport; |
+ os << ", Destination Port: " << m_dport; |
+ os << ", Protocol: " << (uint16_t)m_proto; |
+ os << ", Source Address: " << Ipv4Address::ConvertFrom(m_saddr); |
+ os << ", Destination Address: " << Ipv4Address::ConvertFrom(m_daddr); |
+ os << ", Input Interface: " << m_iif; |
+ os << ", Output Interface: " << m_oif; |
+ os << "] "; |
+} |
+ |
+// Class Ipv6FlowI |
+ |
+Ipv6Address |
+Ipv6FlowI::GetSourceAddress (void) const |
+{ |
+ return Ipv6Address::ConvertFrom(m_saddr); |
+} |
+ |
+Ipv6Address |
+Ipv6FlowI::GetDestinationAddress (void) const |
+{ |
+ return Ipv6Address::ConvertFrom(m_daddr); |
+} |
+ |
+void |
+Ipv6FlowI::Print (std::ostream &os) const |
+{ |
+ os << "Ipv6FlowI [Source Port: " << m_sport; |
+ os << ", Destination Port: " << m_dport; |
+ os << ", Protocol: " << (uint16_t)m_proto; |
+ os << ", Source Address: " << Ipv6Address::ConvertFrom(m_saddr); |
+ os << ", Destination Address: " << Ipv6Address::ConvertFrom(m_daddr); |
+ os << ", Input Interface: " << m_iif; |
+ os << ", Output Interface: " << m_oif; |
+ os << "] "; |
+} |
+ |
+} // namespace ns3 |