blob: 90a0460987e101c31b3f02ae66f24021750d4bce [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoque53353462014-04-22 08:43:45 -050023#include <string>
akmhoquefdbddb12014-05-02 18:35:19 -050024#include <boost/cstdint.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -050025#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050026
akmhoquefdbddb12014-05-02 18:35:19 -050027#ifndef NLSR_ADJACENT_HPP
28#define NLSR_ADJACENT_HPP
akmhoque53353462014-04-22 08:43:45 -050029
30namespace nlsr {
akmhoque157b0a42014-05-13 00:26:37 -050031
32enum {
33 ADJACENT_STATUS_INACTIVE = 0,
34 ADJACENT_STATUS_ACTIVE = 1
35};
36
akmhoque53353462014-04-22 08:43:45 -050037class Adjacent
38{
39
40public:
akmhoque157b0a42014-05-13 00:26:37 -050041 Adjacent();
akmhoque53353462014-04-22 08:43:45 -050042
akmhoque157b0a42014-05-13 00:26:37 -050043 Adjacent(const ndn::Name& an);
akmhoque53353462014-04-22 08:43:45 -050044
akmhoque157b0a42014-05-13 00:26:37 -050045 Adjacent(const ndn::Name& an, const std::string& cfu, double lc,
46 uint32_t s, uint32_t iton);
akmhoque53353462014-04-22 08:43:45 -050047
akmhoque31d1d4b2014-05-05 22:08:14 -050048 const ndn::Name&
akmhoquefdbddb12014-05-02 18:35:19 -050049 getName() const
akmhoque53353462014-04-22 08:43:45 -050050 {
51 return m_name;
52 }
53
54 void
akmhoque31d1d4b2014-05-05 22:08:14 -050055 setName(const ndn::Name& an)
akmhoque53353462014-04-22 08:43:45 -050056 {
57 m_name = an;
58 }
59
akmhoque157b0a42014-05-13 00:26:37 -050060 const std::string&
61 getConnectingFaceUri() const
akmhoque53353462014-04-22 08:43:45 -050062 {
akmhoque157b0a42014-05-13 00:26:37 -050063 return m_connectingFaceUri;
akmhoque53353462014-04-22 08:43:45 -050064 }
65
66 void
akmhoque157b0a42014-05-13 00:26:37 -050067 setConnectingFaceUri(const std::string& cfu)
akmhoque53353462014-04-22 08:43:45 -050068 {
akmhoque157b0a42014-05-13 00:26:37 -050069 m_connectingFaceUri = cfu;
akmhoque53353462014-04-22 08:43:45 -050070 }
71
72 double
akmhoquefdbddb12014-05-02 18:35:19 -050073 getLinkCost() const
akmhoque53353462014-04-22 08:43:45 -050074 {
75 return m_linkCost;
76 }
77
78 void
79 setLinkCost(double lc)
80 {
81 m_linkCost = lc;
82 }
83
akmhoquefdbddb12014-05-02 18:35:19 -050084 uint32_t
85 getStatus() const
akmhoque53353462014-04-22 08:43:45 -050086 {
87 return m_status;
88 }
89
90 void
akmhoquefdbddb12014-05-02 18:35:19 -050091 setStatus(uint32_t s)
akmhoque53353462014-04-22 08:43:45 -050092 {
93 m_status = s;
94 }
95
akmhoquefdbddb12014-05-02 18:35:19 -050096 uint32_t
97 getInterestTimedOutNo() const
akmhoque53353462014-04-22 08:43:45 -050098 {
99 return m_interestTimedOutNo;
100 }
101
102 void
akmhoquefdbddb12014-05-02 18:35:19 -0500103 setInterestTimedOutNo(uint32_t iton)
akmhoque53353462014-04-22 08:43:45 -0500104 {
105 m_interestTimedOutNo = iton;
106 }
107
108 bool
akmhoquefdbddb12014-05-02 18:35:19 -0500109 operator==(const Adjacent& adjacent) const;
akmhoque53353462014-04-22 08:43:45 -0500110
akmhoquefdbddb12014-05-02 18:35:19 -0500111 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500112 compare(const ndn::Name& adjacencyName);
113
akmhoque674b0b12014-05-20 14:33:28 -0500114 void
115 writeLog();
116
akmhoque157b0a42014-05-13 00:26:37 -0500117public:
118 static const float DEFAULT_LINK_COST;
119
akmhoque53353462014-04-22 08:43:45 -0500120private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500121 ndn::Name m_name;
akmhoque157b0a42014-05-13 00:26:37 -0500122 std::string m_connectingFaceUri;
akmhoque53353462014-04-22 08:43:45 -0500123 double m_linkCost;
akmhoquefdbddb12014-05-02 18:35:19 -0500124 uint32_t m_status;
125 uint32_t m_interestTimedOutNo;
akmhoque53353462014-04-22 08:43:45 -0500126};
127
akmhoque53353462014-04-22 08:43:45 -0500128} // namespace nlsr
129
akmhoquefdbddb12014-05-02 18:35:19 -0500130#endif //NLSR_ADJACENT_HPP