forwarding-entry.h
1 
21 #ifndef NDN_FORWARDING_ENTRY_H
22 #define NDN_FORWARDING_ENTRY_H
23 
24 #include <math.h>
25 #include <ndn-cpp/c/common.h>
26 #include "forwarding-flags-impl.h"
27 #include "name.h"
28 #include "publisher-public-key-digest.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 typedef enum {
35  ndn_ForwardingEntryFlags_ACTIVE = 1,
36  ndn_ForwardingEntryFlags_CHILD_INHERIT = 2,
37  ndn_ForwardingEntryFlags_ADVERTISE = 4,
38  ndn_ForwardingEntryFlags_LAST = 8,
39  ndn_ForwardingEntryFlags_CAPTURE = 16,
40  ndn_ForwardingEntryFlags_LOCAL = 32,
41  ndn_ForwardingEntryFlags_TAP = 64,
42  ndn_ForwardingEntryFlags_CAPTURE_OK = 128
43 } ndn_ForwardingEntryFlags;
44 
49  struct ndn_Blob action;
50  struct ndn_Name prefix;
52  int faceId;
53  struct ndn_ForwardingFlags forwardingFlags;
54  ndn_Milliseconds freshnessPeriod;
55 };
56 
64 static __inline void ndn_ForwardingEntry_initialize
65  (struct ndn_ForwardingEntry *self, struct ndn_NameComponent *prefixNameComponents, size_t maxPrefixNameComponents)
66 {
67  ndn_Blob_initialize(&self->action, 0, 0);
68  ndn_Name_initialize(&self->prefix, prefixNameComponents, maxPrefixNameComponents);
69  ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest);
70  self->faceId = -1;
71  ndn_ForwardingFlags_initialize(&self->forwardingFlags);
72  self->freshnessPeriod = -1.0;
73 }
74 
78 static __inline int ndn_ForwardingEntry_getFreshnessSeconds
79  (const struct ndn_ForwardingEntry *self)
80 {
81  return self->freshnessPeriod < 0 ? -1 : (int)round(self->freshnessPeriod / 1000.0);
82 }
83 
87 static __inline void ndn_ForwardingEntry_setFreshnessSeconds
88  (struct ndn_ForwardingEntry *self, int freshnessSeconds)
89 {
90  self->freshnessPeriod = freshnessSeconds < 0 ? -1.0 : (double)freshnessSeconds * 1000.0;
91 }
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif
struct ndn_Blob publisherPublicKeyDigest
A Blob whose value is a pointer to pre-allocated buffer.
Definition: publisher-public-key-digest-types.h:35
int faceId
-1 for none.
Definition: forwarding-entry.h:52
An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a h...
Definition: forwarding-entry.h:48
ndn_Milliseconds freshnessPeriod
-1 for none.
Definition: forwarding-entry.h:54
Copyright (C) 2013-2015 Regents of the University of California.
Definition: forwarding-flags.h:38
struct ndn_Blob action
A Blob whose value is a pointer to a pre-allocated buffer.
Definition: forwarding-entry.h:49
Copyright (C) 2015 Regents of the University of California.
Definition: publisher-public-key-digest-types.h:34
Copyright (C) 2015 Regents of the University of California.
Definition: name-types.h:33
An ndn_Name holds an array of ndn_NameComponent.
Definition: name-types.h:40
Copyright (C) 2015 Regents of the University of California.
Definition: blob-types.h:33