Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
| 8 | #ifndef NDN_FORWARDING_ENTRY_HPP |
Jeff Thompson | e589c3f | 2013-10-12 17:30:50 -0700 | [diff] [blame] | 9 | #define NDN_FORWARDING_ENTRY_HPP |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 10 | |
| 11 | #include <string> |
| 12 | #include "name.hpp" |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 13 | #include "forwarding-flags.hpp" |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 14 | #include "encoding/block.hpp" |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 15 | |
| 16 | namespace ndn { |
| 17 | |
| 18 | /** |
| 19 | * An ForwardingEntry holds an action and Name prefix and other fields for an forwarding entry. |
| 20 | */ |
| 21 | class ForwardingEntry { |
| 22 | public: |
| 23 | ForwardingEntry |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 24 | (const std::string& action, |
| 25 | const Name& prefix, |
| 26 | int faceId, |
| 27 | const ForwardingFlags& forwardingFlags, |
| 28 | int freshnessPeriod) |
| 29 | : action_(action) |
| 30 | , prefix_(prefix) |
| 31 | , faceId_(faceId) |
| 32 | , forwardingFlags_(forwardingFlags) |
| 33 | , freshnessPeriod_(freshnessPeriod) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 34 | { |
| 35 | } |
| 36 | |
| 37 | ForwardingEntry() |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 38 | : faceId_(-1), freshnessPeriod_(-1) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 39 | { |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 40 | forwardingFlags_.setActive(true); |
| 41 | forwardingFlags_.setChildInherit(true); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 44 | Block |
| 45 | wireEncode() const |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 46 | { |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 47 | return wire_; |
| 48 | // return wireFormat.encodeForwardingEntry(*this); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 49 | } |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 50 | |
| 51 | void |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 52 | wireDecode(const Block &wire) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 53 | { |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 54 | // wireFormat.decodeForwardingEntry(*this, input, inputLength); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 55 | } |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 56 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 57 | const std::string& |
| 58 | getAction() const { return action_; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 59 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 60 | Name& |
| 61 | getPrefix() { return prefix_; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 62 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 63 | const Name& |
| 64 | getPrefix() const { return prefix_; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 65 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 66 | int |
| 67 | getFaceId() const { return faceId_; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 68 | |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 69 | const ForwardingFlags& |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 70 | getForwardingFlags() const { return forwardingFlags_; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 71 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 72 | int |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 73 | getFreshnessPeriod() const { return freshnessPeriod_; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 74 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 75 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 76 | setAction(const std::string& action) { action_ = action; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 77 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 78 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 79 | setFaceId(int faceId) { faceId_ = faceId; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 80 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 81 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 82 | setForwardingFlags(const ForwardingFlags& forwardingFlags) { forwardingFlags_ = forwardingFlags; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 83 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 84 | void |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 85 | setFreshnessPeriod(int freshnessPeriod) { freshnessPeriod_ = freshnessPeriod; } |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 86 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 87 | private: |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 88 | std::string action_; /**< empty for none. */ |
| 89 | Name prefix_; |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 90 | int faceId_; /**< -1 for none. */ |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 91 | ForwardingFlags forwardingFlags_; |
Alexander Afanasyev | 895b2f3 | 2014-01-03 13:24:52 -0800 | [diff] [blame] | 92 | int freshnessPeriod_; /**< -1 for none. */ |
| 93 | |
| 94 | Block wire_; |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | } |
| 98 | |
| 99 | #endif |