blob: ae9de5dcecaaa0873692ad762fae1af06fbf294d [file] [log] [blame]
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
Ilya Moiseenko956d0542012-01-02 15:26:40 -08003 * Copyright (c) 2011 University of California, Los Angeles
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -07004 *
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 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 *
20 */
21
Alexander Afanasyev0c395372014-12-20 15:54:02 -080022#include "ndn-net-device-face.hpp"
23#include "ndn-l3-protocol.hpp"
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070024
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070025#include "ns3/net-device.h"
26#include "ns3/log.h"
27#include "ns3/packet.h"
28#include "ns3/node.h"
29#include "ns3/pointer.h"
30
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070031// #include "ns3/address.h"
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -070032#include "ns3/point-to-point-net-device.h"
33#include "ns3/channel.h"
34
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035NS_LOG_COMPONENT_DEFINE("ndn.NetDeviceFace");
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070036
37namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070038namespace ndn {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070039
Alexander Afanasyev565b50c2013-02-01 13:22:56 -080040/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070041 * By default, Ndn face are created in the "down" state. Before
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070042 * becoming useable, the user must invoke SetUp on the face
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070043 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044NetDeviceFace::NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice)
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070045 // : Face(node)
46 : m_netDevice(netDevice)
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070047{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 NS_LOG_FUNCTION(this << netDevice);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070049
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070050 // SetMetric(1); // default metric
Alexander Afanasyeva5abcd92012-04-17 13:34:43 -070051
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080052 NS_ASSERT_MSG(m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070053}
54
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055NetDeviceFace::~NetDeviceFace()
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070056{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 NS_LOG_FUNCTION_NOARGS();
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070058}
59
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070060Ptr<NetDevice>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061NetDeviceFace::GetNetDevice() const
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070062{
63 return m_netDevice;
64}
65
Alexander Afanasyev5bee19e2013-07-10 14:33:57 -070066bool
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067NetDeviceFace::Send(Ptr<Packet> packet)
Alexander Afanasyev5bee19e2013-07-10 14:33:57 -070068{
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070069 return false;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070070}
71
72// callback
73void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074NetDeviceFace::ReceiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
75 const Address& from, const Address& to,
76 NetDevice::PacketType packetType)
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070077{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 NS_LOG_FUNCTION(device << p << protocol << from << to << packetType);
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070079 // Receive(p);
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070080}
81
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070082} // namespace ndnsim
83} // namespace ns3