blob: be52a8bd2030a17828805ec967b24853515c5660 [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;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080027 if (self->childInherit)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070028 result |= ndn_ForwardingEntryFlags_CHILD_INHERIT;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080029 if (self->advertise)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070030 result |= ndn_ForwardingEntryFlags_ADVERTISE;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080031 if (self->last)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070032 result |= ndn_ForwardingEntryFlags_LAST;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080033 if (self->capture)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070034 result |= ndn_ForwardingEntryFlags_CAPTURE;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080035 if (self->local)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070036 result |= ndn_ForwardingEntryFlags_LOCAL;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080037 if (self->tap)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070038 result |= ndn_ForwardingEntryFlags_TAP;
Jeff Thompson94bf61c2013-11-14 14:01:31 -080039 if (self->captureOk)
Jeff Thompson1f8a31a2013-09-30 16:18:47 -070040 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}