Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef NDN_UDP_FACE_H |
| 22 | #define NDN_UDP_FACE_H |
| 23 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 24 | #include "ns3/ndn-face.hpp" |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 25 | #include "ns3/socket.h" |
| 26 | #include "ns3/ptr.h" |
| 27 | |
| 28 | #include <map> |
| 29 | |
| 30 | namespace ns3 { |
| 31 | namespace ndn { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 32 | |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 33 | /** |
| 34 | * \ingroup ndn-face |
| 35 | * \brief Implementation of UDP/IP NDN face |
| 36 | * |
| 37 | * \see ndn::AppFace, ndn::NetDeviceFace, ndn::Ipv4Face, ndn::TcpFace |
| 38 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 39 | class UdpFace : public Face { |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 40 | public: |
| 41 | static TypeId |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 42 | GetTypeId(); |
| 43 | |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 44 | /** |
| 45 | * \brief Constructor |
| 46 | * |
| 47 | * @param node Node associated with the face |
| 48 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 49 | UdpFace(Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address); |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 50 | virtual ~UdpFace(); |
| 51 | |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 52 | Ipv4Address |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 53 | GetAddress() const; |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 54 | |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 55 | virtual bool |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 56 | ReceiveFromUdp(Ptr<const Packet> p); |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 57 | |
Alexander Afanasyev | d573af2 | 2013-07-27 12:57:08 -0700 | [diff] [blame] | 58 | //////////////////////////////////////////////////////////////////// |
| 59 | // methods overloaded from ndn::Face |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 60 | virtual std::ostream& |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 61 | Print(std::ostream& os) const; |
Alexander Afanasyev | d573af2 | 2013-07-27 12:57:08 -0700 | [diff] [blame] | 62 | |
| 63 | protected: |
| 64 | // also from ndn::Face |
| 65 | virtual bool |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | Send(Ptr<Packet> p); |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 67 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 68 | private: |
| 69 | UdpFace(const UdpFace&); ///< \brief Disabled copy constructor |
| 70 | UdpFace& |
| 71 | operator=(const UdpFace&); ///< \brief Disabled copy operator |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 72 | |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 73 | private: |
| 74 | Ptr<Socket> m_socket; |
| 75 | Ipv4Address m_address; |
Alexander Afanasyev | 016a5d8 | 2013-07-15 10:41:29 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace ndn |
| 79 | } // namespace ns3 |
| 80 | |
| 81 | #endif // NDN_UDP_FACE_H |