blob: f82c3d5a8cd236f1d7bce9ced6c938d551dd8f00 [file] [log] [blame]
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
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 */
20#ifndef CCNX_INTERFACE_H
21#define CCNX_INTERFACE_H
22
23#include <list>
24#include "ns3/ptr.h"
25#include "ns3/object.h"
26
27namespace ns3 {
28
29class NetDevice;
30class Packet;
31class Node;
32
33/**
34 * \brief The Ccnx representation of a network interface
35 *
36 * This class roughly corresponds to the struct in_device
37 * of Linux; the main purpose is to provide address-family
38 * specific information (addresses) about an interface.
39 *
40 * By default, Ccnx interface are created in the "down" state
41 * no IP addresses. Before becoming useable, the user must
42 * add an address of some type and invoke Setup on them.
43 */
44class CcnxInterface : public Object
45{
46public:
47 static TypeId GetTypeId (void);
48
49 CcnxInterface ();
50 virtual ~CcnxInterface();
51
52 void SetNode (Ptr<Node> node);
53 void SetDevice (Ptr<NetDevice> device);
54
55 /**
56 * \returns the underlying NetDevice. This method cannot return zero.
57 */
58 Ptr<NetDevice> GetDevice (void) const;
59
60 /**
61 * \param metric configured routing metric (cost) of this interface
62 *
63 * Note: This is synonymous to the Metric value that ifconfig prints
64 * out. It is used by ns-3 global routing, but other routing daemons
65 * choose to ignore it.
66 */
67 void SetMetric (uint16_t metric);
68
69 /**
70 * \returns configured routing metric (cost) of this interface
71 *
72 * Note: This is synonymous to the Metric value that ifconfig prints
73 * out. It is used by ns-3 global routing, but other routing daemons
74 * may choose to ignore it.
75 */
76 uint16_t GetMetric (void) const;
77
78 /**
79 * These are IP interface states and may be distinct from
80 * NetDevice states, such as found in real implementations
81 * (where the device may be down but IP interface state is still up).
82 */
83 /**
84 * \returns true if this interface is enabled, false otherwise.
85 */
86 bool IsUp (void) const;
87
88 /**
89 * \returns true if this interface is disabled, false otherwise.
90 */
91 bool IsDown (void) const;
92
93 /**
94 * Enable this interface
95 */
96 void SetUp (void);
97
98 /**
99 * Disable this interface
100 */
101 void SetDown (void);
102
103 /**
104 * \param p packet to send
105 */
106 void Send (Ptr<Packet> p);
107
108protected:
109 virtual void DoDispose (void);
110
111private:
112 bool m_ifup;
113 uint16_t m_metric;
114 Ptr<Node> m_node;
115 Ptr<NetDevice> m_device;
116};
117
118} // namespace ns3
119
120#endif