blob: f0c32930c53cb7f43d3260756fb943ed6f04f747 [file] [log] [blame]
Alexander Afanasyev016a5d82013-07-15 10:41:29 -07001/* -*- 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 Afanasyev0c395372014-12-20 15:54:02 -080024#include "ns3/ndn-face.hpp"
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070025#include "ns3/socket.h"
26#include "ns3/ptr.h"
27
28#include <map>
29
30namespace ns3 {
31namespace ndn {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080032
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070033/**
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 Afanasyevbe55cf62014-12-20 17:51:09 -080039class UdpFace : public Face {
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070040public:
41 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042 GetTypeId();
43
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070044 /**
45 * \brief Constructor
46 *
47 * @param node Node associated with the face
48 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 UdpFace(Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address);
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070050 virtual ~UdpFace();
51
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070052 Ipv4Address
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053 GetAddress() const;
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070054
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070055 virtual bool
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080056 ReceiveFromUdp(Ptr<const Packet> p);
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070057
Alexander Afanasyevd573af22013-07-27 12:57:08 -070058 ////////////////////////////////////////////////////////////////////
59 // methods overloaded from ndn::Face
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070060 virtual std::ostream&
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 Print(std::ostream& os) const;
Alexander Afanasyevd573af22013-07-27 12:57:08 -070062
63protected:
64 // also from ndn::Face
65 virtual bool
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 Send(Ptr<Packet> p);
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070067
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080068private:
69 UdpFace(const UdpFace&); ///< \brief Disabled copy constructor
70 UdpFace&
71 operator=(const UdpFace&); ///< \brief Disabled copy operator
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070072
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070073private:
74 Ptr<Socket> m_socket;
75 Ipv4Address m_address;
Alexander Afanasyev016a5d82013-07-15 10:41:29 -070076};
77
78} // namespace ndn
79} // namespace ns3
80
81#endif // NDN_UDP_FACE_H