Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_FORWARDING_ENTRY_H |
| 7 | #define NDN_FORWARDING_ENTRY_H |
| 8 | |
| 9 | #include "name.h" |
| 10 | #include "publisher-public-key-digest.h" |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | /** |
| 17 | * An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a hub. |
| 18 | */ |
| 19 | struct ndn_ForwardingEntry { |
| 20 | unsigned char *action; /**< pointer to pre-allocated buffer. 0 for none. */ |
| 21 | unsigned int actionLength; /**< length of action. 0 for none. */ |
| 22 | struct ndn_Name prefix; |
| 23 | struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest; |
| 24 | int faceId; /**< -1 for none. */ |
| 25 | int forwardingFlags; /**< -1 for none. */ |
| 26 | int freshnessSeconds; /**< -1 for none. */ |
| 27 | }; |
| 28 | |
| 29 | /** |
| 30 | * Initialize an ndn_ForwardingEntry struct with the pre-allocated prefixNameComponents, |
| 31 | * and defaults for all the values. |
| 32 | * @param self pointer to the ndn_Interest struct |
| 33 | * @param prefixNameComponents the pre-allocated array of ndn_NameComponent |
| 34 | * @param maxPrefixNameComponents the number of elements in the allocated prefixNameComponents array |
| 35 | */ |
Jeff Thompson | d1427fb | 2013-08-29 17:20:32 -0700 | [diff] [blame] | 36 | static inline void ndn_ForwardingEntry_initialize |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 37 | (struct ndn_ForwardingEntry *self, struct ndn_NameComponent *prefixNameComponents, unsigned int maxPrefixNameComponents) |
| 38 | { |
| 39 | self->action = 0; |
| 40 | self->actionLength = 0; |
Jeff Thompson | d1427fb | 2013-08-29 17:20:32 -0700 | [diff] [blame] | 41 | ndn_Name_initialize(&self->prefix, prefixNameComponents, maxPrefixNameComponents); |
| 42 | ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 43 | self->faceId = -1; |
| 44 | self->forwardingFlags = -1; |
| 45 | self->freshnessSeconds = -1; |
| 46 | } |
| 47 | |
| 48 | #ifdef __cplusplus |
| 49 | } |
| 50 | #endif |
| 51 | |
| 52 | #endif |