Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 1 | /** |
| 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 Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 8 | |
| 9 | void 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 | |
| 21 | int ndn_ForwardingFlags_getForwardingEntryFlags(struct ndn_ForwardingFlags *self) |
| 22 | { |
| 23 | int result = 0; |
| 24 | |
| 25 | if (self->active) |
| 26 | result |= ndn_ForwardingEntryFlags_ACTIVE; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 27 | if (self->childInherit) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 28 | result |= ndn_ForwardingEntryFlags_CHILD_INHERIT; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 29 | if (self->advertise) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 30 | result |= ndn_ForwardingEntryFlags_ADVERTISE; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 31 | if (self->last) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 32 | result |= ndn_ForwardingEntryFlags_LAST; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 33 | if (self->capture) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 34 | result |= ndn_ForwardingEntryFlags_CAPTURE; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 35 | if (self->local) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 36 | result |= ndn_ForwardingEntryFlags_LOCAL; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 37 | if (self->tap) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 38 | result |= ndn_ForwardingEntryFlags_TAP; |
Jeff Thompson | 94bf61c | 2013-11-14 14:01:31 -0800 | [diff] [blame^] | 39 | if (self->captureOk) |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 40 | result |= ndn_ForwardingEntryFlags_CAPTURE_OK; |
| 41 | |
| 42 | return result; |
| 43 | } |
| 44 | |
| 45 | void 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 | } |