NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
notification-stream.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_CORE_NOTIFICATION_STREAM_HPP
27 #define NFD_CORE_NOTIFICATION_STREAM_HPP
28 
29 #include "common.hpp"
30 
31 #include <ndn-cxx/encoding/encoding-buffer.hpp>
32 #include <ndn-cxx/security/key-chain.hpp>
33 
34 namespace nfd {
35 
39 template <class FaceBase>
40 class NotificationStream : noncopyable
41 {
42 public:
43  NotificationStream(FaceBase& face, const Name& prefix, ndn::KeyChain& keyChain)
44  : m_face(face)
45  , m_prefix(prefix)
46  , m_keyChain(keyChain)
47  , m_sequenceNo(0)
48  {
49  }
50 
51  virtual
53  {
54  }
55 
56  template<typename T> void
57  postNotification(const T& notification)
58  {
59  Name dataName = m_prefix;
60  dataName.appendSequenceNumber(m_sequenceNo);
61 
62  shared_ptr<Data> data = make_shared<Data>(dataName);
63  data->setContent(notification.wireEncode());
64  data->setFreshnessPeriod(time::seconds(1));
65 
66  m_keyChain.sign(*data);
67  m_face.put(*data);
68 
69  ++m_sequenceNo;
70  }
71 
72 private:
73  FaceBase& m_face;
74  const Name m_prefix;
75  ndn::KeyChain& m_keyChain;
76  uint64_t m_sequenceNo;
77 };
78 
79 } // namespace nfd
80 
81 #endif // NFD_CORE_NOTIFICATION_STREAM_HPP
The packet signing interface.
Definition: key-chain.hpp:48
provides a publisher of Notification Stream
void sign(Data &data, const SigningInfo &params=DEFAULT_SIGNING_INFO)
Sign data according to the supplied signing information.
Definition: key-chain.cpp:517
Name & appendSequenceNumber(uint64_t seqNo)
Append sequence number using NDN naming conventions.
Definition: name.cpp:253
NotificationStream(FaceBase &face, const Name &prefix, ndn::KeyChain &keyChain)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
void postNotification(const T &notification)
Name abstraction to represent an absolute name.
Definition: name.hpp:46