blob: 001fabcef68e31aae9df83119a4fe3511230dde8 [file] [log] [blame]
Jeff Thompson990599b2013-08-27 15:14:25 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson990599b2013-08-27 15:14:25 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_FORWARDING_ENTRY_H
8#define NDN_FORWARDING_ENTRY_H
9
Jeff Thompson10ad12a2013-09-24 16:19:11 -070010#include "common.h"
Jeff Thompson990599b2013-08-27 15:14:25 -070011#include "name.h"
12#include "publisher-public-key-digest.h"
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070013#include "forwarding-flags.h"
Jeff Thompson990599b2013-08-27 15:14:25 -070014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070019typedef 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 Thompson990599b2013-08-27 15:14:25 -070030/**
31 * An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a hub.
32 */
33struct ndn_ForwardingEntry {
Jeff Thompson93034532013-10-08 11:52:43 -070034 struct ndn_Blob action; /**< A Blob whose value is a pointer to a pre-allocated buffer. 0 for none. */
Jeff Thompson990599b2013-08-27 15:14:25 -070035 struct ndn_Name prefix;
36 struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
37 int faceId; /**< -1 for none. */
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070038 struct ndn_ForwardingFlags forwardingFlags;
Jeff Thompson990599b2013-08-27 15:14:25 -070039 int freshnessSeconds; /**< -1 for none. */
40};
41
42/**
43 * Initialize an ndn_ForwardingEntry struct with the pre-allocated prefixNameComponents,
44 * and defaults for all the values.
45 * @param self pointer to the ndn_Interest struct
46 * @param prefixNameComponents the pre-allocated array of ndn_NameComponent
47 * @param maxPrefixNameComponents the number of elements in the allocated prefixNameComponents array
48 */
Jeff Thompsond1427fb2013-08-29 17:20:32 -070049static inline void ndn_ForwardingEntry_initialize
Jeff Thompson97223af2013-09-24 17:01:27 -070050 (struct ndn_ForwardingEntry *self, struct ndn_NameComponent *prefixNameComponents, size_t maxPrefixNameComponents)
Jeff Thompson990599b2013-08-27 15:14:25 -070051{
Jeff Thompson93034532013-10-08 11:52:43 -070052 ndn_Blob_initialize(&self->action, 0, 0);
Jeff Thompsond1427fb2013-08-29 17:20:32 -070053 ndn_Name_initialize(&self->prefix, prefixNameComponents, maxPrefixNameComponents);
54 ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest);
Jeff Thompson990599b2013-08-27 15:14:25 -070055 self->faceId = -1;
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070056 ndn_ForwardingFlags_initialize(&self->forwardingFlags);
Jeff Thompson990599b2013-08-27 15:14:25 -070057 self->freshnessSeconds = -1;
58}
59
60#ifdef __cplusplus
61}
62#endif
63
64#endif