blob: 4a7510d05432ab5a2f92375f2eb07b9d603b9320 [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"
Jeff Thompson1f8a31a2013-09-30 16:18:47 -07008
9void ndn_ForwardingFlags_initialize(struct ndn_ForwardingFlags *self)
10{
11 self->active = 1;
12 self->childInherit = 1;
13 self->advertise = 0;
14 self->last = 0;
15 self->capture = 0;
16 self->local = 0;
17 self->tap = 0;
18 self->captureOk = 0;
19}
20
21int ndn_ForwardingFlags_getForwardingEntryFlags(struct ndn_ForwardingFlags *self)
22{
23 int result = 0;
24
25 if (self->active)
26 result |= ndn_ForwardingEntryFlags_ACTIVE;
27 else if (self->childInherit)
28 result |= ndn_ForwardingEntryFlags_CHILD_INHERIT;
29 else if (self->advertise)
30 result |= ndn_ForwardingEntryFlags_ADVERTISE;
31 else if (self->last)
32 result |= ndn_ForwardingEntryFlags_LAST;
33 else if (self->capture)
34 result |= ndn_ForwardingEntryFlags_CAPTURE;
35 else if (self->local)
36 result |= ndn_ForwardingEntryFlags_LOCAL;
37 else if (self->tap)
38 result |= ndn_ForwardingEntryFlags_TAP;
39 else if (self->captureOk)
40 result |= ndn_ForwardingEntryFlags_CAPTURE_OK;
41
42 return result;
43}
44
45void ndn_ForwardingFlags_setForwardingEntryFlags(struct ndn_ForwardingFlags *self, int forwardingEntryFlags)
46{
47 self->active = (forwardingEntryFlags & ndn_ForwardingEntryFlags_ACTIVE) ? 1 : 0;
48 self->childInherit = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CHILD_INHERIT) ? 1 : 0;
49 self->advertise = (forwardingEntryFlags & ndn_ForwardingEntryFlags_ADVERTISE) ? 1 : 0;
50 self->last = (forwardingEntryFlags & ndn_ForwardingEntryFlags_LAST) ? 1 : 0;
51 self->capture = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CAPTURE) ? 1 : 0;
52 self->local = (forwardingEntryFlags & ndn_ForwardingEntryFlags_LOCAL) ? 1 : 0;
53 self->tap = (forwardingEntryFlags & ndn_ForwardingEntryFlags_TAP) ? 1 : 0;
54 self->captureOk = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CAPTURE_OK) ? 1 : 0;
55}