blob: e7477ed37141c5b235be7b5bd70ee3307dd06999 [file] [log] [blame]
Jeff Thompson1f8a31a2013-09-30 16:18:47 -07001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "forwarding-entry.h"
8#include "forwarding-flags.h"
9
10void ndn_ForwardingFlags_initialize(struct ndn_ForwardingFlags *self)
11{
12 self->active = 1;
13 self->childInherit = 1;
14 self->advertise = 0;
15 self->last = 0;
16 self->capture = 0;
17 self->local = 0;
18 self->tap = 0;
19 self->captureOk = 0;
20}
21
22int ndn_ForwardingFlags_getForwardingEntryFlags(struct ndn_ForwardingFlags *self)
23{
24 int result = 0;
25
26 if (self->active)
27 result |= ndn_ForwardingEntryFlags_ACTIVE;
28 else if (self->childInherit)
29 result |= ndn_ForwardingEntryFlags_CHILD_INHERIT;
30 else if (self->advertise)
31 result |= ndn_ForwardingEntryFlags_ADVERTISE;
32 else if (self->last)
33 result |= ndn_ForwardingEntryFlags_LAST;
34 else if (self->capture)
35 result |= ndn_ForwardingEntryFlags_CAPTURE;
36 else if (self->local)
37 result |= ndn_ForwardingEntryFlags_LOCAL;
38 else if (self->tap)
39 result |= ndn_ForwardingEntryFlags_TAP;
40 else if (self->captureOk)
41 result |= ndn_ForwardingEntryFlags_CAPTURE_OK;
42
43 return result;
44}
45
46void ndn_ForwardingFlags_setForwardingEntryFlags(struct ndn_ForwardingFlags *self, int forwardingEntryFlags)
47{
48 self->active = (forwardingEntryFlags & ndn_ForwardingEntryFlags_ACTIVE) ? 1 : 0;
49 self->childInherit = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CHILD_INHERIT) ? 1 : 0;
50 self->advertise = (forwardingEntryFlags & ndn_ForwardingEntryFlags_ADVERTISE) ? 1 : 0;
51 self->last = (forwardingEntryFlags & ndn_ForwardingEntryFlags_LAST) ? 1 : 0;
52 self->capture = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CAPTURE) ? 1 : 0;
53 self->local = (forwardingEntryFlags & ndn_ForwardingEntryFlags_LOCAL) ? 1 : 0;
54 self->tap = (forwardingEntryFlags & ndn_ForwardingEntryFlags_TAP) ? 1 : 0;
55 self->captureOk = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CAPTURE_OK) ? 1 : 0;
56}