blob: dd2c2e252533d379120dfb54cf6d0b199b6f92a1 [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,
akmhoquec04e7272014-07-02 11:00:14 -050046 uint32_t s, uint32_t iton, uint64_t faceId);
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
akmhoquec04e7272014-07-02 11:00:14 -0500108 void
109 setFaceId(uint64_t faceId)
110 {
111 m_faceId = faceId;
112 }
113
114 uint64_t
115 getFaceId()
116 {
117 return m_faceId;
118 }
119
akmhoque53353462014-04-22 08:43:45 -0500120 bool
akmhoquefdbddb12014-05-02 18:35:19 -0500121 operator==(const Adjacent& adjacent) const;
akmhoque53353462014-04-22 08:43:45 -0500122
akmhoquec04e7272014-07-02 11:00:14 -0500123 inline bool
124 compare(const ndn::Name& adjacencyName)
125 {
126 return m_name == adjacencyName;
127 }
128
129 inline bool
130 compareFaceId(uint64_t faceId)
131 {
132 return m_faceId == faceId;
133 }
akmhoque31d1d4b2014-05-05 22:08:14 -0500134
akmhoque674b0b12014-05-20 14:33:28 -0500135 void
136 writeLog();
137
akmhoque157b0a42014-05-13 00:26:37 -0500138public:
139 static const float DEFAULT_LINK_COST;
140
akmhoque53353462014-04-22 08:43:45 -0500141private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500142 ndn::Name m_name;
akmhoque157b0a42014-05-13 00:26:37 -0500143 std::string m_connectingFaceUri;
akmhoque53353462014-04-22 08:43:45 -0500144 double m_linkCost;
akmhoquefdbddb12014-05-02 18:35:19 -0500145 uint32_t m_status;
146 uint32_t m_interestTimedOutNo;
akmhoquec04e7272014-07-02 11:00:14 -0500147 uint64_t m_faceId;
akmhoque53353462014-04-22 08:43:45 -0500148};
149
akmhoque53353462014-04-22 08:43:45 -0500150} // namespace nlsr
151
akmhoquefdbddb12014-05-02 18:35:19 -0500152#endif //NLSR_ADJACENT_HPP