blob: 35f7dc1cb454289277128452421d299c8946d309 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07002/*
3 * Copyright (c) 2005,2006,2007 INRIA
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:
19 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070020#ifndef CCNX_FACE_H
21#define CCNX_FACE_H
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070022
23#include <list>
Alexander Afanasyev98256102011-08-14 01:00:02 -070024#include <ostream>
25
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070026#include "ns3/ptr.h"
27#include "ns3/object.h"
28
29namespace ns3 {
30
31class NetDevice;
32class Packet;
33class Node;
34
35/**
Alexander Afanasyev98256102011-08-14 01:00:02 -070036 * \brief The Ccnx representation of a network face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070037 *
38 * This class roughly corresponds to the struct in_device
39 * of Linux; the main purpose is to provide address-family
Alexander Afanasyev98256102011-08-14 01:00:02 -070040 * specific information (addresses) about an face.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070041 *
Alexander Afanasyev98256102011-08-14 01:00:02 -070042 * By default, Ccnx face are created in the "down" state
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070043 * no IP addresses. Before becoming useable, the user must
44 * add an address of some type and invoke Setup on them.
45 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070046class CcnxFace : public Object
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070047{
48public:
49 static TypeId GetTypeId (void);
50
Alexander Afanasyev98256102011-08-14 01:00:02 -070051 CcnxFace ();
52 virtual ~CcnxFace();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070053
Alexander Afanasyev98256102011-08-14 01:00:02 -070054 virtual void SetNode (Ptr<Node> node);
55 virtual void SetDevice (Ptr<NetDevice> device);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070056
57 /**
58 * \returns the underlying NetDevice. This method cannot return zero.
59 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070060 virtual Ptr<NetDevice> GetDevice (void) const;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070061
62 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -070063 * \param metric configured routing metric (cost) of this face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070064 *
65 * Note: This is synonymous to the Metric value that ifconfig prints
66 * out. It is used by ns-3 global routing, but other routing daemons
67 * choose to ignore it.
68 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070069 virtual void SetMetric (uint16_t metric);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070070
71 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -070072 * \returns configured routing metric (cost) of this face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070073 *
74 * Note: This is synonymous to the Metric value that ifconfig prints
75 * out. It is used by ns-3 global routing, but other routing daemons
76 * may choose to ignore it.
77 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070078 virtual uint16_t GetMetric (void) const;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070079
80 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -070081 * These are IP face states and may be distinct from
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070082 * NetDevice states, such as found in real implementations
Alexander Afanasyev98256102011-08-14 01:00:02 -070083 * (where the device may be down but IP face state is still up).
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070084 */
85 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -070086 * \returns true if this face is enabled, false otherwise.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070087 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070088 virtual bool IsUp (void) const;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070089
90 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -070091 * \returns true if this face is disabled, false otherwise.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070092 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070093 virtual bool IsDown (void) const;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070094
95 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -070096 * Enable this face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070097 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070098 virtual void SetUp (void);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070099
100 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700101 * Disable this face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700102 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700103 virtual void SetDown (void);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700104
105 /**
106 * \param p packet to send
107 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700108 virtual void Send (Ptr<Packet> p);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700109
110protected:
111 virtual void DoDispose (void);
112
113private:
114 bool m_ifup;
115 uint16_t m_metric;
116 Ptr<Node> m_node;
117 Ptr<NetDevice> m_device;
118};
119
Alexander Afanasyev98256102011-08-14 01:00:02 -0700120std::ostream& operator<< (std::ostream& os, CcnxFace const& face);
121
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700122} // namespace ns3
123
Alexander Afanasyev98256102011-08-14 01:00:02 -0700124#endif //CCNX_FACE_H