Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_FORWARDING_ENTRY_H |
| 8 | #define NDN_FORWARDING_ENTRY_H |
| 9 | |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 10 | #include "common.h" |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 11 | #include "name.h" |
| 12 | #include "publisher-public-key-digest.h" |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 13 | #include "forwarding-flags.h" |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 19 | typedef enum { |
| 20 | ndn_ForwardingEntryFlags_ACTIVE = 1, |
| 21 | ndn_ForwardingEntryFlags_CHILD_INHERIT = 2, |
| 22 | ndn_ForwardingEntryFlags_ADVERTISE = 4, |
| 23 | ndn_ForwardingEntryFlags_LAST = 8, |
| 24 | ndn_ForwardingEntryFlags_CAPTURE = 16, |
| 25 | ndn_ForwardingEntryFlags_LOCAL = 32, |
| 26 | ndn_ForwardingEntryFlags_TAP = 64, |
| 27 | ndn_ForwardingEntryFlags_CAPTURE_OK = 128 |
| 28 | } ndn_ForwardingEntryFlags; |
| 29 | |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 30 | /** |
| 31 | * An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a hub. |
| 32 | */ |
| 33 | struct ndn_ForwardingEntry { |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 34 | uint8_t *action; /**< pointer to pre-allocated buffer. 0 for none. */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 35 | size_t actionLength; /**< length of action. 0 for none. */ |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 36 | struct ndn_Name prefix; |
| 37 | struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest; |
| 38 | int faceId; /**< -1 for none. */ |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 39 | struct ndn_ForwardingFlags forwardingFlags; |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 40 | int freshnessSeconds; /**< -1 for none. */ |
| 41 | }; |
| 42 | |
| 43 | /** |
| 44 | * Initialize an ndn_ForwardingEntry struct with the pre-allocated prefixNameComponents, |
| 45 | * and defaults for all the values. |
| 46 | * @param self pointer to the ndn_Interest struct |
| 47 | * @param prefixNameComponents the pre-allocated array of ndn_NameComponent |
| 48 | * @param maxPrefixNameComponents the number of elements in the allocated prefixNameComponents array |
| 49 | */ |
Jeff Thompson | d1427fb | 2013-08-29 17:20:32 -0700 | [diff] [blame] | 50 | static inline void ndn_ForwardingEntry_initialize |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 51 | (struct ndn_ForwardingEntry *self, struct ndn_NameComponent *prefixNameComponents, size_t maxPrefixNameComponents) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 52 | { |
| 53 | self->action = 0; |
| 54 | self->actionLength = 0; |
Jeff Thompson | d1427fb | 2013-08-29 17:20:32 -0700 | [diff] [blame] | 55 | ndn_Name_initialize(&self->prefix, prefixNameComponents, maxPrefixNameComponents); |
| 56 | ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 57 | self->faceId = -1; |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 58 | ndn_ForwardingFlags_initialize(&self->forwardingFlags); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 59 | self->freshnessSeconds = -1; |
| 60 | } |
| 61 | |
| 62 | #ifdef __cplusplus |
| 63 | } |
| 64 | #endif |
| 65 | |
| 66 | #endif |