fw: integrate forwarder, strategy, tables
refs #1131, #1136
Change-Id: Ica58341cdc1ea1dc421693a87f35fc50177a707d
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index 6518117..9c8613b 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -8,8 +8,8 @@
namespace nfd {
-Face::Face(FaceId id)
- : m_id(id)
+Face::Face()
+ : m_id(INVALID_FACEID)
{
}
@@ -17,6 +17,18 @@
{
}
+FaceId
+Face::getId() const
+{
+ return m_id;
+}
+
+FaceId
+Face::setId(FaceId faceId)
+{
+ m_id = faceId;
+}
+
bool
Face::isUp() const
{
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index 9ff2d20..994bc78 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.hpp
@@ -17,6 +17,8 @@
*/
typedef int FaceId;
+const FaceId INVALID_FACEID = -1;
+
const std::size_t MAX_NDN_PACKET_SIZE = 8800;
/** \class Face
@@ -25,10 +27,13 @@
class Face : noncopyable, public enable_shared_from_this<Face>
{
public:
- Face(FaceId id);
+ Face();
virtual
~Face();
+
+ FaceId
+ getId() const;
/// fires when an Interest is received
EventEmitter<const Interest&> onReceiveInterest;
@@ -81,8 +86,15 @@
// receiveData();
private:
+ FaceId
+ setId(FaceId faceId);
+
+private:
FaceId m_id;
std::string m_description;
+
+ // allow setting FaceId
+ friend class Forwarder;
};
} // namespace nfd
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index e0ea05b..a764a07 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -17,8 +17,7 @@
public:
typedef T protocol;
- StreamFace(FaceId id,
- const shared_ptr<typename protocol::socket>& socket);
+ StreamFace(const shared_ptr<typename protocol::socket>& socket);
protected:
void
@@ -39,10 +38,8 @@
template <class T>
inline
-StreamFace<T>::StreamFace(FaceId id,
- const shared_ptr<typename StreamFace::protocol::socket>& socket)
- : Face(id)
- , m_socket(socket)
+StreamFace<T>::StreamFace(const shared_ptr<typename StreamFace::protocol::socket>& socket)
+ : m_socket(socket)
{
m_socket->async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0,
bind(&StreamFace<T>::handleReceive, this, _1, _2));
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 25244f8..f67e9b2 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -117,10 +117,7 @@
return;
}
- /**
- * \todo Remove FaceId from here
- */
- shared_ptr<TcpFace> face = make_shared<TcpFace>(1, boost::cref(socket));
+ shared_ptr<TcpFace> face = make_shared<TcpFace>(boost::cref(socket));
onFaceCreated(face);
tcp::Endpoint remoteEndpoint = socket->remote_endpoint();
diff --git a/daemon/face/tcp-face.cpp b/daemon/face/tcp-face.cpp
index 79f9b8c..4a295ff 100644
--- a/daemon/face/tcp-face.cpp
+++ b/daemon/face/tcp-face.cpp
@@ -8,9 +8,8 @@
namespace nfd {
-TcpFace::TcpFace(FaceId id,
- const shared_ptr<TcpFace::protocol::socket>& socket)
- : StreamFace<protocol>(id, socket)
+TcpFace::TcpFace(const shared_ptr<TcpFace::protocol::socket>& socket)
+ : StreamFace<protocol>(socket)
{
}
diff --git a/daemon/face/tcp-face.hpp b/daemon/face/tcp-face.hpp
index c76cbc8..cf3188c 100644
--- a/daemon/face/tcp-face.hpp
+++ b/daemon/face/tcp-face.hpp
@@ -21,8 +21,7 @@
public:
typedef boost::asio::ip::tcp protocol;
- TcpFace(FaceId id,
- const shared_ptr<protocol::socket>& socket);
+ TcpFace(const shared_ptr<protocol::socket>& socket);
// from Face
virtual void