Compare commits

..
1109 Commits
Author SHA1 Message Date
SunnyQjm 9bc57b880b feat: Add qsccp sched 2023-12-03 17:57:24 +08:00
Varun Patil 9b877c3a23 docker: add HOME environment variable and default config
Change-Id: I82b8d46ba74dc648786c23e68a1d1498c893108a
2023-11-18 18:20:28 -08:00
Varun Patil 23135a4cdd Add Dockerfile for nfd-status-http-server
Change-Id: I87349b2cf351c7323d8511677ce7f4a31d944387
2023-11-18 20:21:24 -05:00
Varun PatilandJunxiao Shi 6ba08cd5cb Add initial Dockerfile and CI workflow
Co-authored-by: Junxiao Shi <git@mail1.yoursunny.com>
Change-Id: Ib8341b61edef9be4e4c5f43836ff936c3c063010
2023-11-18 17:18:25 -05:00
Davide Pesavento e277f8b9e8 tools: switch to Face::getIoContext()
Change-Id: I6be4c682d62e1061af45052d2141b9e5b9e897c5
2023-11-11 17:14:02 -05:00
Davide Pesavento 9a63bf22d0 face: add missing includes
Change-Id: I2d855f71310e824205d37d892749c3eab9f5b3c3
2023-11-11 17:12:51 -05:00
Davide Pesavento ef6a528ae0 tests: randomize port used in multicast transport tests
Change-Id: I6030317ad10cf6f3c81f29c2a3898b41a1982c0e
2023-11-03 16:50:10 -04:00
Davide Pesavento 05bd6c2d69 docs: update list of supported platforms
Change-Id: I6aad1f19b593e707e0468e24b160bf3e769376d7
2023-10-31 21:45:25 -04:00
Davide Pesavento a9ec67c52b tests: expand test coverage of EthernetFactory and UdpFactory
Change-Id: I469ac8682502ca7a0e360703b462bfb119eaedf1
2023-10-23 21:00:03 -04:00
Davide Pesavento d7083a507f tests: refactor EthernetFixture
Also, use BOOST_TEST_INFO_SCOPE in a few places.

Change-Id: I113f326207825949ed9d3d22ade0654976d49b76
2023-10-19 17:51:16 -04:00
Davide Pesavento c5a9f81fce face: more robust handling of multicast face creation errors
Refs: #5030, #5297
Change-Id: I3ca985498d9d3756cbff94873063f3734bcea288
2023-10-19 02:12:05 -04:00
Davide Pesavento 0a05f7aea6 build: disable -Wnon-virtual-dtor compiler warning
It's overkill and suffers from annoying false positives that
prevent us from applying the "protected non-virtual destructor"
idiom in several perfectly valid cases. See for instance the
GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102168

The -Wdelete-non-virtual-dtor warning (included in -Wall) is
the preferred alternative and is enough to catch the unsafe
cases without false positives.

Partially reverts 847de408cb

Change-Id: I46ee1f01e7d4e2b125c2c534c6550824ba1de4c0
2023-10-16 20:50:03 -04:00
Davide Pesavento c0df94ed10 face: minor code cleanups
Change-Id: I154d2ad4dfd9e12e1fa9756f74884286b31298e4
2023-10-08 19:26:55 -04:00
awlane 9c36a65b11 face: handle PcapHelper::Error when applying multicast configuration
When the network interface state is changed, NFD reconfigures its
multicast ethernet faces. The code responsible for this is prone to
a TOCTOU race condition, e.g., if an interface is quickly brought up
and then down again. This currently raises an uncaught exception when
we try to set a packet filter for that interface.

Prevent this issue by catching PcapHelper errors in the same manner
as we catch EthernetTransport errors, and skip creating the face.

Refs: #5297
Change-Id: I9f91ac7c42dec06de34128cb34d6de8bb57e8cf5
2023-10-08 16:52:06 -04:00
Davide Pesavento 1e0c88e184 face: use async_wait operation instead of async_read with null_buffers
Change-Id: I2914e7f8fbd1b9a9e1fa8113d53700e7d6184464
2023-10-05 03:52:52 -04:00
Davide Pesavento 9bf64cc60d face: use new-style async_accept API
Change-Id: Id9de72c0922ec9ea13e5b1d9ded27dd7edf67e38
2023-10-05 02:12:02 -04:00
Davide Pesavento d91fe6d921 core+face: avoid deprecated Boost.Asio interfaces
Change-Id: I07ec286531edf63f258babe1561b4da2a88edd10
2023-10-04 21:40:02 -04:00
Davide Pesavento 5d64263dcb daemon: use asio::defer() instead of asio::post() where appropriate
Change-Id: I24d0fab6499d6430dd500ca157daa87f48960d15
2023-10-03 00:36:08 -04:00
Davide Pesavento a9e1ab2664 build: require boost >= 1.71.0
Refs: #5276
Change-Id: Ie428541639dcf1113acfb9e9d0a80f9be87d6cd3
2023-10-02 22:42:02 -04:00
Davide Pesavento 910232fce0 build: use python f-strings
Change-Id: I955739ac40508642509521760c1bc75286c94f30
2023-09-08 14:20:02 -04:00
Davide Pesavento decaf509b4 tools: modernize nfd-status-http-server and improve error handling
Change-Id: I5715c35f79d7dcd8dbefed328ebb625e9150a846
2023-08-30 22:50:03 -04:00
Davide Pesavento 8f0b8b6063 Simplify some code with Boost.Operators
Change-Id: Ic873bcbaf6be00d5c35601cfc8090df534d815ee
2023-08-29 21:04:08 -04:00
Davide Pesavento 11f1fd8340 build: update waf to version 2.0.26
Change-Id: I896871a312983ff36f1784aa53484c5edf95ebda
2023-08-19 01:50:04 -04:00
Davide Pesavento bf2e67fb14 build: enable a few more compiler warnings
Refactor default-compiler-flags.py to reduce duplication

Change-Id: I627b05257c2eec5c3ada9994bcd2b9a9be362157
2023-08-07 17:06:02 -04:00
Davide Pesavento 5b15e2fe97 build: decrease level of debug information produced by default
Refs: #5279
Change-Id: I537ff2a0a2e411279922823ae46cb7fee6586670
2023-08-07 16:35:35 -04:00
Davide Pesavento 95afc6d8a4 fw: increment nOutNacks when sending a Nack from onInterestLoop
Also expand test coverage of all forwarder counters

Change-Id: I6948af05aca1b5589e2f1c8a1f23c002d39d0ec0
2023-08-02 21:20:05 -04:00
Alex LaneandDavide Pesavento 653eb07e29 fw: refactor strategy logging and improve ASF probe logging
Bring strategy logging in line with format from 6bf94c0.
This should also marginally improve performance when log level is raised.

Refs: #5262, #5267
Co-authored-by: Davide Pesavento <davidepesa@gmail.com>
Change-Id: I6493b6476f3d0c6ae5562b66abfa46f6c6f4903d
2023-07-28 14:14:11 -04:00
Alex Lane 6bf94c02f5 fw: add Interest nonce to Forwarder logging where appropriate
Refs: #5262
Change-Id: Id3675fe1adb973d403f1e2ba386e9a4ec686c7b6
2023-06-08 02:42:02 -04:00
Davide Pesavento 191a7a24e6 core+daemon: declare all equality operators as hidden friends
Change-Id: Id832ee1fb16fb6742879c8b87f56002f94745103
2023-05-17 22:50:32 -04:00
Davide Pesavento ae43030f6f Further reduce the use of std::bind()
And also avoid deprecated ndn-cxx type aliases

Change-Id: I87e903b9671a3cf1c1b9ab30d4594d595c3c6da9
2023-05-11 01:50:11 -04:00
Davide Pesavento 63b3ae818f tools: fix compilation with latest ndn-cxx
Change-Id: Ifded624f3256452be98f288f9193dd26e464cd36
2023-03-27 14:05:04 -04:00
Davide Pesavento 4064127b97 mgmt+tools: add missing includes
Change-Id: I53aeaa6b223b616c170697662d02a028cea67400
2023-03-16 13:31:12 -04:00
Davide Pesavento d6ea0b1e0e tests: use std::nullopt
Change-Id: I7efdc8076c1bc4ced11dd3bdab7f199609009545
2023-03-13 22:54:15 -04:00
Davide Pesavento c5e3e7a55d build: drop official support for Ubuntu 18.04 and macOS 10.15
Increase the minimum required version of clang to 7.0 on linux, because
older versions fail to compile libstdc++'s implementation of std::variant

Change-Id: I6320973cbe3ff00faa8a36cd0e7ddf564c20d965
2023-03-07 21:25:27 -05:00
Davide Pesavento bf4c131f82 docs: update several URLs to point to docs.named-data.net
Change-Id: I4bab897f17e2b929675119198c9eab0309b6cc3e
2023-02-23 20:32:01 -05:00
Davide Pesavento 39c67f6291 build: switch source archive to xz compression
And a few minor README improvements

Change-Id: Iae8dc8fb3f5ac53296ffdadc8d2b893d13b8e684
2023-02-15 00:26:26 -05:00
Davide Pesavento 269b702f3d ci: adopt reusable workflows from named-data/actions
Change-Id: Iefd142d82f56a6fb83c5039565b6eba83c6e6445
2023-02-12 16:14:56 -05:00
Davide Pesavento 3bc8e19a89 Prepare release 22.12
Refs: #5250
Change-Id: I6b9a3daab498cbffb78a108207e92bc2596be378
2022-12-31 01:40:11 -05:00
Davide Pesavento 0b0156887b face: put the pcap handle in non-blocking mode
This prevents NFD from getting stuck in pcap_next_ex()
when the network interface goes down

Change-Id: I5760fcc7c950b46aecb7619bd889508ee24133aa
2022-12-12 22:01:28 -05:00
Davide Pesavento 6b78a53cf7 build: update waf to version 2.0.24
Change-Id: I57b597fb5933e46b55979ad6b1a62a7fd40c645d
2022-12-02 18:24:16 -05:00
Ikko Ashimine a68af8129e docs: fix typo in release-notes-22.02.rst
accomodate -> accommodate

Closes: https://github.com/named-data/NFD/pull/11
Change-Id: Ibad215a723cd51881760d2e43c05694a0e8928fe
2022-11-25 22:15:12 -05:00
Davide Pesavento a42efcb408 ci: add Xcode 14.1
Change-Id: I8415fb1375da16813a69fa7a03bf37a7b0efc8b7
2022-11-15 02:43:16 -05:00
Davide Pesavento aa9e3b2148 docs: fix capitalization in doxygen comments
Change-Id: Ibf5ee5119d12d60d382b0acef8dfd08277c18fcb
2022-10-29 21:45:24 -04:00
Davide Pesavento b83d3df256 mgmt: finalize migration to the new signed Interest format
Change-Id: I6d3fe1bd092fa80e185d36746a42c188ab00a60e
2022-10-13 09:45:33 -04:00
Davide Pesavento 6d6f207661 mgmt: rename extractRequester() and support signed Interest v0.3
Change-Id: I6bb6635896fa1b9fa54beb70b902c5a35831dc9c
2022-10-13 08:55:42 -04:00
Davide Pesavento 9bfdaef62d build: link with lld if available
Change-Id: Ie390c511c711508b6bb8c326a9a62fb1eca291c5
2022-10-05 17:38:44 -04:00
Davide Pesavento 20d94f67f8 Use inline on all namespace-scope constants defined in headers
Change-Id: Ic61f8d26f59fdc2895415ca47065c02d6eec28ed
2022-09-26 03:30:53 -04:00
Davide Pesavento 36184f6893 docs: restore exception handling in conf.py
Change-Id: Ie6408385e821e509e964bcea001a39f8cfdc5da0
2022-09-25 03:48:58 -04:00
Davide Pesavento 6cc9541220 docs: simplify conf.py and fix compatibility with upcoming Sphinx 6.0
Change-Id: Iacf4a72d30babc4a7c3fab0fea619a798eff2df1
2022-09-20 19:10:55 -04:00
Davide Pesavento 279af1ceac tests: fix UDP multicast transport tests with IPv6
A valid scope id is always required on the multicast address

Change-Id: Ic676fcde0ee50daf75eb38c137e3cb917f43699f
2022-08-29 20:18:32 -04:00
Teng Liang d94b7b3b24 face: reimplement EndpointId with std::variant
Refs: #5041
Change-Id: Ib8aced49a7aa14b137fb06de4a0ae8b979f07587
2022-08-24 19:38:47 -04:00
Davide Pesavento e541d1b250 build+ci: support macOS on arm64
Refs: #5135
Change-Id: I86f1955366df12cfb8b3e6f9d5e9f202778cc211
2022-08-18 20:50:05 -04:00
Davide Pesavento 4791fcb8ba ci: refresh GitHub Actions matrix
* Add ubuntu-22.04, remove 18.04
 * Add macos-12, remove 10.15

Change-Id: I775ea45661259ba1353e3f6ee0c602abee58acbd
2022-08-14 17:40:05 -04:00
Davide Pesavento 72517b5510 ci: auto-detect the OS instead of relying on NODE_LABELS
And remove WAF_JOBS: waf already defaults to the number of available
CPUs, which is appropriate in most cases, and we can always use the
built-in JOBS variable to override it where necessary.

Change-Id: I555dda0ccc48ee791271dbdaf4225cd1cfec4f3d
2022-08-13 18:50:55 -04:00
Davide Pesavento 20cafa8715 tests: minor code cleanups
Change-Id: I9759ba4b7eb467d4d1df4b379efad91bc4f5cc3a
2022-07-25 01:15:03 -04:00
Davide Pesavento 2150da8ee5 build+docs: support CentOS Stream 9, drop CentOS 8
Refs: #5181
Change-Id: I2d8bc595bad047ceaa78bd3729848491b843e83d
2022-07-08 18:18:51 -04:00
Davide Pesavento 990620ac3b nfdc: merge canonizer.hpp and find-face.hpp into face-helpers.hpp
Change-Id: I19ca5cbce8cab54e61eb7af0a32c33c3aa73faf1
2022-06-13 16:33:25 -04:00
Davide Pesavento a9b09b6994 build: make precompiled headers more useful
This can reduce the compilation time of a release
build (without tests) by more than 40%

Refs: #5212
Change-Id: I977aff0c0c7becbfee8a8b55605b81d0c014829b
2022-06-13 16:30:11 -04:00
Davide Pesavento 9a28c3f752 fw+table: workaround bogus doxygen warnings
Change-Id: I0a093658f4b27620ba9731a0640ca71c3d03360a
2022-06-11 21:52:05 -04:00
Davide Pesavento e422f9e1e9 Refactor and modernize namespace declarations
Move all unit tests to namespace nfd::tests

Delete unused header core/algorithm.hpp

Change-Id: I5591f0c5f3bb5db67f8b45fae95471f8a555ca68
2022-06-11 20:10:26 -04:00
Davide Pesavento a3a7a4e330 Use more C++17 features
Mainly structured bindings, inline variables, and class template
argument deduction, plus many more smaller things.

Change-Id: I810d17e0adb470426e4e30c898e03b3140ad052f
2022-06-04 20:26:02 -04:00
Davide Pesavento b7bfcb904a build: switch to C++17
Change-Id: Ie68020a04b7e20b74778b6d0370544ded55c5e26
2022-05-23 03:42:32 -04:00
Junxiao Shi 4b84a2c9be tests: expect certificate name in KeyLocator
Also, delete unused KeyChainFixture::makeCert function.

refs #5112

Change-Id: I59b1ca81fca0481a37126270c447f639080ec75f
2022-04-28 03:17:05 +00:00
Davide Pesavento 6153eafa62 ci: require gcovr 5.1 for code coverage reports
Stop passing `-j`, it wasn't very useful and it's broken in gcovr 5.1

Change-Id: I17ffb97c2dc9cd8db7c900fbbd4ab5f8f92184dd
2022-04-19 19:45:03 -04:00
Ashlesh Gawande 1ef93d0316 fw: add strategy parameters to configure exponential retx suppression
Supported by ASF, BestRoute, and Multicast strategies

Refs: #4924
Change-Id: I215d9212d90b93fa622cc65278703dc5198d0c9d
2022-04-08 00:27:27 -04:00
Davide Pesavento deb5427bb4 daemon+tests: avoid deprecated ndn-cxx functions
Change-Id: Idfa341629919d63fac140eda0b465f8f8abd38e6
2022-03-11 18:51:05 -05:00
Davide Pesavento 1b22a8c156 tests: drop redundant calls to Interest::setCanBePrefix(false)
Change-Id: I6afd1028ab370633c64a74ab4310396dab3c8a03
2022-03-07 21:23:23 -05:00
Davide Pesavento c52cd5eec1 build: align minimum build dependencies with ndn-cxx
* boost 1.65.1
 * gcc 7.4
 * clang 6.0
 * Xcode 10.0 (11.3 or later recommended)

Change-Id: I5e41f2a70d6c510dcb889a083a51504121b4627d
2022-03-05 20:40:54 -05:00
Alexander Afanasyev 5006c1d6af Prepare release 22.02
Change-Id: Ie0d8db596c11c4f298755aa4b7fde5e616f32ceb
Refs: #5172, #5184
2022-02-17 16:07:18 -05:00
Davide Pesavento a599d2aac9 Convert to span and avoid deprecated ndn-cxx functions
Change-Id: I45c50527fe53498b53a3d951458bdff8e7d7778c
2022-02-16 18:52:43 -05:00
Junxiao Shi b98aa3aca6 face: handle error in TCP socket remote_endpoint
refs #5158

Change-Id: I67fa134cd01a80a4f91122bbdcfc64e089d8145e
2022-01-12 01:14:08 +00:00
Junxiao Shi 727b61087a table+fw: update ForwardingHint format
refs #5187

Change-Id: Ic8e32c83caeb60404f1b035a4f7e9841cc513f0b
2022-01-11 18:40:04 +00:00
Davide Pesavento 80111b72f9 face: adapt to API change in ndn::Transport
Change-Id: Ib424af03b7ec7d7bccce8d9498da6c593e16362f
2022-01-09 16:32:33 -05:00
Davide Pesavento 07da3fec95 build: update waf to version 2.0.23
Change-Id: I33bccd3f9aacdd22b690b6ff08fabd964dc022db
2021-12-29 19:14:42 -05:00
Alexander Afanasyev 5e02c04ca7 docs: Update sample nfd.conf to allow use of v0.3 Signed Interests
Change-Id: I72769d6caf52718b0e9ce4f6d3d8b0a29cf04925
2021-12-22 23:01:07 -05:00
Alexander Afanasyev c414ca5895 tools: Allow batch command processing by nfdc
Change-Id: Ia6f70fed88f2d4c918e2ca2b786222840dbd9076
Refs: #5169
2021-12-21 14:27:26 -05:00
Davide Pesavento f28a061c22 ci: add macOS 11 Big Sur
Remove all traces of Travis CI

Change-Id: Ie9ad527af4921c4f3c56903851200131ed0d5e87
2021-09-29 23:13:32 -04:00
Saurab Dulal af3ff5a8c6 fw: rename n-silent-timeouts to max-timeouts in AsfStrategy
Change-Id: Ie2790a4e1fd545aacf8b297d7ec33b204f2cdbfc
2021-09-19 19:45:25 -04:00
Davide Pesavento 2c61bad944 ci: use gcovr 5.0 to generate code coverage reports
Change-Id: Ib7284d1616f9bce527aa98ccbb32e58d0bfa9dfb
2021-08-30 22:40:35 -04:00
Davide Pesavento 4d030c3896 Add CITATION.cff
Remove duplicate/obsolete files. Use the corresponding
files in https://github.com/named-data/.github instead.

Change-Id: Ife0d7551dd44091a8343ea233072c22a03149a71
2021-08-30 21:48:42 -04:00
Davide Pesavento 13dae355cb ci: restrict token permissions and add badges to README.md
Change-Id: Ia7e254eefb6658aa5110a7fea5a6847cb257a84b
2021-08-13 15:40:54 -04:00
Davide Pesavento 8f0028de4e ci: add GitHub Actions
Change-Id: Idc715edf136550b088f89c19b581f5478b296653
2021-07-30 19:26:03 -04:00
Davide Pesavento 412c982a63 Reduce usage of std::bind()
C++14 lambdas are easier to read, easier to debug,
and can usually be better optimized by the compiler.

Change-Id: I294f275904f91942a8de946fe63e77078a7608a6
2021-07-02 00:21:05 -04:00
Philipp Moll a103334b1c fw: Add default HopLimit to Interest when missing
Refs: #5171
Change-Id: I5973811b5ca7c7cf5ff344872afa51b253b9cae8
2021-06-25 00:24:23 -04:00
Davide Pesavento 0498ce85b0 fw: reorder function params to make the strategy API more uniform
Also add a non-const overload of Face::getCounters to avoid const_cast

Refs: #5173
Change-Id: Iff0bfbdedb90e68a373090cf3f247d9a7501f58d
2021-06-14 14:18:03 -04:00
Davide Pesavento 7647cc7635 table: increase initial and minimum capacity of DeadNonceList
Change-Id: Iaec6299ed985fcf165e23d31a339a6cbf073b55d
2021-06-10 14:30:04 -04:00
Davide Pesavento e08cc4cd7e table: improve logging in DeadNonceList
Refs: #5165
Change-Id: I97f9e28af90d857b33808d385eb077380cafe00a
2021-06-09 03:03:32 -04:00
Varun Patil 67ad70fbd5 table: prevent duplicates in DeadNonceList
refs #5167

Change-Id: Ia7546f75b844cfa1d857a641b015fbc6e9dfaf3d
2021-06-07 16:18:02 -07:00
Davide Pesavento d69070ef50 ci+docs+tools: stop using deprecated ndnsec commands
Change-Id: If77f479b45581a9a70619c329e713524678e35fb
2021-06-04 18:50:52 -04:00
Davide Pesavento d412393379 table: DeadNonceList code cleanup/modernization
Change-Id: I7d2bb8982b60b138c979470406b0a607301f2768
2021-05-28 19:21:03 -04:00
Davide Pesavento 6a699be8cd tests: use InterestSigner instead of deprecated CommandInterestSigner
Change-Id: Iaf98026c9c0a7ee3950d79f4d810e0a7abba43b1
2021-05-17 02:13:37 -04:00
Davide Pesavento a47cca2634 build: make graphviz optional for building documentation
Change-Id: I5434bbef22c840341623bff16f9e8de129249be2
2021-04-16 02:30:11 -04:00
Eric Newberry 7249fb4d52 docs+tests: finalize migration to typed naming conventions
refs #5044

Change-Id: Ia6f52ae0a31db33ca0f9fa6c4553b8fbbc7809bc
2021-04-05 18:16:44 -04:00
Davide Pesavento 86644d36ff mgmt: don't extend the dataset expiration in ForwarderStatusManager
No other managers do this. Moreover, StatusDatasetContext::setExpiry()
has odd semantics and is being removed from ndn-cxx.

Change-Id: I5255aec5c6464e48f4b4765ae2c06f557e094044
2021-04-02 15:20:16 -04:00
Eric Newberry 358414d82f fw: remove reliance upon marker name components
refs #5044

Change-Id: Iea6c98e03dbd3e4463f7bb6fca0be4953a2cdc40
2021-03-25 21:10:38 -07:00
Davide Pesavento 22085365d2 mgmt: fix construction of CertificateRequest in CommandAuthenticatorValidationPolicy
Just pass the KeyLocator name and let CertificateRequest deal
with constructing the Interest and setting CanBePrefix

Refs: #4582
Change-Id: I323d8ac5e16605bb978addc623e525b2536238bf
2021-03-18 22:08:03 -04:00
Saurab Dulal 432be57380 fw: use per-upstream suppression in ASF strategy
Refs: #5140
Change-Id: I49b27ce6b55d01724d0eafa792785d081c6009f7
2021-03-17 16:50:10 -04:00
Davide Pesavento 3db9807200 daemon: mark some classes and methods 'final'
As suggested by gcc's -Wsuggest-final-types and -Wsuggest-final-methods

Change-Id: I1622857ee53581efd0c6ce3fe93199c72202d817
2021-03-15 18:15:01 -04:00
Davide Pesavento 03a75f6c88 tests: add test case for retx suppression in multicast strategy
Refs: #4066
Change-Id: I78953b91b1fc1c6599b83cd1f39c11722261dd98
2021-03-15 18:14:26 -04:00
Davide Pesavento 7922d12449 fw: rename BestRouteStrategy2 class to BestRouteStrategy
Also rename ad-hoc-forwarding.t.cpp to strategy-ad-hoc-face.t.cpp
and broadcast-medium.t.cpp to strategy-broadcast-medium.t.cpp,
for consistency with the other strategy-*.t.cpp test suites.

Change-Id: Ia8f5257260563732d74c7d58e35481b73a231f06
2021-03-09 20:11:24 -05:00
Davide Pesavento 580915891e fw: remove best-route strategy version 1
Change-Id: I7e86d5c19c01db65a84fdc0f289e7534f0774f4e
2021-03-09 11:45:43 -05:00
Davide Pesavento 29abf4cda2 fw: remove ncc strategy
Change-Id: I6de0acf51e965afcbda5cc943cb39daa78cabf2d
2021-03-09 01:43:46 -05:00
Junxiao Shi a6286a9e5a face: allow setting default UDP face MTU in config
refs #5138

Change-Id: Ibb3767b27aec2b046d1f41292f3d61001866f8c0
2021-02-24 12:11:45 -08:00
Alexander Afanasyev 40604e3a1f fw: Dispatch pending interests on new nexhop in multicast strategy
Change-Id: Ifac7b27c9943bd164d0a6579edc68fb959ebe887
Refs: #4931
2021-02-24 11:49:05 -05:00
Alexander Afanasyev 4400e428d4 fw: Remove NACKs from multicast strategy
Change-Id: I49b833ec0ad990dfdf547aef80915e3fc83389ec
Refs: #5146
2021-02-19 18:45:55 -05:00
Davide Pesavento 05590471e0 fw: eliminate Forwarder::dispatchToStrategy()
Change-Id: Ia2e58c66548644fe3395f7e8c65e860554484fc8
2021-02-17 15:53:27 -05:00
Davide Pesavento b21bed88ed fw: fix and simplify enumeration logic in Forwarder::onNewNextHop()
Also remove Strategy::enableNewNextHopTrigger(). Strategies can already
opt-in by overriding afterNewNextHop(), there is no need for a separate
enablement flag.

Refs: #4931
Change-Id: Ifcbdbc7e954bd20d9969fd99882a2a9aebbc8fcc
2021-02-17 15:09:32 -05:00
Davide Pesavento 264af77369 build: prepend "NFD_" to various macro names to avoid conflicts
Change-Id: Icc370968e3d38fef80ece35a2aed56450f54b653
2021-02-10 14:48:07 -05:00
Junxiao Shi 6aecc500e5 doc: accommodate certificate name in KeyLocator in sample nfd.conf
refs #5114

Change-Id: I648318e035fd06722dedc5181e03c108ac275e66
2021-02-07 13:11:56 -07:00
Junxiao Shi 7fb9071230 face: execute pcap_activate as root
refs #4647

Change-Id: Ib88bbebe5d6495e138b65b5b66865a0001aebef9
2021-01-27 10:31:16 -07:00
Davide Pesavento 9ab43e67db ci+docs: CentOS renamed the PowerTools repo to lowercase
Change-Id: I4b78986f3af17d2124824992e31b408ebe8de03a
2020-12-27 20:50:22 -05:00
Davide Pesavento cabd980030 build: upgrade waf to version 2.0.21
Change-Id: I63a240ce9386076dcfae429f954dc0eadb25f6fc
2020-11-20 01:01:43 -05:00
Davide Pesavento 2135375d36 tests: sync common testing infrastructure with ndn-cxx
Change-Id: I6feab5247231abc35b8daa96bca21ad17c9cc4b3
2020-11-20 00:43:44 -05:00
Eric Newberry 3dc9fd0b82 Prepare release 0.7.1
refs #5129

Change-Id: Iba2703bdc5153024dbdfcb7e4c043f52964736f9
2020-10-08 16:41:45 -07:00
Davide Pesavento c0c089314b docs: refresh and improve the "named data" sphinx theme
Change-Id: I196c30f84ce4edd5cd10dfe3cab6ea2dc6947815
2020-10-07 13:19:14 -04:00
Davide Pesavento 9f6a7d97bc docs: fix syntax highlighting of code blocks
And various other cleanups

Change-Id: I240badc5358c09f006c2a22d4706ce373f2dd188
2020-10-07 13:18:44 -04:00
Davide Pesavento 0bba81df36 fw: delete spurious assertion in AccessStrategy
Refs: #5127
Change-Id: Ic6d8b098dc29735f800d4c6b1dc40316d4755172
2020-10-06 13:15:34 -04:00
Eric Newberry 2377ada11a fw: handle dropped packets in strategies
refs #5128

Change-Id: Ic7f7e61b2dde66004d0291bb41e008961fc7b252
2020-10-04 21:06:43 -04:00
Davide Pesavento b7e72c3a0a tests: use NullSignature
Change-Id: Icb8ff95905cfa2ba9d9a493d7a60b30a61a8d671
2020-10-02 20:00:03 -04:00
Ashlesh Gawande c1d4837b6f fw: fix PIT entry rejection in MulticastStrategy on receiving same Interest
refs: #5123

Change-Id: Ie0e1ff798313b190618a42b2a78f8b0cc4184097
2020-08-10 18:52:09 -07:00
Davide Pesavento bc0e617e48 ci: disable frames in lcov HTML coverage report
Change-Id: I5dea51551f8011277d49ce78c80d9064580399a1
2020-08-07 21:05:34 -04:00
Davide Pesavento 5bafd2c7c4 tests: fix Face/TestLpFragmenter after Data encoding changes in ndn-cxx
Change-Id: I6f01ca36ba6f5833a9d73ddc777c5fcdadcd7334
2020-07-28 16:16:27 -04:00
Teng Liang 13d582abec face: remove EndpointId from egress APIs in transport
refs: #4973
Change-Id: I43ca0c0826ec132413c584a1daa2d4687a4965fd
2020-07-22 06:18:21 -07:00
Davide Pesavento d82134b850 ci: add Xcode 11.6 and 12 to Travis CI build matrix
Change-Id: I37add5d807b36dbd8dc8e9f3248488ca5d8a46e5
2020-07-01 22:40:16 -04:00
Teng Liang ebc20f6000 fw: remove EndpointId from egress APIs
This commit partially reverts c707948105

refs: #4849, #4973
Change-Id: I1063e5de2c0e3c90971c4ae006ce46de386c2ed0
2020-07-01 21:34:13 -04:00
Eric Newberry fdc0645d77 fw: add test for received Interest with no nonce
refs #4685

Change-Id: I4f81890b34f4453825f7426e5e55c58b234258cd
2020-06-24 12:46:18 -07:00
Junxiao Shi e1cf4ba46a table: prevent integer overflow in pit::FaceRecord
refs #4979

Change-Id: Iacd5abdfc8ae4530364e3fa590778a234140b7ed
2020-06-19 16:40:53 -06:00
Alex Lane 6bead9b6de fw: Add unsolicited data forwarder counter
Change-Id: I47650e270f0305e34fb4ec9713802671ac96a4cb
2020-06-16 13:37:38 -04:00
Teng Liang f3bc3ae906 face: remove EndpointId from egress APIs
This commit partially reverts 075bb7dac4

refs: #4843, #4973

Change-Id: Iab92addff2bd0fa1e24100d43f9f7076ee84a3f8
2020-06-08 22:06:23 -07:00
Alexander Afanasyev a158370ecb Adjust includes for the updated locations of ndn-cxx security headers
Change-Id: I5a94879966de2c166fed8dedda0ed1d65c33c300
2020-06-06 16:30:06 -04:00
Alexander Afanasyev 34b2b57831 Rename VERSION to VERSION.info to avoid conflicts with modern STL
On case-insensitive file systems (e.g., macOS), inclusion of the new
standard <version> header resulted in unexpected inclusion of VERSION
file.

Change-Id: I5be60b42305856f7b45f3a7116c7bf0cb9082ecf
2020-05-30 18:32:34 -04:00
Eric Newberry 1f237abbf1 tests: avoid use of deprecated default SigningInfo
refs #4804

Change-Id: I32db316bbaca89fb92ec4b70568d0ff7fcd3423b
2020-05-29 10:47:47 -07:00
Alexander Afanasyev 3a2339a1b4 face: Connect faces to the parent (unicast) or associated (multicast) channels
Change-Id: Ie7b2e8fb60050a2bc6e4f5ad053c26e121f3c3d5
Refs: #4973
2020-05-29 10:51:02 -04:00
Davide Pesavento 1752159ae0 build: align minimum build dependencies with ndn-cxx
* Recommend boost >= 1.65.1 and gcc >= 7.4.0
 * Require clang >= 4.0, or Xcode >= 9.0 on macOS
 * Silence an ABI-related diagnostic message from gcc on armv7
 * Fix redundant-tags warning with gcc 10
 * Add CentOS-specific instructions to docs/INSTALL.rst
 * Add Xcode 11.5 to Travis CI

Refs: #5087, #5106
Change-Id: I70746729a132ecb07d4788934385bb403039dba9
2020-05-15 14:25:26 -04:00
Eric Newberry 4995bf960d tools: erase all requested entries from CS in nfdc
This change modifies the behavior of nfdc cs
erase to erase up to the requested count of CS
entries, instead of requiring the user to
continually rerun the command to reach the
desired count of erases.

refs #4744

Change-Id: Ia9b6fa2b4f97769fe6fa911a7b0b5c641ce215dc
2020-04-21 15:31:53 -07:00
Eric Newberry c68b2e8a46 fw: add HopLimit to strategy documentation
refs #4806

Change-Id: I4299c17cb3974efccdd908bcd2aea58ab75c12b4
2020-04-16 13:19:17 -07:00
Junxiao Shi c29eb7f50e fw: attach PIT token upon CS hit
refs #5090

Change-Id: I496ec0865dc4b8dfb35efe2be8453eda96a2ea9b
2020-04-14 13:39:15 -07:00
Eric Newberry 9d283adac4 fw: process HopLimit
refs #4806

Change-Id: I20682570409a576a6f35784f34d33ef27bf801cd
2020-04-14 13:29:30 -07:00
Davide Pesavento b93fb6c831 ci: set ASan's detect_invalid_pointer_pairs to 2
Change-Id: Ibc9a4bd447a8ccebbf864c2da6c279ef5e272739
2020-04-13 20:54:43 -04:00
Davide Pesavento 8f290fc884 ci: add CentOS 8 support; drop CentOS 7
Refs: #5040, #5087
Change-Id: I8a52e02801b8e313d1a7531228616526b0f3cc94
2020-04-12 13:20:07 -04:00
Eric Newberry cb27d91658 common: handle negative unsigneds in config
refs #4489

Change-Id: Ibeab0aad9ac95bef1ef2f17178b795cde4a79fea
2020-04-09 21:23:29 -07:00
Alex Lane 9cec699867 fw: Minor bug fixes for timeout sensitivity and ignored probes in ASF
refs #4983, #4193

Change-Id: I2cf9ac9b51be83e8b03dca40221c7e550c4878a1
2020-04-09 20:12:22 -04:00
Eric Newberry d656aff913 tools: create face during nfdc route add
refs #4332

Change-Id: I1a30bf87abd57bab08a2c027870e779392de0104
2020-04-08 20:55:11 -07:00
Eric Newberry 22974904d3 face: use /run/nfd.sock on Linux
refs #5039

Change-Id: I10902725912a8f194ce6da6590378c1029955f80
2020-04-07 19:33:57 -07:00
Davide Pesavento 69857c37c2 build+docs: switch to python3, refresh FAQ and INSTALL documents
Refs: #5095
Change-Id: Icdc0e9463b28c07783edbe392a9bc47136947e3b
2020-04-06 15:32:21 -04:00
Eric Newberry feeb918ea8 face: handle initially non-running Ethernet interfaces
refs #5096

Change-Id: I27cc913cc2478baa8dfaad08e67bd1b9703c43f4
2020-04-01 16:35:24 -07:00
Eric Newberry 13ff259ec8 mgmt+tools: allow MTU overrides on existing faces
refs #5056

Change-Id: I464a0c68773290bf1cfd0bf2afc4344e79fbb614
2020-03-31 17:50:55 -07:00
Eric Newberry cb6551e96f face: allow GenericLinkService to override MTU
refs #5056

Change-Id: I8eb2dd732b1431e0e809deb53792a14be1698ff1
2020-03-29 16:08:06 -07:00
Davide Pesavento 56c68a364a ci: update Travis configuration
* Drop all versions of gcc < 7 and clang < 5
 * Add clang 11 (development branch)
 * Reenable ASan on Linux with clang 7, the upstream bug has been fixed
 * Drop Xcode 9.2 (macOS 10.12 is no longer supported)
 * Upgrade Xcode 11 to 11.3
 * Workaround issue with missing /usr/local/opt/openssl on macOS
 * Various cleanups

Change-Id: Iee54c0d0480b6ff15bb112a49b3a5c49586ac976
2020-03-29 16:45:43 -04:00
Davide Pesavento 51cf75c8f0 fw+table: use Interest::Nonce instead of uint32_t
Change-Id: I2a4b83696db80d2d0b675121da53a73c309e059c
2020-03-11 22:21:13 -04:00
Jongseok Lee 854866f424 rib: fix logic bug in config file validation
Closes: https://github.com/named-data/NFD/pull/9
Change-Id: I3b7c53c475098ec83fd469ceb40a306dfcd80cf3
2020-03-10 20:23:02 -04:00
Eric Newberry 32f7eac7cd face: deduplicate received LpPackets with reliability
refs #5079

Change-Id: I19ad959ba736253a750997fa468d419c93425686
2020-02-20 15:23:25 -08:00
Eric Newberry 5ab4cf83d9 face: add logging to LpReliability
refs #5080

Change-Id: I2dce3f9d933273cb65603c7cd2177c5d142f4487
2020-02-09 22:06:58 -08:00
Eric Newberry f3ee808927 face: support runtime MTU changes on Ethernet faces
refs #3257

Change-Id: I160fe444b889b8f7be19022a2bd52bbc9f7a21aa
2020-02-09 14:34:00 -08:00
Eric Newberry 97f26a2618 docs: restructure and update AUTHORS.md
refs #5078

Change-Id: Iefa1c730cd83e2965bf92ef6598eb092c4de48f7
2020-01-30 17:13:10 -08:00
Davide Pesavento e89118e8be build: upgrade waf to version 2.0.19
Change-Id: I513db4ba8a12a269deca378e0ab77c7946b3dd63
2020-01-13 21:52:03 -05:00
Alexander Afanasyev fb034219ef Prepare release 0.7.0
Change-Id: I86281204533ea893dd03f35fc0d9403be14f7da4
Refs: #5045
2020-01-13 13:23:45 -05:00
Davide Pesavento cf9e1c7789 tests: avoid deprecated boost headers
Change-Id: I1b79c9422109d2ce8832fd386b524bd9ffffa231
2019-12-22 17:56:07 -05:00
Davide Pesavento 5a897699cf Use NDN_CXX_UNREACHABLE where appropriate
Change-Id: Idb3d8eade91c9e4d6e09f45a54af170f9c74ff12
2019-11-24 13:48:47 -05:00
Teng Liang 18c2b29e41 mgmt: use a separate validator for prefix announcements
This commit also configures the default prefix_announcement_validation
section in nfd.conf.sample to accept any prefix announcement.

refs: #5031
Change-Id: I82e34ce783dfe77c170dd02e78a4bc86faa0147a
2019-11-14 14:00:41 -05:00
Davide Pesavento f7d2050f70 build: pass pkg_config_path to check_cfg() when looking for libndn-cxx
Instead of modifying os.environ

Refs: #5042
Change-Id: Iaf1b87e99d2df6541bc44b1a2f49651c3d5f8c0e
2019-11-07 10:48:44 -05:00
Teng Liang 8e53127d0a fw: SelfLearningStrategy: check if PIT out-record exists
Refs: #5022
Change-Id: Ib4c5288b2b48a65350fbbd6b38892c72aba00f86
2019-11-06 16:43:57 -08:00
Ju Pan 2feb4596a9 fw: add processing for afterNewNextHop signal
Refs: #4931
Change-Id: I08bddc0ae3ceca0ddb777392ea656876ad6fe701
2019-11-06 13:10:57 -08:00
Wenkai Zheng 6598fb0881 rib: error out if both localhop_security and auto_prefix_propagate are enabled
Refs: #4989
Change-Id: Ib742880736a8f5c25e2531d2669a8b993f9f1cd6
2019-10-31 23:13:51 -04:00
Zhiyi Zhang a499aa230f mgmt: Enable use of direct fetch in RibManager
Refs: #2237
Change-Id: I4920af46f03ee5b1471f53f53e2394cca3a2a755
2019-10-13 03:17:58 -07:00
Davide Pesavento 4bd4f71f60 ci: upgrade Travis config to Ubuntu 18.04
Also in this commit:

 * Drop clang 3.8 (no easy way to install it on 18.04)
 * Add clang 10 (trunk)
 * Drop Xcode 8.3
 * Upgrade Xcode 10.2 to 10.3
 * Output folding markers to improve readability of CI logs

Change-Id: I234fcb06527eb60cc1fe4cf5b16eafaa972e07f6
2019-10-09 01:02:45 -04:00
Davide Pesavento a4abfb010f fw: pull FaceTable construction out of Forwarder class
Refs: #4922, #4973
Change-Id: Ibbd4a8840cb0d01ebbd4cabf9c34fa78a1d23db1
2019-10-06 16:08:01 -04:00
Klaus Schneider 380668b6e2 face: Make congestion marking less aggressive
Implement something closer to the CoDel Algorithm (RFC 8289)

Refs: #5003
Change-Id: I909975e7ae1c50d08561a001b67cd9c2c2f150b1
2019-10-05 19:14:39 -07:00
Junxiao Shi 606d5ddc9e face+fw: store and return PitToken from downstream
refs #4532

Change-Id: I97b95232a242186601459622f17983d1bef806d6
2019-09-23 12:47:44 -06:00
Junxiao Shi 24be073413 face: increase pcap buffer size
refs #2441

Change-Id: I927687401fae2d4a9d337d6827f9a735a38ea1bc
2019-09-23 12:38:30 -06:00
Davide Pesavento 759db61b84 daemon: add missing include
Change-Id: I169e1c9e911bf298cd415746b58fda4c4290c931
2019-09-22 19:17:57 -07:00
Ju Pan 6c8c2a0b9c face: add a per face counter for Interests kept by the forwarder
Refs: #4931
Change-Id: Ica1bcec02309eff4d28a55983f089355eb3096fb
2019-09-13 13:03:34 -07:00
Md Ashiqur Rahman c88d2d4a61 Revert "pit: add EndpointId field in in-record and out-record"
This reverts commit d3ae85dbad.

refs: #4973

Change-Id: I0aedfca8ae75137c8c9073a51642bfacf9d8f212
2019-09-11 17:44:17 +00:00
Klaus Schneider cf1d0c0286 fw: Add Random Forwarding Strategy
Implement a forwarding strategy that chooses a random outgoing face,
excluding the incoming face of an Interest packet.

Refs: #4992
Change-Id: I056cd0f05463f5f0742c6adcb32ec1df8ef7529b
2019-09-09 07:04:36 -07:00
Davide Pesavento f689c7944b mgmt: avoid deprecated KeyLocator::Type enum
Change-Id: I8e1528dfee9636096dc10892a37b6d39414e2f4a
2019-08-31 19:42:11 -04:00
Davide Pesavento a6f637a166 fw: various code simplifications in AsfStrategy
Change-Id: Ie006680b2469fa7dc5d9b19665320b2686564f2c
2019-08-31 15:50:35 -04:00
Junxiao Shi df1dc6590c rib: change FIB update mocking method
Previously, FIB update mocking occurs in Rib class. Test coverage
for FibUpdater class is limited to update computation only.
Now, mocking is moved to a subclass of FibUpdater. Test coverage
for FibUpdater class extends to include FIB update queuing.

Previously, mocked FIB update succeeds synchronously.
Now, mocked FIB update completes via io.post, which better
reflects reality that FIB commands are asynchronous.

refs #4731

Change-Id: I563edda5d398eb915f22fecd4b987f32c610d323
2019-08-30 19:03:19 +00:00
wenkaizheng 55d83d449d docs: remove "Installing from Binaries" section from INSTALL doc
Refs: #4984

Change-Id: I56e3be670e0981c4f9e30a7bcec73d8533bde847
2019-08-28 07:42:02 -07:00
Ju Pan d8315bf75b table: add Fib::afterNewNextHop signal
Refs: #4931
Change-Id: I68915b5f5688ad2f62147069fea86956a22672b6
2019-08-27 10:41:59 -07:00
Davide Pesavento 7890a9f26d tests: avoid comparing Interests with operator==
Refs: #4569
Change-Id: Ia75169c147976d3980dd113054ba560caf0f33c8
2019-08-25 23:11:18 -04:00
Davide Pesavento eb7b7abbee fw: use ndn-cxx's RttEstimator in AccessStrategy
Refs: #4887
Change-Id: I7e404df953f99374e676c7eb29897c45d0868eef
2019-08-22 22:15:53 -04:00
Ernest McCracken 1402fa153d fw: Use ndn-cxx's RttEstimator in AsfStrategy
Refs: #4887
Change-Id: Ice718be99f2b96f183bb35c5df84930be54a9f8e
2019-08-13 13:15:50 -04:00
Md Ashiqur Rahman 6be9387a4f Revert "fib: add EndpointId field in NextHop record"
This reverts commit 3ad49db6ea.

refs: #4973

Change-Id: I3216a55a8c4ed52cd9181f790f8ab72e44330a38
2019-08-12 12:00:30 -07:00
Ju Pan 9aafc2a086 Revert "mgmt: add EndpointId for fib dataset"
This reverts commit 602c3aaa56.

Refs: #4973
Change-Id: I02553dc7385d430cf719db3b0f576dc48f6ec059
2019-08-12 08:46:08 -07:00
Ju Pan 57113d1369 Revert "tools: display EndpointId in 'nfdc fib list'"
This reverts commit 13839ac94a.

Refs: #4973
Change-Id: If03e8f22ff4c8c65b20b486302fda0ffc8192662
2019-08-07 21:21:47 +00:00
Junxiao Shi 07f2e2f516 table: rename cs::iterator to cs::Table::const_iterator
refs #4914

Change-Id: I0d81a0983c6bbf8ad2bdf78eec4f37ac73ec3d2d
2019-07-22 09:10:06 -06:00
Davide Pesavento f190cfa470 face: use ndn-cxx's RttEstimator in LpReliability
Refs: #4887
Change-Id: Iaf8b04e33de363bae2c99f10f3866773c900f30d
2019-07-20 02:25:14 -04:00
Junxiao Shi 5153338a18 rib: make several Rib methods private
refs #4731

Change-Id: Id0e7aa70bb21c2a5f08679a2d82e5dc91d618ef4
2019-07-19 13:50:26 +00:00
Davide Pesavento cb425e83e4 face: move common declarations to face-common.hpp
Change-Id: I0e3e7a93f0693b0e24ca67493a4229987e792ef4
2019-07-18 11:07:40 -04:00
Davide Pesavento d214881326 ci: add Xcode 11 to Travis CI build matrix
Also reenable ASan on Linux with clang 9, it seems to be working now.

Change-Id: If1beb0d9437954a229d9dbf248c6a231f6e11ace
2019-07-18 11:03:29 -04:00
Junxiao Shi 5e4a02fe9e cs: avoid Entry construction during query
Using C++14's transparent comparators, CS lookup logic can
compare stored Entry objects with the queried Name without
constructing an Entry object. This in turn eliminates the need
for a special "query entry", so EntryImpl class is deleted.

refs #4914

Change-Id: I5b05a1ab9ad696e79f7ebd6045be8de11cd58ee6
2019-07-15 11:59:18 +00:00
Davide Pesavento 859a69e349 daemon: globally disable automatic verification of Interest parameters digest
Refs: #4658
Change-Id: I07cc6811fc42ee216e0b84cdcb3165170e5d3f89
2019-07-13 17:10:46 -04:00
Md Ashiqur Rahman 115ea63ecf fw: on CS miss, pass ingress with EndpointId=0 to strategy
refs: #4849

Change-Id: Idebbd60c185497bde5c4372e512a5f937b42f0a7
2019-07-05 22:32:19 -07:00
Junxiao Shi 17a7001ae9 rib: consolidate RibManager::FaceIdSet into Rib
refs #4731

Change-Id: Ic78f44e8a504ebf1490dfc1ee4f0fe6cbc7135d0
2019-06-25 10:50:32 +00:00
Davide Pesavento 9d491024ac ci: add gcc-9 to Travis CI build matrix
Change-Id: Id4165765e2099ba9ff242dcef6b4a6fe08eaba97
2019-06-23 19:15:05 -04:00
Ju Pan 13839ac94a tools: display EndpointId in 'nfdc fib list'
Refs: #4816
Change-Id: Id656939d9595adbd8c96a78e9aedfdd8dda2a555
2019-06-19 12:08:43 -07:00
Ju Pan 602c3aaa56 mgmt: add EndpointId for fib dataset
Refs: #4816
Change-Id: Ic463ac34fca8d9c415e66347dfe642ad01c1ce59
2019-06-04 21:45:49 +00:00
Junxiao Shi 47c343b9f2 tools: set CanBePrefix in autoconfig
Also, rewrite RoutablePrefixesDataset test suite to use
SegmentFetcher.

refs #4581

Change-Id: I68e0ffcd59dcbae0856bfa2977545f06482f3515
2019-05-25 07:53:01 +00:00
Junxiao Shi 73b4980eb6 tests: add FreshnessPeriod where MustBeFresh is used
Also, set MustBeFresh in autoconfig-server HubData test,
to reflect the behavior of autoconfig client.

refs #4913

Change-Id: I0af29378630a2208e98ef0913d83668a603e9a88
2019-05-25 07:52:26 +00:00
Junxiao Shi 25d9728d2f table: drop Selectors processing from PIT
refs #4805

Change-Id: Ic15aec7f30d40485031e48e83377a621279e82f1
2019-05-14 13:44:46 -06:00
Junxiao Shi 9d727857dc tests: set CanBePrefix in daemon tests
This commit also updates makeInterest and makeNack functions
so that their APIs are compatible with ndn-cxx test suite.

refs #4581

Change-Id: I0c81740416c26a03450dc3a12c89944b72ce5901
2019-05-14 13:44:22 -06:00
Davide Pesavento 5f59607a8a pit-fib-benchmark: remove gap4 and simplify
Refs: #4929
Change-Id: Iebe064ace48a78aa88449c17f08a9522935448f0
2019-05-11 16:52:05 -04:00
Davide Pesavento b3a23ca711 face: eliminate Transport::Packet wrapper type
Refs: #4843
Change-Id: I5977be55e8bdac33c989e3b8523fea764f304c37
2019-05-07 00:32:57 -04:00
ashiqopu 075bb7dac4 face: add EndpointId in Face and LinkService
refs: #4843

Change-Id: If1249015392ef904a56a0d0d97946e2b3024d7d4
2019-05-02 06:04:43 +00:00
Junxiao Shi 14b391842b table: drop ChildSelector processing in CS
refs #4805

Change-Id: I994d1955091421e6a4ab682f40898999875736fe
2019-04-29 19:19:18 +00:00
Alexander Afanasyev 65c494acf0 Prepare release 0.6.6
Refs: #4916
Change-Id: I1134244b58f14afa32c21dd8270103693cea4e84
2019-04-29 11:05:38 -04:00
Alexander Afanasyev a6bd7da559 build: Remove unnecessary std::ref, causing compilation issues with Boost 1.70.0
Refs: #4923
Change-Id: Idba1abe89161b11b1ec80fdceac51e2b00ed507b
2019-04-26 10:49:02 -04:00
Davide Pesavento b31206e87e fw: always create PIT in-records with EndpointId=0 for now
Also improve test coverage

Refs: #4849
Change-Id: I0f3aba98ec7460f0dbf58b6dc00414e1f722c036
2019-04-23 13:30:56 -04:00
Davide Pesavento 2cae8cacf0 core: move nfd-specific files to daemon/
Refs: #4922
Change-Id: I2243dbb87c63f9cbaf7d7051d7a0d4bca2f9fdb5
2019-04-21 22:15:03 -04:00
Davide Pesavento 2840dbc868 tests: remove support for unit-tests.conf
Logging can be configured, as usual, via the
NDN_LOG environment variable.

Change-Id: I488d4c85961cb013b9e3421d049a9baa8ef45357
2019-04-21 16:27:39 -04:00
Davide Pesavento 0dc3cb1788 ci: adapt to new repo layout for CentOS boost RPMs
Change-Id: I8f8c804d0499fecaac744a08111709d2fd49e7b7
2019-04-20 16:38:06 -04:00
Junxiao Shi 9222f3665b table: eliminate Selectors from CS tests
refs #4805

Change-Id: I6ae48fc40e62aeeb41cde7530d6bfa6b6d5ef000
2019-04-16 15:15:23 +00:00
Davide Pesavento 08b91c8d4e docs: sync sphinx build config with ndn-cxx, improve README.md
Replace custom redmine_issue extension with sphinx.ext.extlinks

Change-Id: Ie6995fd418e4e355cc193b68423899fc029d93ce
2019-04-14 16:01:15 -04:00
Saurab Dulal a6dec22caa fw: properly handle consumer retransmission in AsfStrategy
Do not reject an existing PIT entry if there are no
next hops during consumer retransmission

refs: #4874

Change-Id: Iea8602897e99fdf2f6fd0226b5eb74bd7a4bced1
2019-04-12 20:05:53 -04:00
Davide Pesavento 03f45d2bb6 core: move NFD_VERSION{,_BUILD}_STRING to version.cpp
Change-Id: I97c23de24d8a176bb83a8f481f4880ff49ea710d
2019-04-04 12:35:17 -04:00
Davide Pesavento a809858c53 tests: merge DummyFace::LinkService with DummyReceiveLinkService
Change-Id: I0b45d80055085278bbe028ef95898d68c6e3f824
2019-04-01 22:23:13 -04:00
Davide Pesavento 284bd626fd face: simplify and optimize Internal{Forwarder,Client}Transport
Refs: #4528
Change-Id: Ie3246382965640e0d2cb71116b6526e68925887c
2019-03-31 02:10:02 -04:00
Davide Pesavento 16916ae20a face: introduce NullTransport and use it in several places
Refs: #4528
Change-Id: Icc7a77232bca1a700ce1319493c15a85d05d7488
2019-03-30 15:30:09 -04:00
Davide Pesavento a681a24c22 face: downgrade "Creating transport" log message to DEBUG
FaceTable already logs at INFO level whenever a new face is added.

Change-Id: Id2905c8b6d42df8bfc4c43cc12d432d9ce180aae
2019-03-29 23:51:04 -04:00
Davide Pesavento 14e71f0fe8 tests+tools: minor code cleanup
Change-Id: Ic3356d4a18a8e5eeb45fc076fc0563c3d1549c8a
2019-03-28 18:46:47 -04:00
Davide Pesavento c6a65ad55e nfd-status-http-server: fix display of satisfied/unsatisfied Interests
Amends commit 7570e778e4

Refs: #4720
Change-Id: I61bd78076b0b8d14b106e056a0ea9e000d70369b
2019-03-27 18:30:25 -04:00
Davide Pesavento 17c172ba6b fw: AccessStrategy: fix PIT in-record lookup with EndpointId
Refs: #4849
Change-Id: Ia3e2d033be507cb782b8d6c234a0e53c18590528
2019-03-26 22:53:08 -04:00
Davide Pesavento cf7db2fd83 tests: unit-tests-{core,tools} no longer require a global io_service
BaseFixture is moved to tests/daemon and renamed to GlobalIoFixture

Refs: #4528
Change-Id: If9184e9f7f1d6072b0103d3ea3ca6c31a9e505c8
2019-03-26 22:52:16 -04:00
Davide Pesavento b7703adb88 tests: introduce ClockFixture
Identical to UnitTestTimeFixture, except that it does not derive
from BaseFixture, and thus does not depend on a global io_service.

Refs: #4528
Change-Id: Ia2e6c4835a1e461c73281e103109d5cc85be355e
2019-03-26 22:51:04 -04:00
Davide Pesavento 1d12d2fe4e tests: IdentityManagementFixture no longer derives from BaseFixture
Also rename it to KeyChainFixture

Refs: #4528
Change-Id: Id86f4affc9c4c9ae159912430cc3e78557bf1ac2
2019-03-26 22:50:07 -04:00
Davide Pesavento 3626b59818 ci: update .travis.yml
Change-Id: Iffa90852e74b6ea40bbb52239a91f4fd98de27c4
2019-03-23 13:10:06 -04:00
Davide Pesavento fa2aa50d8d face+tools: fix compilation with Boost 1.69.0
Refs: #4890
Change-Id: I64c2e6ac99767fbd0b8afa9669eb6097148f8628
2019-03-22 21:44:29 -04:00
Davide Pesavento 0a71dd3a00 mgmt+rib: use getScheduler() in RibManager and Readvertise
Refs: #4528
Change-Id: Ie6dd2b0fbe5d57cd7878d86b0185ae5d9bd92cf0
2019-03-19 16:05:24 -04:00
Davide Pesavento 3dade00499 core+daemon: eliminate scheduler::{schedule,cancel} wrappers
Also move core/global-io.hpp to daemon/global.hpp

Refs: #4528, #4883
Change-Id: I0b99029f1a19d7451aab57099cd3303b7eb42ff3
2019-03-19 11:29:56 -06:00
Davide Pesavento 2d83a86255 face: introduce NullLinkService and use it in makeNullFace()
Change-Id: Ia983c62fecdf94aa4f8cbb034735a229bd58d742
2019-03-16 19:27:48 -04:00
ashiqopu c707948105 fw: add FaceEndpoint parameter in Forwarding and Strategy API
refs: #4849

Change-Id: Ibe22557488fa83a555fd13d6eb8e03f8d81d0b2b
2019-03-06 02:27:50 +00:00
Davide Pesavento 78ddcabcd0 mgmt: merge ManagerBase with NfdManagerBase
Refs: #4528
Change-Id: I2ecb4af68927157a9eafc269399855cff192bb54
2019-02-28 23:37:02 -05:00
Davide Pesavento 8a05c7fd2a rib: move RibManager to mgmt
Refs: #4528
Change-Id: Idff4ce8fe28b48163794cd12f0d185f8ca4233e3
2019-02-28 12:32:31 -05:00
Davide Pesavento 1b077f6028 rib: move entire subdir to daemon/rib
Refs: #4528
Change-Id: I7de03631ddef0f014f12f979373aa449f42486d1
2019-02-21 12:37:03 -05:00
Davide Pesavento 50a6af341d table: code modernization
Change-Id: I9ca9a1905aea316726d0323f4537a2420890735f
2019-02-21 00:42:49 -05:00
ashiqopu 77d0bfdaf0 face+table: move EndpointId typedef out of Transport and use it in table
refs: #4843

Change-Id: I2b200518a57b21d66eae4360166afda31c3bf11b
2019-02-20 21:18:08 -05:00
Davide Pesavento 2bdf60c4e8 core+main: switch to std::thread and thread_local
Change-Id: I892eb7d87639c2b0d24a8ed457b9d32635269216
2019-02-19 18:23:45 -05:00
Davide Pesavento 6ecc3f8141 build: respect --without-systemd
Change-Id: I5c5b5f43c5e3ae3ca2812b1f167179d4b6624319
2019-02-19 16:26:33 -05:00
ashiqopu d3ae85dbad pit: add EndpointId field in in-record and out-record
refs: #4842

Change-Id: Id4bca4ad9c2d7c8a2fd975c0b052fb9271b6e47d
2019-02-18 00:07:10 +00:00
Davide Pesavento 97e33024f2 Replace nfd::getExtendedErrorMessage with boost::diagnostic_information
Refs: #4834
Change-Id: I7fc00960d7e5a97748b2277c525a19775810377f
2019-02-15 18:48:22 -05:00
Davide Pesavento 19779d861e Replace all uses of BOOST_THROW_EXCEPTION with NDN_THROW
Refs: #4834
Change-Id: If2455e1830f310beea434ffb455d960e11c4c2ed
2019-02-14 20:48:34 -05:00
Alexander Afanasyev 99a7ce1363 core: Fix compilation error when privilege drop is not supported
Refs: #4833
Change-Id: I2ccc80b31eb5642d66b28e205143243e006f18ca
2019-02-05 14:38:19 -05:00
Davide Pesavento b8bd5ee965 core: use ndn-cxx's getRandomNumberEngine()
Change-Id: I3b5b3ac5238d47ac14481b21d0303c63d0c93b56
2019-02-04 18:52:05 -05:00
Alexander Afanasyev 77cddbc978 Prepare release 0.6.5
Change-Id: I2cc63230fd6b949cfae763a7a1cbeb03ea1d6400
Refs: #4821
2019-02-04 13:31:06 -05:00
Alexander Afanasyev c38219e208 build: Upgrade waf build system to version 2.0.14
Version 2.0.6 had some strange issues with Python 3.7.2 on macOS with
Homebrew.

Change-Id: I1f61c343cbef37db0dbf3fe8b4b291afd84bc0f0
2019-01-30 05:32:53 -08:00
Davide Pesavento 48b4587eee systemd: allow nfd-status-http-server to bind to any port
Change-Id: Ie6e2af3b2e194fbe0c4952b90fc39844b20722f0
Refs: #4533
2019-01-28 22:22:18 -05:00
ashiqopu 3ad49db6ea fib: add EndpointId field in NextHop record
refs: #4284

Change-Id: If0cfc21cfa81d6fa3c1590ecdce8fbbc1ea95e13
2019-01-24 18:07:07 +00:00
Junxiao Shi feddc3c054 core: use ndn-cxx scheduler::ScopedEventId
refs #4698

Change-Id: I5ab56855fb22824e129fd7e3ccfb53174cf34f82
2019-01-17 19:06:00 +00:00
Davide Pesavento 9120cee21d systemd: allow AF_NETLINK in ndn-autoconfig-client.service
It uses NetworkMonitor

Change-Id: I244f61578614307b13ed5b67981e1409e3d9e677
2019-01-16 15:40:36 -05:00
Davide Pesavento 97ab201be7 systemd: add WantedBy=nfd.service to units that bind to nfd
Change-Id: I09c0f05a22985b9182e75feaae0d97791827675e
Refs: #4594
2019-01-16 02:50:56 -05:00
Teng Liang 39465c218d fw: implement self-learning forwarding strategy
refs #4279

Change-Id: I3c80820f9e3382d204a75ea3248234581b4d97d2
2019-01-16 02:25:53 -05:00
Junxiao Shi 00e32fede9 fw: delete deprecated ClientControlStrategy
refs #3783

Change-Id: Ib26ac493a4481dfd26bf01e73d11521f8bb5fde9
2019-01-14 23:34:32 +00:00
Davide Pesavento f392b8ff44 systemd: improve nfd.service, add unit files for tools
Change-Id: I0012278b1898a48ea5594ce648dea1ebc2152113
2019-01-11 14:14:08 -05:00
Davide Pesavento 90290c5664 Add git .mailmap
Change-Id: Ifda2482b1ed27c12efd757f7b2b5b72b28af95a6
2019-01-09 16:54:46 -05:00
Davide Pesavento 2849fd45f0 contrib: remove obsolete upstart files
Move the remaining launchd and systemd files to top-level directories

Change-Id: Ic459b9b7302a7fc574b4e93f1c9d1fe05350761c
2019-01-03 18:43:48 -05:00
Davide Pesavento e271260c49 core: seed the global PRNG with more entropy
Change-Id: I874b742e0d7cccfc71eb4ea21c60e6e1042d7d6f
2019-01-03 15:50:54 -05:00
Davide Pesavento edb69c4375 tests: don't throw if NetworkMonitor lacks CAP_ENUM
Gracefully handle this case by returning an empty list of interfaces

Change-Id: I481e35bd0632db56beca410c4c41dd03a4e04ea8
Refs: #4796
2019-01-02 16:51:21 -05:00
Davide Pesavento dfbeda2f10 build: ensure /usr/local/include is treated as system include path on FreeBSD
Also use the LLD linker by default on FreeBSD.

Change-Id: I45fd307417768e6f79fefdb6ebc6b4dbcafd2b92
Refs: #4790
2018-12-19 01:15:48 -05:00
Junxiao Shi fbdd5cec13 face: set EthernetTransport UP/DOWN based on netif state
refs #3352

Change-Id: I24476ee293d229cd9222996f91f31cfb15728c47
2018-11-26 15:10:51 +00:00
Davide Pesavento 8b663a9528 tools: replace boost::any usage with ndn::any
Change-Id: I7048a64b7c17353037ea9a64a11366d2fae6fd49
2018-11-25 02:49:27 -05:00
ashiqopu d29a5dab89 ci: install gcovr via apt
Change-Id: I83a16e080145e206a08cc5255a906e41605ceca8
refs: #4771
2018-11-25 01:09:15 +00:00
Davide Pesavento 16cbadb47a Use the official markdown version of the GPLv3
Also mention CityHash license

Change-Id: I67b7081cedacc7847c928a6bf8c6450e6849513d
2018-11-23 22:30:20 -05:00
Davide Pesavento 774071c8d5 daemon: basic systemd integration
Notify systemd when NFD is ready/reloading/terminating

Change-Id: I833b48fbcaf6ecc2c4bb8a1da67d4eb9a050c116
Refs: #2815
2018-11-21 00:19:22 -05:00
Davide Pesavento d27841b7d5 face: consistently use the template method pattern in ProtocolFactory
Change-Id: Ied0bf02cfcdffc7e9b2c28c5452441c01f98ccbc
2018-11-21 00:19:01 -05:00
Ju Pan bc59dd0075 face: don't set SO_BINDTODEVICE on Android
refs: #4761

Change-Id: Ife5c61fbc0d6e1af8148c32de5d89d8a3e7fbfee
2018-11-19 20:30:43 -07:00
Davide Pesavento 096f86a311 face: support IPv6-only WebSocket channels
Change-Id: Ib9ba27d04611c13882e50995d701fc1b707cea5f
Refs: #4710
2018-11-11 19:02:18 -05:00
Davide Pesavento 9be9980011 Update WebSocket++ to 0.8.1
Change-Id: I185c26a78aaf8ba6edeec935b0b0e3aa6c6c5f4c
2018-11-11 16:44:31 -05:00
Junxiao Shi eef49a922e face: parse face_system.netdev_bound config section
refs #3521

Change-Id: I803a1651d5b44e021ec7bedb8001e216c849b9ab
2018-11-10 12:19:36 +00:00
Davide Pesavento 28181320e8 mgmt: report face MTU in faces/list and faces/query datasets
This commit also contains an overall cleanup of FaceManager
and extends the FaceDataset test case.

Change-Id: I8c8290b0dc04b25582e66a5c6dad3cca4dd226eb
Refs: #4763, #3325
2018-11-08 18:38:16 -05:00
Teng Liang a4e6ec3155 rib: do the longest-prefix match in self-learning route renew helper
Change-Id: I7f6f349fda6925dc3847716fed123d745f11b02a
refs: #4683
2018-11-08 13:39:37 -07:00
Davide Pesavento 5e1124ccac ci: fix several issues with preinstalled homebrew packages on Travis
Change-Id: I7fa52e6ed80d8c46398243412967226b40882796
2018-11-06 14:40:50 -05:00
Ju Pan 7570e778e4 tools: display satisfied and unsatisfied interests counters
refs: #4720

Change-Id: I69c2400a558997ff48f2b66883cc680dc497360a
2018-11-02 19:49:00 +00:00
Ju Pan 6eb1ac9b49 mgmt: add satisfied and unsatisfied counters for forwarder status management
refs: #4720

Change-Id: I69545e0fbf4ebba75a292644631c2cf9fdaa301a
2018-10-27 21:57:33 +00:00
Yanbiao Li f48d0809f0 rib: reimplement auto prefix propagation based on readvertise
Change-Id: I6c4d81b829cf78084d26121c81d977d0a86c9a0c
Refs: #3819
2018-10-20 10:31:50 +00:00
Davide Pesavento e1bdc08302 rib: stop using the global scheduler
Change-Id: I0e205e2f1adf85be49b132b47791b27e4530697a
Refs: #4528
2018-10-19 14:41:30 -04:00
Alexander Afanasyev 407d569821 Prepare release 0.6.4
Change-Id: I5f72c2fbf2a2ec86c108a47b4c854b069267276b
2018-10-19 10:25:29 -04:00
Alexander Afanasyev 3c0c035609 rib: Avoid use of orphaned ValidationPolicyConfig
Change-Id: Id1fa969a2e4b3c88a21cacdbbeda32d17834fe6f
Refs: #4759
2018-10-17 12:00:17 -04:00
Junxiao Shi 5ba7dfc10f rib: provide self-learning helpers
refs #4683

Change-Id: Ib1e586a505d07a5e1f7a4b6d78306ea08b4dcda8
2018-09-26 14:24:05 +00:00
Alexander Afanasyev a46d41df0e Prepare release 0.6.3
Change-Id: I004e5609f26186ad270bbe5f2015052a7c2be89a
Refs: #4727
2018-09-18 08:52:46 -07:00
Md Ashiqur Rahman 922330b1e0 ci: add support for CentOS 7
refs: #4610

Change-Id: I699bbbe1f59dd3bd0fe23e94de28b44613833ce6
2018-09-16 12:30:57 -04:00
Teng Liang bce3cb528b tests: adapt to lp::PrefixAnnouncementHeader
Change-Id: Ic1bfeb76010955426b421f9239d9bbc987e2f316
refs: #4280
2018-09-16 09:23:54 -07:00
Davide Pesavento 7015694293 tests: use "daemon" user/group in Test{PrivilegeHelper,GeneralConfigSection}
Change-Id: I40ff8317a11e8fb88555f6c85dae3430295ac435
Refs: #3403
2018-09-15 18:40:21 -04:00
Davide Pesavento 69692abf50 build+ci: sync compilation flags and Travis-CI matrix with ndn-cxx
Change-Id: I49c7069bf1fcc1bf89c91a5f92cd830730a32a87
Refs: #4721
2018-09-11 18:11:23 -04:00
Chavoosh Ghasemi 32e7609edf table: Make LRU the default CS replacement policy
Change-Id: I01fe000544da9df860437ffc8869bc6b20e844c0
refs: #4728
2018-09-11 11:47:37 -07:00
Junxiao Shi d47cd63b1b rib: put PrefixAnnouncement in Route and RibEntry
refs #4650

Change-Id: I03a846cd6e013d52f080bd7b092cd392b0284f88
2018-09-11 03:10:00 +00:00
Teng Liang f59e58f202 core: add a facility to execute functions on the main io_service
Change-Id: I38e5f4ad5ed6798a14e0075fb7a14b792f8b2413
refs: #4683
2018-09-10 12:42:01 -07:00
Junxiao Shi 5200904303 rib: change FIB mocking mechanism
Previously, RIB test suites mock FIB updates by invoking RibManager
or Rib's private methods from a callback. In this commit, Rib class
exposes a `mockFibResponse` function variable, so that test cases
can directly specify FibUpdater's response without needing to invoke
private methods. This further allows replacing these private methods
with lambdas.

Also, logic for beginning RibUpdateBatch is abstracted out of control
command handlers, in preparation for PrefixAnnouncement-based RIB
update functions.

refs #4683

Change-Id: I0c95d8daa1458c704c7352a7809e6bed69134642
2018-09-10 12:33:56 +00:00
Davide Pesavento dda258af14 ci: introduce helper to preserve select env variables under sudo
Change-Id: Ia5db4b50e07a40c2eb256182a721c990c5b53382
Refs: #4610
2018-09-09 19:21:42 -07:00
Davide Pesavento 3e7fc83c12 face: add missing out-of-class definition of Transport::MIN_MTU
Also fix a type mismatch in Transport::m_sendQueueCapacity

Change-Id: I5b316917f5088587aefaa1bbb67efe017b77c155
2018-09-08 14:21:22 -04:00
Ashlesh Gawande f84bac5a7a rib: fix initialization error in Service
refs #4723

Change-Id: Ibfe313a3e2f1b0e57ee81661aa387397101228f9
2018-08-27 07:39:31 +00:00
Junxiao Shi f4cfed1a61 rib: move config parsing to Service class
This commit also de-duplicates code in Service class constructors
and reduces usage of unique_ptrs.

refs #4650

Change-Id: Ibbf454841b76ffe4d569b51fef3b1d06f7d2fdfc
2018-08-22 23:26:29 +00:00
Davide Pesavento 9f8b10e350 rib: change object ownership
rib::Service instead of RibManager now owns Controller,
Rib, FibUpdater, AutoPrefixPropagator, Readvertise objects.
RibManager is only responsible for serving RIB management
commands and datasets.

refs #4650

Change-Id: Idb99cdc6cb97b3e3c1bc56685b3ca121b062c7f5
2018-08-22 08:45:37 +00:00
Teng Liang 04d5ce685d rib: make Service globally accessible via get() static function
Change-Id: I2101fb81a613d301acbce7f26e062caa692c5e29
Refs: #4683
2018-08-11 00:54:18 +08:00
Teng Liang 952d6fd3d7 core: add a facility to execute functions on the RIB io_service
refs #4279

Change-Id: I29222053348e5d1737d47c85a59d29280b4b791b
2018-08-05 14:12:14 -04:00
Junxiao Shi b53fe6444b docs: improve ndn-autoconfig man page
refs #4201

Change-Id: I544d7ac9b71ab28ada11b47c852a3de681ed8b4c
2018-07-25 11:45:35 -06:00
Junxiao Shi a4d7fe0f22 tools: implement 'nfdc cs erase' command
refs #4318

Change-Id: If4dc401a3efff44a5bf4b3074d21797f8384cf9f
2018-07-20 06:51:41 -06:00
Davide Pesavento 457f135980 face+tools: use Boost.Endian for endianness conversions
Change-Id: Ia9c8777cc16130ace9f1ca478624d71e6a11fadd
2018-07-14 17:17:38 -04:00
Davide Pesavento d657d53eea build: require clang >= 3.6
Also fix an unused lambda capture warning with clang >= 5.0

Change-Id: I29c56cdf560da4a44efa038d4e65d868975aab6e
2018-06-26 21:16:10 -07:00
Eric Newberry 359135cfb2 tests: check against new SegmentFetcher error messages
refs #4364

Change-Id: I543930d76a01ef1eeef611fb589eb722342b5a86
2018-06-26 21:02:12 -07:00
Eric Newberry 4f8dd96fbf tools: add mtu option to 'nfdc face create'
refs #4789

Change-Id: I9e31c5fb460ee99199332ffb6fadc9f0f33125e9
2018-06-20 22:16:57 -07:00
Eric Newberry 812d615717 mgmt+face: allow MTU of datagram faces to be overridden
refs #4005

Change-Id: I01d98b88cdee41b633f6fb9a5600088efe8de749
2018-06-19 16:28:29 -07:00
Davide Pesavento e4b2238b33 Improve and simplify code with modern C++ features
Change-Id: I83bf5513c2a1f90ba5a59e93c473306864b27d94
2018-06-11 20:26:47 -04:00
Davide Pesavento 1705744468 tests: stop using deprecated {get,set}FinalBlockId
Change-Id: Ibe3f7b394487773139ec4e17d2b87ca8cb06504a
2018-06-06 16:25:04 -04:00
Davide Pesavento c0822fa4a5 build: switch to C++14
Change-Id: I7a32dad01e74ef5b7c5f37a5464d0b17a7882c61
Refs: #3076
2018-06-06 16:24:22 -04:00
Nick Gordon 7b8e797c32 docs: minor changes to the contributing guide
refs: #4475

Change-Id: I7e1e43e5f0990b7f1a9ff7e3463ebe620e92fe4e
2018-05-24 10:20:50 -04:00
Davide Pesavento 9c33b90fd3 core+face+tools: use asio::ip::address::from_string directly
The compatibility wrappers in ndn-cxx are no longer needed
and will be deprecated soon.

Change-Id: I394164c11dfe776f1d5a6f7c0dceffe9ce6ad85f
2018-05-22 18:22:49 -04:00
Davide Pesavento 5f35f64d9a build: require gcc >= 5.3 and boost >= 1.58
This effectively drops support for all versions of Ubuntu older than 16.04

Change-Id: If1c96cc697d38a94588f126a89d13ec8e582702d
Refs: #4462
2018-05-10 20:33:57 -04:00
Davide Pesavento a3148081ce core: reimplement logging using ndn-cxx's facility
Change-Id: Ifc7c5d70a61ad405dc1f1adfa522a2c0ad1586ab
Refs: #4580
2018-05-05 23:04:22 -04:00
Alexander Afanasyev 782a1d1621 Prepare release 0.6.2
Change-Id: I50c8479efa4fff6244f50555d8ff552530bc4509
Refs: #4564
2018-05-03 15:00:14 -04:00
Davide Pesavento 67f797f9a3 ci: add gcc-8 to Travis-CI build matrix
Change-Id: Ibf4ea92af716c44c5a91e704c605b2b811f3122e
2018-04-28 14:51:27 -04:00
Junxiao Shi 21e0193e5c face: piggyback Ack field with fixed-width encoding
refs #4403

Change-Id: I4b0123d20aea058581774d467452553724fddc61
2018-04-21 10:39:05 +00:00
Davide Pesavento e34a2825f1 core: silence truncation warning in LoggerTimestamp's operator<<
Change-Id: I85882bf5589fbdb8239deec285509c123740ec25
Refs: #4365
2018-04-20 13:10:18 -04:00
Davide Pesavento 45898d2215 tools: fix compilation with Boost 1.67
Change-Id: Ia2bdaa0c78757a03796acf64b15c781ec9fa6c0e
Refs: #4584
2018-04-19 12:32:40 -04:00
Junxiao Shi bd72431945 mgmt: implement cs/erase command
refs #4318

Change-Id: I2c8180cde940cc378a219f9aaecae71cd3b0b28c
2018-04-17 02:23:48 +00:00
Davide Pesavento 87fc0f8d6f core: drop std::function and ndn::Exclude from common.hpp, add ndn::optional
Change-Id: Ie3983d8b6f9929430efd8ada8d942e3f95755cd4
2018-04-12 14:23:40 -04:00
Davide Pesavento 981db808cb Delete core/asserts.hpp and use ndn-cxx's util/concepts.hpp instead
Change-Id: I13a3460c1c3a90ea0fdca3d8212267353f72af4f
2018-04-11 19:24:54 -04:00
Davide Pesavento 1cb619e63b docs: fully qualify types documented via doxygen's \class command
Change-Id: I38594e4d358078d3c6dc7c588695c4b299a44895
2018-04-11 19:24:48 -04:00
Alexander Afanasyev ded17426c6 face: Configurable IP subnets for "local" TCP faces
Change-Id: Idaddfe4b2c304b552d2e132235f4c3d3e6c2ebcb
Refs: #4546
2018-04-11 19:23:41 -04:00
Alexander Afanasyev e4d745d41f core: Add IpAddressPredicate for white-/blacklisting IP address subnets
Change-Id: I9f67c4bcbc55e8a8de0bb70812c5562ba083c948
Refs: #4546
2018-04-10 19:28:07 -04:00
Teng Liang 43bb2315ea fw: introduce afterReceiveData strategy trigger
Change-Id: Ia805f1bd48f481c9b903b6ce5c388dd66fbbb7d1
refs: #4290
2018-04-10 05:30:36 -07:00
Alexander Afanasyev 3bdc1decf6 core: Add support for IPv6 subnets in Network::isValidCidr
This change effectively adds support for IPv6 subnets in white-/blacklists
of NetworkInterfacePredicate

Change-Id: I1962100329d398b4659c4d1a4a0975fa354af026
Refs: #4546
2018-04-09 19:25:14 +00:00
Junxiao Shi 30c37ab9bf table: add Cs::erase method
This commit also corrects CS's description in Doxygen.

refs #4318

Change-Id: Ie8854a2e2b59a072b98603c0cc31768bb84ea6d2
2018-04-09 14:26:47 +00:00
Eric Newberry c14a8acf39 build: find Boost lib architecture automatically
refs #4573

Change-Id: Ie58f18c0634a837b303e290018f8a9a5bb71f5c7
2018-04-07 16:32:43 -07:00
Eric Newberry 971d9621ce face: correctly handle removed fragments in LpReliability
refs #4479

Change-Id: Id5d1aa231ddfc10a14859ef819f6dde0a4111501
2018-04-02 18:37:29 -07:00
Eric Newberry 3406dc9742 docs: only use sphinxcontrib-doxylink on Python 3
refs #4553

Change-Id: I001d1fddc13994f8a522251a439cad0467bd8c58
2018-03-25 14:35:18 -07:00
Teng Liang 85a36632a7 fw: introduce afterContentStoreHit strategy trigger
Change-Id: I71ca9e21467d2296203eb9686bff7647b1140271
refs: #4290
2018-03-22 21:57:06 -07:00
Junxiao Shi 7a36ac7d9d tools: include CS config in 'nfdc cs info'
Also, ForwarderGeneralModule::formatItemText now uses ItemAttributes.

refs #4050

Change-Id: I1b2bde29b82e4b3910d87b41efd90e273052b18d
2018-03-21 15:23:22 +00:00
Junxiao Shi 057d149fda table: enforce NameTree max depth universally
refs #4262

Change-Id: Ia9b04a89c12cd09aa244201b513cc1808c0c473f
2018-03-20 17:14:18 +00:00
Teng Liang 7003e0bc66 fw: replace straggler timer with per-strategy decision
remove onInterestReject pipeline

refs: #4200

Change-Id: I184d7ef7f732efda3d1066eef6cd89e36a6a8802
2018-03-20 00:26:15 -07:00
Davide Pesavento 3cf75dc10b mgmt: prevent potential nullptr dereference in FaceManager
Change-Id: Ice622f2b51a3be448dc1c211dc4f80d967db14c6
Refs: #4548
2018-03-17 00:38:03 -04:00
Davide Pesavento 068a71d6f0 ci: update .travis.yml
Change-Id: I0bb8694ccbef65ec124def2aafcd772c8dd058c7
2018-03-15 00:52:34 -04:00
Davide Pesavento 0064c1dd91 build: update waf to version 2.0.6
Major cleanup of all build scripts

Change-Id: I6904f034d40adc66366fdf08749900ffb31c68d9
2018-03-08 20:16:30 -05:00
Junxiao Shi cdf7845986 tools: add 'nfdc cs config' command
refs #4050

Change-Id: Ifc49b78a286b1947452d3d7917b5937b95d1bfe5
2018-03-03 07:37:47 -08:00
Junxiao Shi 8dc473a724 tools: simplify on/off attribute printing
refs #4004

Change-Id: Idb666ff4dbeddc37f1cb10710ba3d75f7fe8bdb5
2018-03-03 07:35:50 -08:00
Teng Liang 6f09ab6cde fw+table: add isSatisfied and dataFreshnessPeriod to PIT entry
Change-Id: I00731028131139164adca342d0a0fd7d3af0709a
refs: #4290
2018-03-02 23:22:32 -07:00
Davide Pesavento cfb1a315ed mgmt: eliminate FaceManager::setConfigFile()
Change-Id: Ib39b05a969345448b3719047093577df31d2bf8a
Refs: #3904
2018-03-01 01:35:36 -05:00
Teng Liang 63086448bf fw: remove onInterestUnsatisfied pipeline stage
Change-Id: Ic008bb26b87db176bac8d51230e53f923b19e5d2
refs: 4290
2018-02-27 13:20:11 -07:00
Davide Pesavento 47456e7d98 daemon: log more detailed build info at startup
Change-Id: Ie0a96a3871c24879d6bb2afdd8544da9724253a2
2018-02-25 19:54:14 -05:00
Davide Pesavento b922c8891c tools: ignore URL query string in nfd-status-http-server
Change-Id: I5e071b7f036a0ef4e9a6e8b6a1eaf637aa5ad92e
2018-02-25 19:51:52 -05:00
Davide Pesavento 9e5b8af1f5 tools: fix a couple of HTML/CSS validation errors in the status page
Also update reset.css and text.css from the Unsemantic project
https://github.com/nathansmith/unsemantic/tree/master/assets/stylesheets

Change-Id: I8f6292461f13902d39b511399515b3efdf50c8c5
2018-02-25 19:50:12 -05:00
Davide Pesavento 6a88b5f435 tools: use CSS to paint table rows with alternating colors in the status page
Change-Id: I04416437e2b18b452bde2f478084090f92003a85
2018-02-25 19:49:04 -05:00
Davide Pesavento d9c520bed9 tools: fix listing of face flags in HTML status page
Change-Id: I288615eb8379979b0e3eb9599e1adb1d06478814
2018-02-24 14:49:14 -05:00
Davide Pesavento d214744ab8 tools: alias 'nfdc cs' to 'nfdc cs info'
Change-Id: Ied1d34a84110ee0b6488d35d56fb1caecaf14117
Refs: #4498
2018-02-20 21:39:09 -05:00
Davide Pesavento 2a58815ee3 tools: extend nfdc help to cover more cases
Change-Id: I0cd182c8635b15c8ffb750c913e14fa99e595d45
Refs: #4503
2018-02-20 21:34:00 -05:00
susmit 3f94ec31f3 Prepare for 0.6.1 release
Change-Id: Ia0b2f1bedafecc58030b66c7cae81ae03eba7886
Refs: #4497
2018-02-19 09:41:38 -05:00
Davide Pesavento e0bae0f64b tools: make nfdc smarter when the user asks for help
Now 'nfdc foo help', 'nfdc foo --help', and 'nfdc foo -h'
are all accepted as synonyms of 'nfdc help foo'.

Additionally, '--version' can be used in place of '-V'.

Change-Id: I070bb0ea9231a2642c40938377f1e9af2630b34e
Refs: #4503
2018-02-18 10:26:12 -05:00
Teng Liang fdcbb4d0ef face: support NonDiscovery and PrefixAnnouncement in GenericLinkService
Change-Id: I2b9577203274d28b374ebfd6a8154b5398b8ec57
Refs: #4280, #4355
2018-02-18 11:23:56 +00:00
Davide Pesavento acd00876f9 core: optimize PrivilegeHelper::runElevated()
Using std::function is overkill

Change-Id: I0e60592aea1b2fb82c3ea780701dae5e129a9810
2018-02-15 18:26:18 -05:00
Davide Pesavento d7b44c817d face: elevate privileges before calling setsockopt(SO_BINDTODEVICE)
Change-Id: I33db8eb59ffd17dab087c0a6af5faf273f1c5987
Refs: #4507
2018-02-15 17:41:06 -05:00
Davide Pesavento 4d82692800 docs: update XML Schema for nfdc status after the recent changes
Plus some minor docs updates

Change-Id: Ieb8d6f520c47c022087354d745e33fff58c2d875
2018-02-12 19:28:30 -05:00
Davide Pesavento 56a741f29a tools: port nfd-status-http-server to python3
Also cleanup tools/wscript

Change-Id: Iedb9d0ef3c63ad5ef7350381f0b5dfe1681f82b0
2018-02-12 18:52:08 -05:00
Eric Newberry 17d1849dec face: enable congestion marking by default on supported faces
refs #4465

Change-Id: Id545f83763f1ba27ba0d770fd4398948d6f20acf
2018-02-11 23:23:09 -07:00
Davide Pesavento 003357899d tests: increase tolerance in several time-sensitive test cases
To avoid spurious failures when CI build bots are overloaded.

Change-Id: If6ec5579dfef1f9fdbd57723e6aeec0a46221a3f
2018-02-11 14:42:47 -05:00
Eric Newberry de33245d9f tools: add congestion marking parameters to nfdc face create
refs #4465

Change-Id: I5df5d6136f4729ad836a72f55531208d868da5f7
2018-02-10 14:04:10 -07:00
Junxiao Shi 26667e16df mgmt: include capacity and enablement flags in cs/info dataset
refs #4050

Change-Id: I3de0692ec9f26429733bade80a96e154865928fe
2018-02-08 20:01:18 +00:00
Davide Pesavento d5e89e8c7d face: initialize m_wantCongestionMarking in factories
Amends commit 0c84164fd0

Change-Id: I05dc7afee02abd8053a72f548f4cdd00b5f60d6e
Refs: #4465
2018-02-08 19:23:37 +00:00
Junxiao Shi c9b5e018ed mgmt: implement cs/config command
refs #4050

Change-Id: I86b050ac062855bad66197a775a502007e687d8d
2018-02-07 15:04:18 +00:00
Junxiao Shi 02a0e0fbe3 mgmt: limit prefix length in fib/add-nexthop
This commit also makes FibManager logging more consistent.

refs #4262

Change-Id: I8e1d58eacfdf0a87d6f94182c78a157421de6f6f
2018-02-06 02:03:45 +00:00
Ashlesh Gawande 92e4ea53ba fw: Add ASF strategy parameters n-silent-timeouts & probing-interval
refs: #4193

Change-Id: I9572425a2fdcbf67b9886c2a5b6b50a10a0856e2
2018-02-06 01:09:01 +00:00
Davide Pesavento 494a955b56 face: support non-listening UDP channels
This commit also improves coverage of the ProcessConfig
test suite for the various protocol factories.

Change-Id: Id9dbe2ca914e273f9225cd93db41bf714c714591
Refs: #4098
2018-02-05 02:31:20 -05:00
Junxiao Shi 332783b3e5 mgmt: respond with 414 if StrategyChoice prefix is too long
refs #4262

Change-Id: Ief6dec02d7fbf372382a167e04d82e48777fa30b
2018-02-04 23:52:46 +00:00
Davide Pesavento d96744d968 mgmt: don't crash if no authorizations are configured
Change-Id: I02d439a73c9b02fcb7141104d62a67aa1fa5aefb
Refs: #4487
2018-02-03 20:19:09 -05:00
Davide Pesavento 85244373f9 core: don't complain if the configuration file is empty
It is not an error in itself.

Change-Id: I2d100203c9c63ef4774e00dfa17fd1087e381122
2018-02-03 20:19:09 -05:00
Junxiao Shi 75306351ff rib: limit route prefix length in rib/register command
refs #4262

Change-Id: I567934419f6872cb0f5a823400f53014b9c6e85e
2018-02-01 21:59:44 +00:00
Junxiao Shi 3d2049fbc1 table: add CS enablement flags
This commit also:

* deletes never-implemented and unused Cs::erase method
* groups CS configuration methods together
* uses Table::emplace in Cs::insert

refs #4050

Change-Id: If8cf29dd33921da2f2c4ce56e02395d43cd3ee99
2018-01-30 09:15:15 -08:00
Eric Newberry 0c3e57b399 face+mgmt: allow congestion marking parameters to be enabled and set
refs #4465

Change-Id: I9d49135ab32bacb2885b70031c573f7c8709ac1f
2018-01-29 21:52:53 -07:00
Davide Pesavento 15b5505e01 face: group parameters to createFace and connect into a common structure
Change-Id: Icb6857602ed7e897be6c5334b05be23793d133bb
2018-01-29 18:56:12 -05:00
Davide Pesavento 97a010178c tests: prevent unsigned integer underflow in TestUdpFactory/Blacklist
Change-Id: If00bb69fc2ddaded91c199c6ba17d94e12b1ffea
2018-01-22 19:37:44 -05:00
Davide Pesavento 5cc706c8cb tests: update copyright in test case example
Change-Id: Ifb12152dc56b59c038751c53abc169f3d36c8b17
2018-01-22 17:39:00 -05:00
Junxiao Shi 0e13e1e2e2 docs: give nfdc examples
refs #4234

Change-Id: Ib8102edfc64f2cc8e822335baaa288b0cec3cf42
2018-01-22 08:29:12 +00:00
Eric Newberry 0c84164fd0 face: allow enabling/disabling congestion marking through config file
refs #4465

Change-Id: I888b83b1fdbe8e3fc36a902bf7af52147807d829
2018-01-22 01:00:16 +00:00
Davide Pesavento a6f2d245d7 tests: use BOOST_TEST_GLOBAL_CONFIGURATION with boost >= 1.65
Change-Id: I12b06a97955f611a48642bc20ebc896e1007ccb1
Refs: #4255
2018-01-21 16:18:00 -05:00
Md Ashiqur Rahman 8ce09032ff face: implement IPv6 UDP multicast transport
Change-Id: Ib6ab956354dbbba00694c7949fa9ee4639579879
Refs: #4222
2018-01-14 22:43:25 -05:00
Eric Newberry b49313db62 face: congestion detection in TCP, UDP, and Unix socket transports
refs #4362

Change-Id: Idaa5d65e1f33663d95bad56de42640183b2cda6d
2018-01-14 17:50:01 -07:00
Davide Pesavento 167040a677 ci: update Travis-CI configuration
* Add clang-6.0 to the build matrix (allowed to fail)
 * Upgrade xcode9 to xcode9.2
 * Various simplifications

Change-Id: I626006f79bbb7a1a79ec804c66ef30fef1e7cfd2
2018-01-10 02:48:47 -05:00
Junxiao Shi 3160a3f820 tools: implement 'nfdc cs info' command
refs #4219

Change-Id: I4252878943c3f6c88f306f83f5023fffc82326b0
2018-01-09 21:25:15 +00:00
Nick Gordon 3257af2823 docs: mention the contributing guide
Change-Id: I3f35c7bfa652fca9d32a2476b979415f8f5150c7
refs: #4415
2018-01-06 09:09:54 -08:00
Junxiao Shi f2bfb44a4a mgmt: CS information dataset (hit/miss counters)
refs #4219

Change-Id: If3ede6b3cba3b836e4e3190989c65f13280fa972
2018-01-05 12:34:57 +00:00
Davide Pesavento 8215a3ada6 face: deduplicate multicast UDP socket setup
In preparation for adding IPv6 support.

Change-Id: I5a3be2007f7fecc44915a5d6794093143ce9c0f9
Refs: #4222
2017-12-26 13:58:24 -05:00
Eric Newberry 4738f15594 tests: make CongestionMarkStrategy parameters human-readable
Change-Id: I45448640b9125015a0ae2711f14fc3c1472603c3
2017-12-21 21:10:50 -05:00
Eric Newberry 00d39fda3c tests: improve LpReliability unit tests
count retransmitted, but received packets properly in LpReliability

refs #4391

Change-Id: I6867a70a1e7d7e949a250982df2ff97e49848996
2017-12-13 05:25:24 -08:00
Eric Newberry 78ef901f24 tests: allow parameters to be specified to CongestionMarkStrategy
refs #4327

Change-Id: If33efc23cc0e4d85aaa99cfcb5411e42b409c899
2017-12-12 13:49:01 -08:00
Junxiao Shi 3f9234b2cf table: limit prefix length in Measurements
refs #4262

Change-Id: Ife04f8df1fb833b477d055a1cd1f37d2af474e7f
2017-12-07 17:41:50 +00:00
Alexander Afanasyev 0c63c63ed7 build: Fix build when std::to_string is not available
Change-Id: If34fcebe17bd7e3de23655680957fa6e0df27676
Refs: #4393
2017-12-05 11:27:41 -05:00
Eric Newberry 69b63dcdd4 tests: add integration test helper strategy CongestionMarkStrategy
refs #4327

Change-Id: I966ed4fb4526338138712017e326cc80a1a3be7a
2017-11-22 00:06:53 -07:00
Eric Newberry 41aba10d3d fw: add strategy notification for Interests dropped by LpReliability
add dropped Interest counter to faces

refs #3823

Change-Id: I9910b66932d74383203e8f3732bb45cade83b972
2017-11-20 18:10:52 -08:00
Davide Pesavento 4253885f23 contrib: improve systemd service file for nfd
Change-Id: I784d8acc26d480bef5c4daf750957d85340b50d6
2017-11-20 10:41:19 -05:00
Davide Pesavento 59769b1864 Make the exit status consistent across all programs
(except nfdc)

Change-Id: Ia3edb11b3f4284df5db8279b06e6fb708ae454e9
2017-11-20 10:41:07 -05:00
Eric Newberry 52ae3296bd tests: remove reliance of other tests on WITH_TESTS
refs #3609

Change-Id: I8fa858d207cd060cfcda7c86af56dac4afb48fe1
2017-11-18 20:45:32 -07:00
Davide Pesavento bb734df9f6 face: pass the whole NetworkInterface to UdpFactory::createMulticastFace
Instead of just the interface name. This is in preparation
for adding IPv6 support to createMulticastFace.

Change-Id: Ie3c02af4483b041d39d4e85c85cd712368e9bb8f
Refs: #4222
2017-10-28 15:54:48 -04:00
Davide Pesavento bc79bd63c7 tests: fix Face/TestTcpTransport/PermanentReconnectWithExponentialBackoff
Change-Id: I9728c8e4f350589fd2f5af03fc82fcdb0f8bfe24
Refs: #4301
2017-10-28 15:54:17 -04:00
Davide Pesavento 6daf2a39f5 ci: add Xcode 9.0 to Travis-CI build matrix
Change-Id: Ib37408bde561b8191cbdd6c746efcf6303d36f4b
2017-10-17 16:28:18 -04:00
Davide Pesavento 22fba35327 tests: test IP transports under various combos of address family/scope
In particular, link-local addresses are now tested as well.

Additionally, WebSocketTransport send/receive tests are extended
to check transport counters.

Change-Id: I5b35f498a5d8d70cb1f7a2bea3ce99d22370e050
Refs: #1428
2017-10-17 16:00:11 -04:00
Alexander Afanasyev 84dd4ca348 Prepare release 0.6.0
Change-Id: I0a80e05ddf5e3b98544bf56575e13efae22ccb5b
Refs: #4275
2017-10-15 17:47:06 -04:00
Davide Pesavento b8d1fc7562 tests: add support for link-local addresses in getTestIp
Change-Id: If57cb93f1c25a18b680aef12895ee5924ca90cfa
2017-10-09 16:09:55 -04:00
Davide Pesavento 6d1c1c320b tests: stop using deprecated Buffer::buf()
Change-Id: I48b7672098cfe57ccb470a247eed0c80e24cfffe
2017-10-09 15:53:37 -04:00
Davide Pesavento 4b89a6e943 face: move createChannel overloads that take strings to unit tests
They are used only there.

Change-Id: I0c70221bbcad36024223cc6e3c929b9c08b683c0
2017-10-07 15:29:50 -04:00
Yanbiao Li afb2059377 use ndn::ip::address(V6)FromString for scope-id aware conversion
Change-Id: Ifdc31771b8a990867c0a79ba42b71c87a97bcd56
Refs: #1428
2017-10-06 10:15:51 -07:00
Junxiao Shi 4e837f8d12 table: limit prefix length in StrategyChoice
refs #4262

Change-Id: Iddebeb555b2f3315515a298f8cded353fb51854d
2017-10-02 22:14:43 +00:00
Davide Pesavento b5eee2066b face: delete deprecated FaceSystem constructor
Change-Id: I54d623f1432428c2c3516a00f66dfe3f847bbc2c
Refs: #3377, #4021
2017-09-22 21:20:02 -04:00
Davide Pesavento 0804f5dd1f tests: stop using deprecated Block constructor
Change-Id: If50d5f0e2a4d6cef3a5e84e0f1da4a388b216233
2017-09-22 21:19:42 -04:00
Alexander Afanasyev 847de408cb build: Add warning for non-virtual destructor and fix discovered issues
Change-Id: I1d67b9b63d84d8524580e80ac06c3efef860c56a
2017-09-22 15:00:29 -04:00
Alexander Afanasyev b5220706c6 build: Add -isystem and set specialized flags as a last configuration step
This change prevents global flags from interacting with library/feature
detection scripts.

Change-Id: Id4d1d3f6cba6672ef04309b881bcff36a106f236
Refs: #4296
2017-09-22 15:00:03 -04:00
Alexander Afanasyev 38fb251c44 Update security section in sample config for V2 certificate
Change-Id: I50225d5019040a85e6df3584fb48b6b6386ed56d
Refs: #4276
2017-09-17 18:33:44 -07:00
Chavoosh Ghasemi 60b7d51063 docs: Fix reference to ValidatorConfig documentation
Change-Id: I43d96c64d031ad318333de8613e589633e58b52e
refs: #4184
2017-09-15 13:07:27 -04:00
Davide Pesavento 085b9e3a6f ci: add clang-5.0 build job to Travis-CI
Change-Id: Iea59e4f4687485dd4f076d41a4d6d6f1c8da7797
2017-09-15 12:53:12 -04:00
Junxiao Shi cfe81d5098 face: increase tolerance in WebSocketChannel test
Face/TestWebSocketChannel/SetPingInterval now allows 80ms
absolute tolerance, so that the test case is more stable on
slower machines.

refs #4244

Change-Id: I897f3b33a0ea2eb9006f0dd8d70ef2a4624953e2
2017-09-15 03:26:08 +00:00
Junxiao Shi 042a331582 table: attach PIT entry to NameTree node within depth limit
refs #4262

Change-Id: I64d76a337c3b491efa2f93c803046cea70c87000
2017-09-15 02:51:20 +00:00
Davide Pesavento ac238f29be tests+tools: fix build with clang-5.0
Change-Id: I75eeb01b071c1702517a65a8099e52d4092a4638
Refs: #4278
2017-09-12 15:22:02 -04:00
Junxiao Shi f940ae70f2 fw: use lp::isLessSevere from ndn-cxx
refs #4228

Change-Id: Ib430810ef356c309aa1f800f9b09c51d09dbc012
2017-09-11 03:24:29 +00:00
Junxiao Shi f54d0301c6 table: advisory limit of NameTree depth
refs #4262

Change-Id: I691f9615e2b8a3b146a683919c6d5833f53f6122
2017-09-07 18:16:38 +00:00
Nick Gordon 88043fcbe8 docs: clarify adding gerrit as remote repo
Change-Id: I92498afc362d254534ca03168fb8f0dca6a37f8e
refs: #3898
2017-09-07 08:49:03 -07:00
Junxiao Shi 06a1eab063 fw: Forwarder provides CS hit/miss counters
refs #4219

Change-Id: I7058c43bac4a5508d4b9907f6e684663b8953656
2017-09-04 13:13:02 +00:00
Junxiao Shi a907980840 tests: do not encode invalid SignatureInfo
refs #3200

Change-Id: I54199080439a41cf91c190e64a68540afabc7414
2017-08-27 11:38:56 -07:00
Davide Pesavento c25737cd9a ci+docs: remove all references to cryptopp/crypto++
Change-Id: I40fc72a8fa27c1a73c349e8cbaeb402a8b6af742
Refs: #3946
2017-08-26 16:39:56 -04:00
Eric Newberry 84d3adcd6c tools: add reliability option to nfdc face create
add LpReliability flag to FaceManager face status output

refs #4004

Change-Id: Ibcdfe7ff0fc9790cbcc4f2aa5e57e27b8a76023c
2017-08-26 12:39:10 -07:00
Davide Pesavento a997d29622 Fix compilation with Boost 1.65.0
Change-Id: Ib88b7e13bddb1728dd882c086e97edffdd696f0d
Refs: #4258
2017-08-25 23:30:24 -04:00
Md Ashiqur Rahman c8f17e51ed tools: Make ndn-autoconfig register / instead of /ndn
Hosts in consumer region should use / instead of /ndn as default route.

refs #4201

Change-Id: I6dd15c6657cfe9110c7a4dc3e9046370cbaf2733
2017-08-22 15:08:58 -07:00
Davide Pesavento c0a5a39a4f Add -Wextra-semi -Wundefined-func-template to the default CXXFLAGS
And fix the resulting compilation errors.

Change-Id: I2f8a8406542d297bfeeb4c922812ff1879a4dff6
Refs: #4248
2017-08-20 14:29:18 -04:00
Alexander Afanasyev 01bbd09ed8 tools: delete nfdId from 'nfdc status' output
refs #4089

Change-Id: I95f8a4346b2c4601acdc63daac20259b076a1d7e
2017-08-14 23:56:19 +00:00
Junxiao Shi 15902efdef tools: delete legacy nfdc and nfd-status invocations
The following legacy nfdc sub-commands are deleted:
- register
- unregister
- create
- destroy
- set-strategy
- unset-strategy
- add-nexthop
- remove nexthop

nfd-status no longer accepts command line arguments.

refs #4198

Change-Id: I3ec61fd24c09599c87f07bd92d8f0b5f4e7c70de
2017-08-11 22:58:35 +00:00
Davide Pesavento 00a3c9dc86 face: enable fragmentation and reassembly on unicast Ethernet faces
Change-Id: I81a065866610ec499a88b451bfaeea8ad40c17e2
Refs: #4011
2017-08-10 22:40:16 -04:00
Davide Pesavento 8ca138de13 ci: preserve PATH when running waf under sudo
Change-Id: Ideb6f9d4ec3d92af134b923b9abafc952ee868e6
Refs: #4186
2017-08-10 21:36:30 -04:00
Junxiao Shi a5765d647b core: delete NetworkInterfaceInfo class
nfd::NetworkInterfaceInfo has been replaced by
ndn::net::NetworkInterface.

refs #4021

Change-Id: Ic023b935f47f99f3bd74bbd4dc6c0e5bb2b3bf1c
2017-08-09 04:07:46 +00:00
Eric Newberry 2642cd250b mgmt: support LpReliability flag in faces/create and faces/update
refs #4003

Change-Id: Iddf94ea55c630b038187c2503783591b118230ec
2017-08-08 18:00:28 -07:00
Davide Pesavento b15276f90e tests: improve EthernetFactory test coverage
Also simplify other factories' GetChannels test case
by using checkChannelListEqual().

Change-Id: I02ecbd06fad498ea84b11d32b61ed4d63d929f2d
Refs: #4012
2017-08-08 20:32:22 -04:00
Davide Pesavento 6126547e53 face: EthernetFactory: skip non-Ethernet interfaces
Change-Id: Ifa42755b032cf23ea688e055477820d27e7dc8df
Refs: #4021
2017-08-08 15:48:10 -04:00
Davide Pesavento b8eebcb4aa face: EthernetTransport: use MTU provided by ndn::net::NetworkInterface
Change-Id: I949f054625ae6584d99505ea3fea2c4ab65b9cfb
Refs: #4021
2017-08-08 15:03:17 -04:00
Junxiao Shi 79a92089e7 face: use NetworkMonitor in EthernetFactory
EthernetFactory now creates unicast channels and multicast faces
on eligible netifs found by NetworkMonitor. However,
EthernetFactory does not yet react to fine-grained signals from
NetworkMonitor.

refs #4021

Change-Id: I58aac67d5a1b00d3cda76e78627b887f93ffa541
2017-08-08 02:40:59 +00:00
Nick Gordon 27b3854eb7 docs: write contributing guide and code of conduct
refs: #3898
Change-Id: Ife8936030527dba9020f0b298793c1121ae1fd6c
2017-08-07 12:37:05 -07:00
Junxiao Shi bbace1de47 face: use NetworkMonitor in UdpFactory
UdpFactory now creates multicast UDP faces on eligible netifs
found by NetworkMonitor. However, UdpFactory currently does not
react to fine-grained signals from NetworkMonitor.

refs #4021

Change-Id: I7802acb6f3aaa19db8f3c3141bbcdfc338e34eba
2017-08-06 20:03:37 +00:00
Junxiao Shi 4e1b6eee32 tests: avoid misaligned memory access in CS test
refs #4191

Change-Id: Idbc59c7d64805f6af239d66635821647956daf6d
2017-08-03 02:20:50 +00:00
Junxiao Shi 849e12a068 docs: corrections in Getting Started page
* Replace nfdc command lines with new syntax
* Remove mentioning of deprecated 'ndnd' and 'ndnd-tlv'
* Remove 'start nrd' step which has been removed
* Remove mentioning of ndn-cxx 'ndncatchunks3' and
  'ndnputchunks3' which have been moved into ndn-tools

refs #4194, #3570, #3700

Change-Id: Ie52c727400f7a1b4b076b3a94e48c72724139713
2017-08-02 00:14:57 +00:00
Ashlesh Gawande 90015991bc fw: per upstream retx exponential suppression for multicast strategy
refs: #4066

Change-Id: Ic1047b871dc9dc040e95ac5edceaae9994cd2849
2017-07-31 12:06:56 -05:00
Junxiao Shi bb6146ef74 tests: use ndn::util::Sha256 instead of ndn::crypto
refs #3940

Change-Id: I87c9cbfa9ae3592a053dd7eb0cb09d857668d111
2017-07-26 23:07:52 +00:00
Junxiao Shi 6028619f71 face: remove prohibited endpoint set
Prior to this commit, TcpFactory and UdpFactory each had a "prohibited
endpoint set" which prevents creating a face that connects to NFD
itself. This feature is no longer necessary after Nack-Duplicate has
been introduced, and is now removed.

refs #4189

Change-Id: I3b80ddc76ca1afb83b6f62061ccdbb69200e1841
2017-07-26 01:07:48 +00:00
Junxiao Shi fc2e13d58d fw: replace Link with forwarding hint
Forwarding now processes forwarding hint on Interests,
and no longer considers the Link object.

refs #4055

Change-Id: I0331687ee8ec31afa2f1a105e903670689647c4d
2017-07-25 02:08:48 +00:00
Eric Newberry 944f38bb49 face: move face parameters into CreateFaceParams struct
refs #4003

Change-Id: I6e1149e7075eb055912fd452a21b22fcb610829a
2017-07-23 20:37:06 -04:00
Junxiao Shi b347b7f189 tools: switch to v2::Validator in nfdc
"nfdid" field in 'nfdc status show' command is temporarily unavailable
because NfdIdCollector relies on v1 Validator. It will be re-implemented
in a future commit.

refs #4089

Change-Id: I21feae43055a17438d8bd3c0439ae4e0a2d5d14c
2017-07-23 14:01:58 +00:00
Davide Pesavento 6837d4f732 tests: cleanup FaceManager test cases
Change-Id: I1fd379fc1e01de331523260bd98ba96d6a7de88e
Refs: #3903
2017-07-18 00:47:11 -04:00
Junxiao Shi 0ba6d64e5a face: pass addFace and NetworkMonitor to ProtocolFactory constructor
refs #4021

Change-Id: I842515eb044bb1c655b347e6069e63c55c4e2d54
2017-07-17 00:53:22 +00:00
Junxiao Shi 2d49175d6e face: give ProtocolFactory access to NetworkMonitor
Subclasses of ProtocolFactory can access NetworkMonitor and
addFace callback anytime via member fields. They are supplied
to ProtocolFactory::create from FaceSystem.

This is in preparation for letting ProtocolFactory subclasses
react to fine-grained signals from NetworkMonitor.

refs #4021

Change-Id: I8da116bffc83d1bdeed7fd3b2e12c8872f19177b
2017-07-14 21:32:05 +00:00
Junxiao Shi 84d62cbbc6 face: use NetworkMonitor::listNetworkInterfaces() in tests
refs #4021

Change-Id: I6daccc3872a0c6b2e2e49390bc5881c796503926
2017-07-12 16:15:18 +00:00
Eric Newberry 7b0071e6a9 face: Acks acknowledge TxSequence instead of Sequence
refs #3931

Change-Id: I83919fe815c2a43e47eb09d754f77166c051d013
2017-07-09 07:31:51 -07:00
Junxiao Shi a5a3a87ae0 tools: simplify autoconfig MulticastDiscovery stage
refs #4158

Change-Id: Ib44804a0ac97b59d567fe8c0493c7d9ec4915137
2017-07-08 12:42:11 +00:00
Junxiao Shi cb76686ecc tools: refactor ndn-autoconfig
Hub face creation and prefix registrations are moved into a new
Procedure class. Main function is simplified.

refs #4158

Change-Id: I15b660e3b8a1bde89498a1cb549a87788de46c7a
2017-07-07 22:21:04 +00:00
Junxiao Shi 0d82d0459c face: construct EthernetTransport with NetworkInterface
EthernetTransport and EthernetChannel constructors now accept
ndn::net::NetworkInterface instead of NetworkInterfaceInfo,
in preparation for the transition to NetworkMonitor.

refs #4021

Change-Id: I1687a13dfaafde4ab3795a6f8c76c728c12929b9
2017-07-07 06:15:27 +00:00
Junxiao Shi 2760adcb80 core: NetworkInterfacePredicate accepts ndn::net::NetworkInterface
refs #4021

Change-Id: I6612a67db03b6651e8fbccad91f776ae502283d9
2017-07-06 05:44:52 +00:00
Junxiao Shi f748a4e9e2 tools: rename autoconfig Base to Stage
Also, turn BaseDns into non-member functions.

refs #4158

Change-Id: Id3ab862497a07cc261ed34b2ab116f4014a4c6fa
2017-07-05 23:41:48 +00:00
Davide Pesavento 84c65c0546 docs: update doxygen configuration
Most notably:
 - use relative paths in file list instead of file name only
 - enable sorting of brief descriptions of class members
 - show one enum value per line

refs #4163

Change-Id: Ib08601bc90f6eeb4e8754ed4335a447d5d0cc26c
2017-07-05 18:40:34 +00:00
Davide Pesavento 9ac95d3c1c ci: expand Travis-CI build matrix and use two parallel build jobs
Change-Id: I7dbba5bcd63274daa9b0da2ee9d631a55c1eca9e
2017-07-05 00:10:25 -04:00
Davide Pesavento 68ab43d8b7 face: don't set TransportState to FAILED if connection is closed cleanly
Change-Id: I0989cdf49558574f30b55a172d467b39683f9bb6
Refs: #4099
2017-07-05 00:07:12 -04:00
Davide Pesavento 0b0a71d801 face: rename hasBeenUsedRecently to hasRecentlyReceived
The word "used" is misleading, because the flag is set only when
packets are received, not for any other use of the transport.

Change-Id: I8a940d7887955c47cef085149629591b6e80c2a1
2017-07-05 00:06:54 -04:00
Davide Pesavento 1816d4b190 face: implement close-on-idle and persistency change for Ethernet unicast
Change-Id: I255024990a72b8cea5a44fa89f515ad91aadba66
Refs: #4011
2017-07-05 00:06:39 -04:00
Junxiao Shi 3b0815486e tools: modularize ndn-autoconfig-server
refs #4158

Change-Id: I90eb570e2ca2ae611d48aeb1e456712c1d148531
2017-07-04 18:37:34 +00:00
Junxiao Shi dbb6b3e119 mgmt: use v2 ValidationPolicy in CommandAuthenticator
refs #4089

Change-Id: I9a1cc77a960abe1e58a744f9d065634ab7597d15
2017-07-03 12:42:07 +00:00
Junxiao Shi 8a1f170ea6 tests: sign command Interests with CommandInterestSigner
Previously used ndn::v2::KeyChain::sign creates signed Interests, not
command Interests.

refs #4089

Change-Id: I7b13926d676ff81041f036eaec1978d82e8e1dfd
2017-07-03 00:05:08 +00:00
Junxiao Shi 83be1dae4b use FaceUri and NetworkMonitor from ndn-cxx/net
This commit also contains a quick fix in LpReliability to avoid
ndn::lp::Packet::wireEncode(EncodingEstimator&).

refs #3940, #4156

Change-Id: Ice8e3649be21dd023ed1f6562c185f9e6721e45e
2017-06-30 13:37:37 +00:00
Junxiao Shi 08e96316be tools: simplify nfd-autoreg with range-based for
refs #4158

Change-Id: Ibe83df03a1618b987608d539173ad32f03aafc42
2017-06-29 18:07:27 +00:00
Davide Pesavento 8eb5f8f3ed build: sync default-compiler-flags.py with ndn-cxx
- explicitly require clang >= 3.4
 - move -Og to basic debug flags (supported by clang since 4.0)
 - use gold linker and enable linker optimizations

Change-Id: Ife0b645a94abfe86230bac179779fde6b529f075
2017-06-24 02:24:42 -04:00
Davide Pesavento 46afec48ec face: unicast support in EthernetFactory
Change-Id: I1886a87d79a7194b3320a5417404b17a7290fa5d
Refs: #4012
2017-06-22 14:11:29 -04:00
Davide Pesavento 43ff2a9254 face: EthernetChannel
Change-Id: I8d9be571a2b0abe0cfad09756ea6c691e0679450
Refs: #4011
2017-06-22 14:11:08 -04:00
Davide Pesavento 7744a4a298 ci: speed up Travis-CI osx jobs by upgrading only the packages we need
Change-Id: I8bb4ddb5dbb335bf4f9ea925fe87bd7739adcb9d
2017-06-20 21:29:56 -04:00
Yanbiao Li f32ca897c5 rib: make log messages of AutoPrefixPropagator more accurate
Change-Id: Ieadfb95cd97b6f4ad0397d927ab31b21da3aa431
ref: #3774
2017-06-13 11:56:08 -07:00
Davide Pesavento 221f53bb6f ci: filter websocketpp files from lcov output
Change-Id: Ibd1ce39b0bf936e280e0277eaabf98cc68a5d656
2017-06-04 19:32:53 -04:00
Eric Newberry 9f3973e7b7 tests: increase timeout in Face/TestWebSocketChannel/MultipleAccepts
prevents test case failure on Ubuntu 17.04

refs #4002

Change-Id: I379499eaa90f12137b8c31b4a4fbe16392780a7d
2017-05-31 17:13:45 -07:00
Eric Newberry 7d8695d9e7 tests: check for new FaceUri canonization result string syntax
refs #4095

Change-Id: I068d140f50375541dee159b675b2ecfe69eb56a8
2017-05-30 23:28:47 +00:00
Junxiao Shi 3f21e58a58 rib: simplify Route class
Route::expires is changed to an optional, with nullopt representing
"never expires". This avoids an integer overflow.

RouteFlags accessors are now provided by ndn::nfd::RouteFlagsTraits.

Stream insertion operator is improved.

refs #3502

Change-Id: Ia912eab771fb00020385bf84d486955feae6aafa
2017-05-29 15:26:32 +00:00
Junxiao Shi 6eb0271fae face: decode CachePolicy without requiring allowLocalFields
refs #3966

Change-Id: I9a0f3c72682a6bc66f8852f115789a450a168223
2017-05-27 22:48:02 +00:00
Junxiao Shi 33a24e8e8f ci: fix ndn-cxx-latest version detection
refs #3321

Change-Id: I25ff57b634772fae324459751d6a7375346012ff
2017-05-27 17:09:31 +00:00
Junxiao Shi 16a3adfafc switch to ndn-cxx KeyChain v2
refs #4089

Change-Id: I32bc19db156de49275b681ef67f684b76631d50b
2017-05-26 17:38:51 +00:00
Eric Newberry f4056d0242 cs+fw: omitted FreshnessPeriod implies always stale
refs #3944

Change-Id: I018242b3ba5850e8a126f956af4150b512406efd
2017-05-26 17:31:53 +00:00
Qi Zhao 9ae8857bce tools: fix the inconsistent logging among ndn-autoconfig stages
refs #4079

Change-Id: Ie1edd8d30dbe7a9f5bf7b3364a07e71910cd91eb
2017-05-23 16:19:31 -07:00
Davide Pesavento a94f3676c3 face: MulticastEthernetTransport: remove promiscuous mode fallback
Change-Id: I040704577e66951ab5d1298ac4f99d98af11f809
Refs: #4081
2017-05-18 19:52:55 -04:00
Davide Pesavento fe0580cb55 face: introduce PcapHelper class
Change-Id: I26f7d43394e1b17f314c226ca6bce723c2410ae3
Refs: #4011
2017-05-18 18:17:54 -04:00
Ashlesh Gawande 6f6ef012cb ci: check boost version change on OSX
refs #3321

Change-Id: Iedccc7588ecaa95b34e6592aa0fa4f8a593233fd
2017-05-11 16:07:15 -05:00
Junxiao Shi 5c1bb36ae9 tests: include Flags in mocked faces/create response
refs #3956

Change-Id: I2e9af94bbb525739a31623da71325178191297d3
2017-05-11 16:03:38 +00:00
Davide Pesavento 8d61c037a7 ci: add generation of HTML coverage report using lcov
Copied from ndn-cxx

Change-Id: Ie8c08a570afe67c9eb232b37ad0038566ad49572
2017-05-03 01:14:32 -04:00
Junxiao Shi 1cce2a3014 mgmt: enable LocalUri in faces/create command response
Display LocalUri in 'nfdc face create' output.

refs #3956

Change-Id: I3c9ce266f218547bd6ba9509437178d271f680f7
2017-05-02 02:39:55 +00:00
Eric Newberry 73bcad33b9 core: make SizeCounter use pointer instead of reference
Restore virtual inheritance of GenericLinkServiceCounters in
GenericLinkService

refs #3941

Change-Id: I368e4694fee7bc97173fddfc81d0c679da0d6eed
2017-04-27 18:53:34 -07:00
Davide Pesavento 22db53973d rib+tools: use ndn::nfd::RouteOrigin instead of uint64_t
Change-Id: Ic8cbe95491a41e1d34b66d406da8637aeb5fd9e3
Refs: #3903
2017-04-14 20:48:20 -04:00
Junxiao Shi 38c7d9e6d7 tests: add bad FaceUri tests in FaceManager/CreateFace
refs #3377

Change-Id: I8be096c9bd25a80f063113f3d04f544ed184cc7d
2017-04-13 14:22:50 +00:00
Junxiao Shi 8eda682a18 tools: nfdc route commands accept and print RouteOrigin strings
refs #3987

Change-Id: I47594546e3fe9279fff5ea6ade9ce38cb3b05b6c
2017-04-12 02:53:14 +00:00
Davide Pesavento a3c9ddb21c face: allow the creation of permanent TCP faces
Change-Id: I516c176b000a78012f2ef7bd7f1f3e74c1758a94
Refs: #3167
2017-04-11 02:46:47 -04:00
Davide Pesavento acca18ae12 face: use std::array in UdpChannel
Change-Id: I9dc209ef471601f73ae85a36a317d7abf7c1849d
2017-04-09 13:23:16 -04:00
Davide Pesavento 77911ccc73 face: make logging more uniform across channel types
Change-Id: I21db45f736e07464260dcc902c673d098ba3c549
Refs: #2561
2017-04-09 13:11:16 -04:00
Davide Pesavento c19408ddf2 face: move isListening()/size() to Channel as pure virtual methods
As a side effect, this ensures that Channel cannot be instantiated.

Change-Id: I875876ddf8fc0fbb04f3e88726c708ece8106702
2017-04-09 02:57:19 -04:00
Davide Pesavento e5eebad6d2 face: remove nfd::ProtocolFactory type alias
Change-Id: Iac0af82a5301245e621a39f3bfc98aaed8dbaa45
2017-04-06 20:39:41 -04:00
Davide Pesavento 8fd15e628a face: move Channel and subclasses into nfd::face namespace
Change-Id: I163ef20e11b65d19d68585ec075fd3cd224a573b
2017-04-06 20:39:05 -04:00
Junxiao Shi b283f52c78 tools: nfdc strategy set/unset commands
nfdc set-strategy and nfdc unset-strategy are deprecated.

refs #3865

Change-Id: I934cbfcd567ac7ee33381ae4baf00b668977a0aa
2017-04-06 20:46:15 +00:00
Junxiao Shi f03d4796d7 mgmt+tools: rename 'datas' to 'data'
Plural form of 'data' is 'data'.

refs #3955

Change-Id: I62f5ebe53b8e36d565e5a243288eb12ae9a08014
2017-04-06 16:41:22 +00:00
Qi Zhao 6fc57a69fa tools: ndn-autoconfig continue proceeding with existing face
refs #4008

Change-Id: Ic264d1e3ba31cf0a743d6f190272e67f9c28e595
2017-04-05 16:53:10 +00:00
Junxiao Shi 5d3e481956 tools: nfdc strategy list/show commands
refs #3865

Change-Id: I6cc115b3c3f3d0840814a329c68356bbe6ad2e3f
2017-04-05 16:52:59 +00:00
Teng Liang f995f382ec fw: forward Interest/Data to ad hoc incoming face
Change-Id: Ia2eacf2a54d65ea4bffb607a709e1d1263547fd7
Refs: #3968
2017-04-04 22:09:39 +00:00
Ashlesh Gawande cad76b6242 fw: ASF should check if FaceInfo exists before using it
refs: #3968

Change-Id: I4c20a51609dd714e6104b103a4bef63ac8761083
2017-04-04 16:14:57 -05:00
Junxiao Shi 0d97692b40 tools: nfdc face create command accepts local FaceUri
refs #4017

Change-Id: I2d13403f13c30146c53744828ba2a37a6fab7de2
2017-04-01 14:35:21 +00:00
Eric Newberry 78e32b0ee2 face+mgmt: accept LocalUri in ProtocolFactory and FaceManager
refs #4016

Change-Id: I3e192e6d3982ae8e6ced1dbfbaa62f1c993f799e
2017-04-01 14:34:44 +00:00
Davide Pesavento 6bd6d0b50a face: UnicastEthernetTransport
Change-Id: I4d19f52835d9268f2ea63fd4e0b1a0a5aed95c47
Refs: #4011
2017-03-30 18:25:57 -04:00
Teng Liang bfea575095 face: configuration option to make Ethernet face "ad hoc"
Change-Id: I55aeb2ca38ec34365b2d5d951b9ca2d7b05f46b2
Refs: #4018, #3967
2017-03-29 04:51:10 +00:00
Teng Liang fe4fce3a3f face: configuration option to make UDP multicast face "ad hoc"
Change-Id: Ifd407f42e9646826697f73ab1890c819fce16857
Refs: #4018, #3967
2017-03-29 04:49:38 +00:00
Eric Newberry 185ab29325 face: add best-effort link-layer reliability
refs #3931

Change-Id: I009fabe000f4dd4ceb62acab6b0c735c13112430
2017-03-28 06:45:39 +00:00
susmit 21f22e692f core: enable wildcard matching on interface names for whitelist/blacklist
Change-Id: Iabf5084028d7e8c4a26ec5289c331f4a779c0bf7
Refs: #4009
2017-03-26 18:35:04 -04:00
Junxiao Shi da89fa5a9f fw: silence unused variable warning in FaceTable
Change-Id: I32136aabbac6c25f3b1e4ea17e2eeaddafd5c8c0
2017-03-22 21:34:56 +00:00
Davide Pesavento d2ea2350ad tests: no need to wrap ndn::nfd::RibEntry anymore
ndn-cxx provides the required operators now.

This commit also contains minor cleanups to RibManager test suite.

Change-Id: I2c7e4b5978319d654b69346935de37088bd6e877
Refs: #3903
2017-03-18 12:39:18 -04:00
Teng Liang 4f5cdcf421 fw: avoid breaking logic after LINK_TYPE_AD_HOC is introduced
Change-Id: I4f17a3a92c6ec44f1cb3ee619600c07e2ec39a16
Refs: #3967
2017-03-16 15:54:03 -07:00
Davide Pesavento d396b61ba1 rib: a few cleanups and simplifications in RibManager
Change-Id: I77699525ab372c4f4f3bbcae74e65bec24a86b4c
Refs: #3903
2017-03-12 19:53:54 -04:00
Davide Pesavento 1586aff97b mgmt+tests: no need to wrap ndn::nfd::FibEntry anymore
ndn-cxx provides the required operators now.

Change-Id: I7d7f371b89f8231853cb75682066ac09a858916d
Refs: #3903
2017-03-12 19:53:35 -04:00
Nick Gordon 9fcf123b19 rib: Enable Readvertise-to-NLSR
Change-Id: If50ffe740e8137ca2aeed67be219f6487153af9f
refs: #3818
2017-03-10 22:30:20 +00:00
Alexander Afanasyev 635bf20ef5 Remove use of deprecated code
Notably, faces/enable-local-control and faces/disable-local-control
management commands are removed in this commit.

Change-Id: I9ba45c9697eca418315c1c749a3c0c602a36f34e
Refs: #3988
2017-03-09 21:57:34 +00:00
Junxiao Shi f6af4f8913 tools: deprecate nfdc register/unregister/add-nexthop/remove-nexthop
They are replaced by 'nfdc route add' and 'nfdc route remove'.

refs #3866

Change-Id: I8040bf39ce9bd4b68409896c355beb12b0da5692
2017-03-09 16:20:14 +00:00
Junxiao Shi 1d62e62bc0 tools: nfdc route list and nfd route show commands
refs #3866

Change-Id: Ic8feab0ce9e5707c1cf382cdea7264e28e3edb30
2017-03-08 22:39:28 +00:00
Junxiao Shi 89c0ea0621 rib: introduce Readvertise
refs #3818

Change-Id: I4635fecfcb8be5d9bb3086dea3bf7bbd90538832
2017-03-06 19:52:05 +00:00
Nick Gordon 2fb3e8e3fe rib: introduce ReadvertisePolicy
refs #3818

Change-Id: Id40a7dfeeb1c46d6bff0750b15f3288a10897288
2017-03-06 19:50:59 +00:00
Junxiao Shi 63b67e2b23 rib: simplify ReadvertisedRoute
refs #3818

Change-Id: Ied644d825458f387b6f886bfcd425cffd2c2c7aa
2017-03-06 19:46:02 +00:00
Junxiao Shi 1a25a6edd0 tests: MockNfdMgmtFixture requires specific command Interest
MockNfdMgmtFixture previously allows a test case to respond to
the "last" command Interest, which causes difficulty when the
management client sends multiple command Interests together. It
now requires a specific command Interest for sending a response.

refs #3866

Change-Id: I80eeed2cdced618725a73f21bfaa387d831ca11a
2017-03-06 03:09:47 +00:00
Junxiao Shi 2fe3af0577 fw: duplicate Nonce from same face is not loop
refs #3888

Change-Id: I973f58281dca32b5f807d7be82a49d04314cbfb1
2017-03-04 17:24:19 +00:00
Ashlesh Gawande ecdbe5f2a6 fw: consumer retansmission in multicast startegy
refs: #2062

Change-Id: I2b58a289fffe262c69a797f339e40ad9037acf8f
2017-03-04 03:08:24 +00:00
Ashlesh Gawande f7bf4093be tools: fix compilation error due to ndn-cxx RouteFlags change
refs #3903

Change-Id: I799291d51d2b96ea1f7f8d07d000ae2c12300cf1
2017-03-04 03:06:26 +00:00
Junxiao Shi 084b79553f tools: nfdc route remove command
refs #3866

Change-Id: Iffbcf3face8758a52d35a854408f9910f4ba6c0b
2017-02-26 22:00:53 +00:00
Ashlesh Gawande e38e261ae6 fw: Nack in multicast strategy
refs: #3176

Change-Id: I1ef43c277a6a251170b652bf77d5516912a5d630
2017-02-25 07:23:41 +00:00
Junxiao Shi 918e5d451e tools: nfdc route add command
This commit also simplifies 'nfdc face destroy' and its test case.

'nfdc register' is deprecated in favor of 'nfdc route add'.

refs #3866

Change-Id: I1de5cc0bc956d57b0793da920c1e87b3580a3297
2017-02-25 03:58:21 +00:00
Davide Pesavento 7a294d49ab tests+tools: add missing includes
Change-Id: I29d9d265cb72c43edc4dbfd44261da823090bc10
2017-02-21 21:46:44 -05:00
Junxiao Shi d695801754 tools: deprecate nfdc create and nfdc destroy
They are deprecated in favor of nfdc face create and nfdc face destroy.

There is also a minor correction to nfdc-face man page.

refs #3864

Change-Id: I038bc604304ac5650101ee2afe30753e59061632
2017-02-20 03:34:48 +00:00
Davide Pesavento 26cbdbd904 tools: follow API change in ndn::nfd::Route
Change-Id: I67b770b4083afbea1fcf59fdcd183e971b1f6a6d
Refs: #3903
2017-02-19 21:48:21 -05:00
Davide Pesavento 6fd1e7e5ef fw: in FaceTable::add(), move the shared_ptr instead of copying it
Change-Id: Iddbdc35452f9512a75850b7a9cd3734d4cf89326
2017-02-17 18:45:27 +00:00
Junxiao Shi 36e5429622 tools: nfdc face list command with filters
refs #3864

Change-Id: Ie22e506bb2aeae8abf7c94b394e7aa56c840266f
2017-02-17 18:43:16 +00:00
Yanbiao Li 58ba3f9429 mgmt+tools: rework FacePersistency handling in faces/create and faces/update
1. enable changing persistency in faces/update command
2. reject faces/create request if the face already exists
3. nfdc changes to support the above

Change-Id: I659906da846608a42a768f08fb110ceee1a947a7
refs: #3232
2017-02-17 20:05:06 +08:00
Junxiao Shi 970f648843 tools: nfdc face create output fix
NFD faces/create command response does not contain a Uri field,
so nfdc face create output should not try to obtain canonical
remote FaceUri from the command response.

refs #3864

Change-Id: Idae4552e0e197257ea1277e12e20fe565a8562c6
2017-02-10 20:50:14 +00:00
Junxiao Shi 8f803f292e tools: use FindFace in nfdc face show command
This commit also uses FaceQueryFilter operator== in test cases.

refs #3864

Change-Id: I5096ab07ce02535364c5ac8f9e0f0ad27e55b96e
2017-02-10 03:04:28 +00:00
Junxiao Shi 05dd4441b0 tools: nfdc face destroy command
refs #3864

Change-Id: I1d070570c14364529c566273eba44b87413942b1
2017-02-06 22:50:07 +00:00
Junxiao Shi 1fbdb54f85 tests: improve Table/TestCs test suite
Adding MustBeFresh test case.
Updating DigestOrder test case.

refs #2411

Change-Id: Iae38e62e460251f3c74b67d0fcafae6007d8ddc5
2017-02-03 00:05:53 +00:00
Junxiao Shi f9858fdd1a fw: strip Link object when Interest reaches producer region
refs #3893

Change-Id: I7cb0a58f75eb4275bbf0fe0c7dcdb583c8519644
2017-02-02 06:07:52 +00:00
Junxiao Shi fab9e0de46 tests: forwarding with Link objects test suite
Fw/TestLinkForwarding is an end-to-end test suite that verifies
the proper forwarding rules for Interest with Link objects.
It replaces Fw/TestStrategy/LookupFib test suite.

refs #3893

Change-Id: I6dd3fe7988f8be6d55dd5dc589f7953c4d18f2ee
2017-02-02 06:04:59 +00:00
Junxiao Shi 1d7fef5810 tools: nfdc face create command
refs #3864

Change-Id: Icca589eceae0b78f68cda61e761dd4721ce54f9c
2017-02-02 05:33:14 +00:00
Junxiao Shi f0dfb33292 docs: write arguments as upper case in manpages
refs #3780, #3864

Change-Id: Iff0534dbd0119734fdb567500fe2e1842c7805f5
2017-02-02 05:32:25 +00:00
Nick Gordon 04262d9c84 rib: ReadvertiseDestination availability
refs: #3818

Change-Id: Ifc2875ba38025595f3d6a8f8207f5ec126f93c90
2017-02-01 12:14:21 -06:00
Junxiao Shi 056815ea8b tools: fix nfdc::text::ItemAttributes evaluation order bug
When multiple ItemAttributes::operator() invocations appear on the same
expression, they are not always evaluated left-to-right, causing incorrect
text output.

refs #3864

Change-Id: I4c99c5bc4a76b4becf83f368c9f253c0b254fc05
2017-01-29 16:39:19 +00:00
Junxiao Shi 215fd0b6d9 tools: import FacePersistency and FaceUri to nfdc namespace
refs #3864

Change-Id: I999fa2419f4d23368d924b536aee6f225017b570
2017-01-28 19:01:04 +00:00
Junxiao Shi 9954007722 fw: abstract Nack processing out of BestRouteStrategy2
refs #3176

Change-Id: Ib220269ff52acc47c65f854a610941afd862ad41
2017-01-27 19:57:33 +00:00
Junxiao Shi ea47bde02e mgmt: FaceManager no longer owns FaceSystem
refs #3904

Change-Id: I2ef6fd36a51493eea27d8eb0e1c7dc022766f948
2017-01-26 17:49:16 +00:00
Junxiao Shi c344304026 face: make ProtocolFactory::processConfig pure virtual
refs #3904

Change-Id: I1f2cb0a85b75f9adbabd4c9e5afb7d81567cfbd7
2017-01-26 17:21:35 +00:00
Junxiao Shi 1f481fa1a3 tools: nfdc face show command
refs #3864

Change-Id: Ibee7b082681edc35e8c272b2363436dbc7eaf9c0
2017-01-26 15:14:43 +00:00
Junxiao Shi 88a062de78 tools: add exit code and streams to nfdc::ExecuteContext
Moving exit code to the context allows error handling routines to
rely only on the context.

Moving stdout and stderr streams to the context allows mocking in
unit tests, and allows sending output to a buffer for pre-processing
when we implement interactive mode.

refs #3864

Change-Id: Ibf59c12405d0eaca0597835cb2e30125b7f70adb
2017-01-26 03:10:05 +00:00
Alexander Afanasyev 19e2e6d858 docs+build: Prepare release 0.5.1
Change-Id: If6c2cf06d604c6541bedec6cf87731f1f593eae4
Refs: #3859
2017-01-25 16:16:33 -05:00
Junxiao Shi c31080d470 mgmt: Create UDP multicast faces according to whitelist/blacklist
refs #1712

Change-Id: Ia957bb1a3a3a0108d06716bfb25ecd29c6952d62
2017-01-25 14:17:55 -05:00
Junxiao Shi b47247dad9 face: ProtocolFactory registry
refs #3904

Change-Id: Ic7c8b3d6138b7c27d4189a2e15cc646055ad1294
2017-01-25 14:17:45 -05:00
Davide Pesavento 8a84773fdb ci: preserve environment when running tests as superuser
Change-Id: I18c59d6411169c4bf0742fd0c581c9c1f747806b
2017-01-25 09:29:49 -05:00
Junxiao Shi 55e21b9e17 table: clear StrategyInfo only if Strategy type differs
refs #3868

Change-Id: I164ccba3bd6c69cef9d2ebba303f8d8d941aac99
2017-01-25 09:29:02 -05:00
Junxiao Shi 7d30d8556a tests: rewrite StrategyChoiceManager test suite
refs #3868

Change-Id: I3ff124bcbf8a8a0b2badfc9adedbbaa09f91e72f
2017-01-22 03:29:26 +00:00
Junxiao Shi 64d99f21eb face: process face_system.udp config section in UdpFactory
refs #3904

Change-Id: I8edf69c152f7c164cbab2b482d6b138cbf89d3e2
2017-01-21 23:06:36 +00:00
Junxiao Shi 1b65ca1900 tests: delete BOOST_CHECK_NO_THROW in ProtocolFactory test suites
This makes exception message appear in testing logs, which
simplifies debugging.

refs #3904

Change-Id: I7d1a36c1c66d885a03e6a6d283e2907364f7f31a
2017-01-21 23:04:41 +00:00
Junxiao Shi 3409cd399d face: process face_system.websocket config section in WebSocketFactory
refs #3904

Change-Id: I8e30a54ab0664432cebf5d74e0467e9bfba60f2f
2017-01-18 15:31:27 +00:00
Davide Pesavento 3206565bac face: revert unintended behavior change in Transport::setPersistency
Prior to commit 32dab97321, persistency
transitions from NONE were not logged and before/afterChangePersistency
was not called. Restore that behavior.

This commit also improves test coverage of the persistency-related
functions in the various Transport subclasses.

Change-Id: Ide77c67ea277fca3d1cad5ea131ae0fa259db75c
Refs: #3232
2017-01-15 15:04:19 -05:00
Yanbiao Li 32dab97321 face: Transport::canChangePersistencyTo
Feasibility of transport persistency change can be checked with
Transport::canChangePersistencyTo before executing the actual change.
This enables management to verify persistency and other parameters
in a faces/update command before applying the updates.

Change-Id: Ia283f0daf678f47aad7b78b7e06dee4827f57cab
refs: #3232
2017-01-13 14:30:01 +08:00
Junxiao Shi 7003c609b8 face: process face_system.ether config section in EthernetFactory
This commit also fixes a potential memory access error in EthernetTransport.

refs #3904

Change-Id: I08296e7c6f1039b59b2859d277fc95326af34f52
2017-01-10 13:35:28 +00:00
Alexander Afanasyev 16320cd28b ci: Fix macOS build with Travis-CI
Change-Id: Iabdfd71c4ba8b3c35f6de117da3b42b61cb1dc4e
2017-01-06 04:22:46 +00:00
Junxiao Shi 406deb5971 face: process face_system.unix config section in UnixStreamFactory
refs #3904

Change-Id: I8f8772054ece2971758efd0599ef06fd3b778735
2017-01-05 20:07:44 +00:00
Junxiao Shi 38b24c7b94 face: process face_system.tcp config section in TcpFactory
refs #3904

Change-Id: I509f07e6835a96c7ba05137529f29da76a6514fd
2017-01-05 02:59:31 +00:00
Junxiao Shi 530cf00d68 table: StrategyChoice::insert return value includes error description
The error description is used in the response to a strategy-choice/set
management command failure.

refs #3868

Change-Id: I14e0eb4dc311806a90ebfe60fa17177d2809d104
2017-01-03 14:43:16 +00:00
Alexander Afanasyev 465056e9c6 ci: Fix bug with coverage report generation
Many files were missing from the report because the build path was
excluded.

Change-Id: Ia7ecdf4a81b8d37cff6c3fd14c5de3407648d91c
2016-12-30 16:19:46 -08:00
Junxiao Shi 91f6ee0c72 fw: instantiate strategy of next higher version
When an exact strategy version is unavailable, strategy registry now
instantiates the next higher version which can offer backwards compatibility.

All existing strategies do not support other versions.

refs #3868

Change-Id: Id2cf9ae3a1fa078ce8be815eea9396f5aa81ecbb
2016-12-29 21:44:44 +00:00
Junxiao Shi b859031855 face: FaceSystem class
FaceSystem class is the entry point of NFD's face system. It owns
ProtocolFactory objects that are created from face_system section of
NFD configuration file. This responsibility is split from FaceManager.

This commit also adds test coverage for face_system.websocket config
section processing routine.

refs #3904

Change-Id: If9a23c23b81f03d2b76c29febb3f29e6007d595b
2016-12-29 21:22:25 +00:00
Eric Newberry 81a9a86305 ci: speed up code-coverage jobs
some documentation updates

refs #3809

Change-Id: I0c837a3b8f0f5e5e15d20ba41418bf17660fffb5
2016-12-28 22:52:35 -07:00
Junxiao Shi 7f566dd0e5 table: StrategyChoice no longer supports installed instances
All strategies should be registered in the strategy registry.

refs #3868

Change-Id: Ie89b0ffaf9943e591f9f2d80546b013d5cc16ff8
2016-12-27 02:28:31 +00:00
Junxiao Shi 65800d22e7 mgmt: change strategy-choice/set response codes
If the specified strategy name cannot be instantiated,
respond with 404 status code.

refs #3868

Change-Id: I8275923f149ec9c2ed82e485e933d16320bd3a03
2016-12-25 21:05:45 +00:00
Junxiao Shi 4cb74319f9 fw: delete deprecated Strategy::getName in favor of getInstanceName
This commit also renames strategy_choice::Entry::getStrategyName
to getStrategyInstanceName.

refs #3868

Change-Id: I40301e744fc236918d6be1c1262eba952198e22f
2016-12-25 20:48:47 +00:00
Junxiao Shi 3aba7548f4 table: make FIB and StrategyChoice iterators default-constructible
They were previously not default-constructible when compiled with gcc 4.8.4.

refs #3882

Change-Id: I2431c869fb61b7adbe83d5551705981bf8618280
2016-12-24 02:42:52 +00:00
Junxiao Shi 593887c8d0 mgmt: use strategy registry in TablesConfigSection
refs #3868

Change-Id: I3500505f11d8dbfa37bb57c283bd4847ab0f11e5
2016-12-24 02:39:29 +00:00
Junxiao Shi 0e4a1f112d tests: register instead of install DummyStrategy
refs #3868

Change-Id: I5e44582625be51ef874e2a92e4bb7cc22d5b607b
2016-12-24 02:39:01 +00:00
Junxiao Shi 18739c4ac1 fw: pass parameters to Strategy subclass constructors
refs #3868

Change-Id: I1a09e7353c047d548065c4ed669d1f7993676428
2016-12-22 08:03:00 +00:00
Nick Gordon 947192570d rib: ReadvertiseDestination
refs: #3818

Change-Id: I453d69c4a100ede9065756fe16cb60c19aea33db
2016-12-19 11:58:31 -08:00
Alexander Afanasyev 2a00194316 tools: Add NDN-FCH stage (service to get "closest" NDN hub) to ndn-autoconfig
Change-Id: Ia2b0bf93d3d25b45713eeba58924e64871715bdb
Refs: #3800
2016-12-18 15:08:13 -08:00
Junxiao Shi 9137e9e2ae tools: nfd-status-http-server returns HTTP 504 when NFD is not running
504 Gateway Timeout is a better HTTP response code than 200 OK
in this situation.

refs #3863

Change-Id: Ib41e07a8a33c5408cb8fcb2fe85c9d0f1bd1ed6b
2016-12-15 21:31:50 +00:00
Junxiao Shi 890afe9d85 tests: add StrategyTester to strategy registry
refs #3868

Change-Id: Iaeb684b03726cf8c0aa9eb3ca8e52537f892fb1b
2016-12-15 14:34:34 +00:00
Junxiao Shi d0e276f66a tools: autoconfig MulticastDiscovery warns on Nack
refs #3704

Change-Id: Iff86770cf0bf7df7da08ef9b57101c645da0a301
2016-12-14 23:13:39 +00:00
Niv Sardi 5e8755c774 docs: Fix typos in manpages
Change-Id: I0231775c7d509c992e782144e7838dce793f7e5f
2016-12-14 09:27:24 -08:00
Junxiao Shi 037f4ab4b6 fw: move STRATEGY_NAME to getStrategyName static function
This avoids potential problems with static initialization order.

refs #3868

Change-Id: I13f0ff6c51c0a3bd43af7993233ff63a4bca9cf9
2016-12-13 04:27:06 +00:00
Junxiao Shi f15058ab06 table: don't share Strategy instance among StrategyChoice entries
For a Strategy type registered in the strategy registry,
a new instance is created for each StrategyChoice entry that uses it.

StrategyChoice::install is deprecated. An installed strategy instance
is still shared among StrategyChoice entries that use it. This will
be removed after unit tests switch to use the strategy registry.

refs #3868

Change-Id: Ibca685e6b6668f64fa1a503e3575867e8babdfe1
2016-12-11 20:15:05 +00:00
Junxiao Shi c34d167b91 fw: refactor Strategy registry
Strategy registry is moved into Strategy class.
Strategy instantiation logic is implemented in Strategy::create.
These are in preparation of supporting Strategy parameters.

refs #3868

Change-Id: If36a08ad25a00a7008a5eccc8cfe4f6c63638676
2016-12-09 15:57:59 +00:00
Junxiao Shi b4a5acd890 mgmt: tables.cs_policy config option
refs #3148

Change-Id: Icf30bbe508c1c491949d9fcb433fdfa16842d312
2016-12-07 19:59:18 +00:00
Junxiao Shi a88911105c tools: ndn-autoconfig MulticastDiscovery uses FaceQueryDataset
refs #2426

Change-Id: Ib9dcd77564d80b403199e9079d4753dadb96e350
2016-12-06 21:11:33 +00:00
Junxiao Shi 7ee00fb680 table: cs::Policy::getPolicyNames
refs #3148

Change-Id: I06f66e9780b9c5c4820ba18cca5fbc9b1061eae0
2016-12-04 21:23:00 +00:00
Junxiao Shi c29c0b01a7 fw: don't expose UnsolicitedDataPolicy::Registry
UnsolicitedDataPolicy::Registry was mistakenly made public when
implementing getPolicyNames.

refs #2181

Change-Id: Ib2e68360aef2e7d3695273f8ef2b6c0c67bd914a
2016-12-04 21:11:44 +00:00
Junxiao Shi 9db735958c fw: UnsolicitedDataPolicy::getPolicyNames
refs #2181

Change-Id: Ie2abcd7503d1079734e6386fbab37cadd186e07c
2016-12-01 23:43:11 +00:00
Junxiao Shi 57cda13f7b fw: delete deprecated Strategy::sendInterest overload and violatesScope
refs #1756, #3841

Change-Id: Idd5fb5692435c864a0a9b140992e615b280243a3
2016-12-01 23:43:01 +00:00
Ashlesh Gawande 2a73f35ce6 fw: localhop scope restriction in ASF strategy
refs: #3841, #1756

Change-Id: Ic82e7055ace9d3f8eca8f9bad94603692ff321d5
2016-12-01 17:27:02 -06:00
Weiwei Liu aaa58a6c10 rib: fix incorrect operator<< output
refs #3423

Change-Id: I22137a1ad2c3b64d74b7ba2fe6b5f7f55486c276
2016-11-29 23:48:28 -07:00
Junxiao Shi 52fa45c6ee tools: ndn-autoconfig code style corrections
refs #2426

Change-Id: Ied8de3b3f839e07090fc71f41cd01f4e5b4987f3
2016-11-29 21:18:13 +00:00
Junxiao Shi 934f5055ab tools: deprecate nfd-status command line options
nfd-status command line options are deprecated in favor of
nfdc subcommands such as 'nfdc face list' and 'nfdc status report xml'.

'nfd-status' without command line options is kept as an alias of
'nfdc status report' and is not deprecated.

refs #3780

Change-Id: Ib54b239062b4987295e22c7eb94b75c030f7308a
2016-11-28 17:13:35 -08:00
Davide Pesavento 26c82ca131 tests: no need to use a logger in TestVersion
refs #1575

Change-Id: I48aae470b579b7df669606e6d2bda3dff8de364f
2016-11-27 07:46:22 -08:00
Junxiao Shi 52555b06d4 table: CS policy registry
refs #3148

Change-Id: I058357839e514787405952569d1abf402375d1ea
2016-11-25 21:39:06 +00:00
Junxiao Shi e21b3f3dc4 fw: localhop scope restriction in best-route v1, multicast, ncc strategies
canForwardToLegacy function no longer checks scope. Strategies using this
function shall use wouldViolateScope separately.

refs #3841, #1756

Change-Id: Ib1bd3f9fe19e4cadfa27e86dcc730d16cfd4b0db
2016-11-24 14:13:46 +00:00
Eric Newberry ee400b5235 face: GenericLinkService encodes and decodes CongestionMark field
refs #3797

Change-Id: Ia6b00a36f3e7ed9ec98e41dee7e2f97eaf235ddd
2016-11-24 14:12:48 +00:00
Junxiao Shi e273333fba tools: nfd-status-http-server invokes nfdc
`nfdc status report xml` command is invoked instead of legacy `nfd-status`.

refs #3780

Change-Id: I30ee00b59c388186b030757c815c147f74d000d1
2016-11-24 14:11:40 +00:00
Eric Newberry 6d932e83d2 tools: display face flags in nfdc and nfd-status-http-server
refs #3733

Change-Id: Idd66ffb7594079d2738253d035792300fe3febef
2016-11-24 05:05:43 +00:00
Junxiao Shi ae889380da tools: nfdc status commands
refs #3780

Change-Id: I5222aacc0a7134978e9496c68a3b915dac4aee18
2016-11-23 04:52:51 +00:00
Junxiao Shi a7f9a29e74 fw: localhop scope restriction in AccessStrategy
AccessStrategy now properly invokes reject pending Interest action
when an Interest cannot be forwarded.

Fw/TestStrategyScopeControl test suite is introduced to test localhost and
localhop scope control in strategies.

refs #3841, #1756

Change-Id: I7ae0d9f07ad6673363045a8c0341dfb78e088672
2016-11-22 16:31:38 +00:00
Junxiao Shi a6350d9395 tests: DummyStrategy forwards specific Interest
refs #1756

Change-Id: I252364ef75f5a74e61828e35385c272b1a8b4581
2016-11-22 14:22:25 +00:00
Junxiao Shi 6c13562d23 tools: nfdc help command
refs #3780

Change-Id: Ibd0e37bad127a38e582864fadd81afadc74baf48
2016-11-21 14:30:33 +00:00
Junxiao Shi 00dc91423e fw: localhop scope restriction in BestRouteStrategy2
localhop scope rules are implemented as wouldViolateScope function;
the old violatesScope function is now deprecated.
Strategy::sendInterest overload without specific Interest packet is also
deprecated. BestRouteStrategy2 has switched to use the new overload.

refs #3841, #1756

Change-Id: Ic117f01926eadddf1da3ccb580b52a3903a70c89
2016-11-21 14:23:12 +00:00
Davide Pesavento ac767aad0f core: Network: fix uncaught bad_lexical_cast in isValidCidr()
Change-Id: Ibeac1bb5d637324e880f00a0ae0ff9e65506efd4
Refs: #3858
2016-11-20 02:35:06 +01:00
Davide Pesavento 89567d3b31 core: Network: misc code cleanups
Change-Id: Idc37b5f834220e8e980958953785806687435f36
Refs: #3858
2016-11-20 02:19:25 +01:00
Weiwei Liu dcdf6212cc face: support permanent persistency in TcpTransport
refs #3167

Change-Id: I217c5f0fe0dfbbd759861ee262920cc03394b0ed
2016-11-19 02:43:53 +01:00
Junxiao Shi c5f651f014 fw: allow strategies to pick outgoing Interest
This commit changes outgoing Interest pipeline and Strategy API,
to give strategies an opportunity to pick an outgoing Interest that
matches the Interest table entry.
No strategy is updated in this commit.

refs #1756

Change-Id: Iffad77ef0078c437070039fca6b24a85df13bda7
2016-11-17 22:58:12 +00:00
Junxiao Shi a274292b93 table: pit::Entry checks Interest matches entry when updating in/out-record
pit::Entry::canMatch is the single place to determine whether an Interest
matches an Interest table entry. This condition is asserted when an in/out-
record is inserted or updated. This prevents a strategy from incorrectly
picking an Interest that is incompatible with the Interest table entry.

refs #1756

Change-Id: Ibf61a0e2e32b7a0e04e581f01ef07b791c6010a2
2016-11-17 22:53:23 +00:00
Ashlesh Gawande d3ac777f7b fw: Check out record exists before calculating RTT in ASF
Change-Id: Ie7f2db50b21d314a5df998e4220f64de14861d3e
refs: #3829
2016-11-14 12:59:49 -06:00
Eric Newberry ecc45cbc7e rib: use faces/update instead of faces/enable-local-control to enable local fields
refs #3734

Change-Id: Ic7a39a9b3297103bbe36bf5955e52523b9f8baa4
2016-11-08 19:57:12 +00:00
Eric Newberry 1b4ba050cc mgmt: send FACE_EVENT_UP and FACE_EVENT_DOWN notifications
refs #3794

Change-Id: I98cc9db2652454d8fd09975b619433046e9bc7ca
2016-11-06 09:39:04 -07:00
Davide Pesavento 5f47aa6140 core: use C++11 <random> instead of Boost.Random
Change-Id: I8f22965b86c681581762a47995f29f888421a558
Refs: #3599
2016-11-04 17:56:14 +01:00
Nick Gordon 89c4cca866 rib: route addition and removal signals
refs: #3818

Change-Id: Ic47afeba4b4133a2092b26ecd49adbaac0505781
2016-11-03 13:51:49 -06:00
Eric Newberry 27bdd1a325 build: load sanitizers last in wscript to prevent Boost link failure
refs #3828

Change-Id: I582095027dd0330cdad76accd0e2ffe5382840b0
2016-11-01 18:28:31 -07:00
Eric Newberry 6db5ce1912 ci: set Travis CI Xcode version and update NODE_LABELS to 10.11
refs #3833

Change-Id: Ie6eea82b165390fbf88ab08766c25daa10c60370
2016-10-31 16:08:30 -07:00
susmit 91e1d7ce48 mgmt: create Ethernet multicast faces according to whitelist/blacklist
Refs: #1712

Change-Id: Iaabaeaf58e460c86ca58f9099b5c2b904a5a5c93
2016-10-26 20:45:02 -06:00
Davide Pesavento 97210d5b15 tests: respect naming conventions and improve nesting of some test suites
Change-Id: I65af858bc6d10197c6ee11111fa9f7c1faa617ef
Refs: #2497
2016-10-14 15:45:48 +02:00
Alexander Afanasyev 436f3bd9fe build: Do not fail the build in debug mode when using deprecated declarations
The original motivation of this change was to avoid compilation failure
in debug mode on macOS 10.12.

Change-Id: I15437050555646b2458989f3788fce4c1e354e48
Refs: #3795
2016-10-13 16:42:59 -07:00
Davide Pesavento 7de0444d06 ci: ensure XML test reports do not clobber the output of previous runs
This was broken since commit e0edc4c06d

Change-Id: I369e9ad2cb3345ef3a707799e86c3c3beaf83788
Refs: #3418, #3750
2016-10-13 14:41:20 +00:00
Weiwei Liu 7c7951391c tools: fetch face dataset with StatusDataset client in nfd-autoreg
refs #3659

Change-Id: I60b0947cbaf47d2e69cd3f3604ffc46f96ad91a1
2016-10-11 10:43:24 -07:00
Weiwei Liu 6e21cdb13f rib: fetch face dataset with StatusDataset client
refs #3620

Change-Id: Ibf1a0e064e105389d6b733b2d1f0791dff356208
2016-10-06 16:21:31 -07:00
Alexander Afanasyev 67019110d7 docs+build: Prepare for version 0.5.0 release
Change-Id: I0f7fbd26d6d3f22c1d14ff10b53c1276abe0aa0c
Refs: #3762
2016-10-04 16:51:28 -07:00
Davide Pesavento 9a00fabed7 tests: merge TcpChannel and UdpChannel test suites using test case templates
Change-Id: Id56bb036db53494d4d250f9ea68a3ded78b33ddb
Refs: #3514
2016-10-03 18:52:44 +02:00
Eric Newberry c05918c860 mgmt: add Flags field to faces/list and faces/query in FaceManager
refs #3732

Change-Id: I6532962831efa780d1737412a8dfb2125f296f16
2016-10-03 09:43:42 -07:00
Eric Newberry f40551a061 face+mgmt: enable local fields through ProtocolFactory::createFace
refs #3731

Change-Id: I569dae59cda150ffcb1c0ff1d01a575d8850beca
2016-09-23 01:16:23 -07:00
Junxiao Shi d8205106cc mgmt: ForwarderStatusManager answers only status/general
GeneralStatus dataset at /localhost/nfd/status prefix was deprecated
and is now removed.

refs #3379

Change-Id: I9ce8bba9b11823b6a1a159703cc9f8050656ab53
2016-09-22 18:08:45 +00:00
Davide Pesavento cffb4e5bce Add Travis CI badge to README
Change-Id: I352dbee34ba17d6526eb305add548e0eb3b953f5
2016-09-20 15:54:06 +02:00
Davide Pesavento 3495b8009c face: fix TestWebSocketTransport/StaticPropertiesNonLocalIpv4 on Travis CI
Don't assume that the local address of the client is the same as the remote
address seen by the server. The client may be behind a NAT, for example.

Change-Id: I2de084830c364e28c49de8fdbce60b46f76727ad
Refs: #3676
2016-09-20 15:53:31 +02:00
Junxiao Shi c143afea10 tools: various improvements in nfdc
* use same underlying type for ParseMode and AvailableIn,
  to avoid potential errors when converting between them
* simplify AvailableIn stream output operator with text::Separator
* allow CommandParser::addCommand to accept bitwise OR'ed modes
* qualify nfdc logging sources with 'nfdc.' prefix

refs #3780

Change-Id: I2eee3d562184daf27305c2d5f2892637b63421c2
2016-09-20 13:04:51 +00:00
Junxiao Shi c69f9210d9 fw: deprecate ClientControlStrategy
It becomes unnecessary because NextHopFaceId is honored universally.

refs #3783

Change-Id: I4c0c48f10ae58aa2603998f195f43d54e81bfcf2
2016-09-19 21:21:03 +00:00
Davide Pesavento 043c50147c ci: enable AddressSanitizer for unit tests
Change-Id: Iaf4c24f7e6f79d2915bf8ef78cff398876091c73
Refs: #2589
2016-09-19 17:23:32 +00:00
Davide Pesavento e94804bd48 rib: fix use-after-free in Rib::erase and RibManagerFixture::clearRib
Change-Id: Ia4c2211f6c48d852e3b73dc84e298d26ad14f708
Refs: #3787
2016-09-19 17:23:21 +00:00
Junxiao Shi e342e8de70 fw: honor NextHopFaceId universally
NextHopFaceId usage no longer depends on client-control strategy.

refs #3783

Change-Id: Ie49c453f90fa34b517b576fe401c8e4e8f23eab7
2016-09-18 16:48:00 +00:00
Junxiao Shi c06746182b core: delete unused SegmentPublisher
SegmentPublisher was used in RibStatusPublisher which has been deleted.

refs #2857

Change-Id: I2c294f58a6444a99a2453057e4718cef27afe517
2016-09-17 12:32:35 +00:00
Junxiao Shi fc6515d2f7 tests: delete unused malformed.ndncert
malformed.ndncert was used in CommandValidator test suite
which has been deleted.

refs #2063

Change-Id: I7d123822c06fc2ccc4301c62ae7d312662659e38
2016-09-17 12:26:39 +00:00
Junxiao Shi 3d1eb091c0 tools: nfdc status commands
These commands are added to nfdc:

    status show
    face list
    channel list
    strategy list
    fib list
    route list

They are implemented by calling into legacy nfd-status procedures,
and currently do not support filtering arguments.
Future commits will re-implement them directly with StatusReport.

refs #3749

Change-Id: I11f3f074966649c3732969ffa22f9b3938bb4bac
2016-09-14 19:20:20 +00:00
Junxiao Shi bf6acd5cc9 tools: normalize nfdc exit codes
refs #3749

Change-Id: I0c81dff095c170390f62de82badc0cca7b53392d
2016-09-14 03:57:57 +00:00
Junxiao Shi 737c43cdad tools: nfdc creates Face and KeyChain in main function
refs #3749

Change-Id: I169ad766634371b0192ebae640355298b78aaaa4
2016-09-14 02:51:44 +00:00
Alexander Afanasyev 0fc97486ff build: Do not fail build when -Winfinite-recursion warning is generated
Change-Id: I6370a0a5a938de15924f8e139ea34b32ed20e063
Refs: #3358
2016-09-13 18:33:15 +00:00
Davide Pesavento e0edc4c06d ci: make unit tests execution compatible with different versions of Boost
This commit also unifies the coding style of CI scripts.

Change-Id: Iae73f63d8a997dbfde9233b6ee7f53a3d9644ef6
Refs: #3750
2016-09-13 18:29:52 +00:00
Davide Pesavento 0a5e5e2fa5 ci: fix gcovr invocation
Change-Id: If74633cfb67725b43a55d7b190b178137ad2c420
Refs: #3418
2016-09-13 18:29:33 +00:00
Junxiao Shi 8527f86de4 fw: correct typo in Strategy test suite
refs #3664

Change-Id: I34711f6552892ee467e0d03b0ff4c8a9c7d3b513
2016-09-12 21:32:35 +00:00
Alexander Afanasyev 6459e64f36 core: initialize Boost.Log backend through ndn-cxx
ndn-cxx logging facility and NFD logging both use Boost.Log.
When each of ndn-cxx and NFD adds a std::clog sink, messages are
appearing twice on OS X, resulting in scrambled log output.

This commit removes NFD's Boost.Log backend initialization and
let ndn-cxx logging facility initialize Boost.Log.

Change-Id: Ib25efe5c924d530424c275f9c8f168683f4ef039
Refs: #3761
2016-09-12 10:01:36 -07:00
Junxiao Shi 25c6ce41d5 mgmt+rib: include ndn-cxx/mgmt/nfd/*
refs #3760

Change-Id: I9a2e3012af2f72495ce3259fa4f51ebaa8ea7096
2016-09-09 13:49:59 +00:00
Junxiao Shi cbc8e947bf daemon+rib: add proper #include line for NDNLPv2 tags
refs #3755

Change-Id: I3ab279405aca7c7139e8d0e8e662eb3ea7200045
2016-09-06 03:17:45 +00:00
Junxiao Shi 0dba01018c fw: improve Strategy::lookupFib test coverage
refs #3664

Change-Id: I0ae2e2f99d91306930718d43982ca1744640e533
2016-09-06 01:57:53 +00:00
Eric Newberry b5aa7f58e8 mgmt: add faces/update command
refs #3731

Change-Id: I79777a10feecb2de83276371100cc86a43d0e76d
2016-09-05 09:33:17 -07:00
Junxiao Shi 64567bb12a tools: nfdc command line parser
refs #3749

Change-Id: Ief301152212a6d501f0396b2c9834e860ddaf6c5
2016-09-04 16:00:27 +00:00
Junxiao Shi 58320f7156 fw: UnsolicitedDataPolicy registry
refs #2181

Change-Id: I39f5dd02a224f9d872bde29f29aab05f64bb6e06
2016-09-04 04:40:34 +00:00
Yanbiao Li 5ad19febad rib: keep AutoPrefixPropagator log levels symmetric
Change-Id: Iabf254706dba0ea7843495912be4154321a91993
refs: #3524
2016-09-03 07:16:46 +00:00
Junxiao Shi 88f5f7392b fw: change default UnsolicitedDataPolicy to drop-all
refs #2181

Change-Id: I5e70a6f7d025462e96e852159343b478c8404ea7
2016-09-03 07:11:37 +00:00
Eric Newberry 4260241659 mgmt+face: move protocol-specific face creation checks into protocol factories
Also brought implementation of faces/create in line with design

refs #3731

Change-Id: I4f48079136b42c7fdbd4fdfba37116d2565f9dc1
2016-09-02 18:56:24 -07:00
Davide Pesavento 231ddd7508 ci: stop adding capabilities before running unit tests
This ensures that all tests pass (or are automatically skipped)
when run as an unprivileged user.

Change-Id: If8b66fd6555de455648576565b1c6cbd02695d1b
Refs: #3418
2016-09-02 22:20:00 +00:00
Junxiao Shi cf0f3ce319 fw: move Forwarder::lookupFib to Strategy::lookupFib
refs #3664

Change-Id: Ib4dd2354d853f7d6455bf08bb6b863b5f77076c1
2016-09-02 13:01:59 +00:00
Davide Pesavento aaa5dd3a00 tests: add callgrind start/stop macros in benchmark programs
Change-Id: Ibd875f4275431ebcbeba2fffe319956580714553
Refs: #3610
2016-09-02 12:33:33 +00:00
Alexander Afanasyev a269f47bc7 docs: Fix syntax for python3
Change-Id: I52fc914f462a87efae49115827163db09a5212d1
2016-08-31 18:59:55 -07:00
Junxiao Shi 9685cc5682 mgmt: tables.cs_unsolicited_policy config option
This commit introduces tests/check-typeid.hpp which provides
unit testing tools to validate runtime type information.

refs #2181

Change-Id: I987c9875517001ea82878cbe2646839a03ad54f3
2016-08-29 12:47:05 +00:00
Junxiao Shi 2f741327e6 tools: legacy nfdc parses command with Boost.Program_options
refs #3749

Change-Id: I5274e0a2594323729834cd8001308ec699fbe6d6
2016-08-29 00:53:18 +00:00
Junxiao Shi 8c39bf0b9f tools: rename nfd::tools::nfdc::OutputFormat to ReportFormat
refs #3749

Change-Id: I4984d056c26f9ecbda25103ad60dc50bb60a4dec
2016-08-28 23:54:13 +00:00
Junxiao Shi e0fa33b2a0 fw: delete deprecated BroadcastStrategy
refs #3206

Change-Id: Ifa5e2ac08ce236a4c20b6b49abe5c40cdc74652b
2016-08-26 02:27:38 +00:00
Junxiao Shi fc02186460 table: StrategyInfoHost stores StrategyInfo as unique_ptr
refs #3205

Change-Id: Ia194ca94717347848d257096549cfec5df1ba6c9
2016-08-25 21:51:18 +00:00
Junxiao Shi 2af9ca368b table: move CS limit change logging to cs::Policy
refs #2181

Change-Id: Ifffc72b4f8c84b9caa254ce30b57a42d83fa5b11
2016-08-25 21:51:02 +00:00
Junxiao Shi 0cc125c365 mgmt: TablesConfigSection constructor accepts Forwarder&
refs #2181

Change-Id: I1a87dd573f25f3806bc1b1f3c60ec9eef0eca4e3
2016-08-25 21:50:04 +00:00
Junxiao Shi 36b22256c1 fw: additional unsolicited Data policies
refs #2181

Change-Id: I439a77f8f48ad194459dc2391cd0ad8d0860b83e
2016-08-25 13:22:21 +00:00
Junxiao Shi fbe8efea55 fw: UnsolicitedDataPolicy
The decision of whether to cache or drop an unsolicited Data is moved from
Data unsolicited pipeline to UnsolicitedDataPolicy.

refs #2181

Change-Id: Iba3e72c2214e0ac5f6f305c2c1c0ed182b008e85
2016-08-22 16:02:30 +00:00
Junxiao Shi 2e526d70d2 rib: delete RibStatusPublisher
RibStatusPublisher is unused since RibManager switches to ndn::mgmt::Dispatcher.

This commit also corrects a typo in rib-entry.hpp

refs #2857

Change-Id: I968a836e46c9a7e70513d45c90099678ef587f86
2016-08-22 16:02:13 +00:00
Junxiao Shi 06d6ba666d rib: add proper #include line for ndn::OBufferStream
refs #3741

Change-Id: If08719fac9e977bd5d68c1aba491738eacbfa900
2016-08-22 15:59:03 +00:00
Junxiao Shi 37175489ca mgmt: delete CommandValidator
CommandValidator has been replaced with CommandAuthenticator.

refs #2063

Change-Id: I6569db6ff103de5f56cac480e334f32ff9f9a40f
2016-08-22 03:59:15 +00:00
Junxiao Shi 9ddf1b5c26 mgmt: NfdManagerBase::makeAuthorization uses CommandAuthenticator
This commit also eliminates Forwarder in Mgmt/TestFaceManager/CreateFace test suite
and uses FaceTable directly.

refs #2063

Change-Id: I596e8c2a12dad64ee75082f384955f30d574f53e
2016-08-22 03:58:55 +00:00
Junxiao Shi 217384025e core: change ManagerBase::authorize to makeAuthorization
refs #2063

Change-Id: I0e6faced6e4e1733362e3ec018e2ee60fcefafa1
2016-08-22 03:58:28 +00:00
Junxiao Shi 29b4128397 rib+tools: adapt to Controller::CommandFailCallback with ControlResponse
refs #3739

Change-Id: Icf5b3ed0bd997730a024bad2ccd258c8168b4ccb
2016-08-22 03:47:02 +00:00
Junxiao Shi 331ade75da tools: merge nfd-status into nfdc
nfd-status functionality is accessible through `nfdc legacy-nfd-status` subcommand,
and nfd-status is replaced with a shell script calling this subcommand.

refs #3749

Change-Id: Iab03f3bc9ddb4333a0b6ca5fb9c67f54e9960ab4
2016-08-19 14:07:19 +00:00
Junxiao Shi d243d71bf5 tools: split nfdc into multiple files
refs #3749

Change-Id: I24a3fd287773d0577d438e9ca24dc1dfab335a4f
2016-08-19 06:45:31 +00:00
Junxiao Shi 5b3feb6008 table: rename StrategyInfoHost::getOrCreateStrategyInfo to insertStrategyInfo
refs #3205

Change-Id: Icd3ab9e4fdb5a2ffc39a8d0e0c713e22f13fe28c
2016-08-19 01:51:41 +00:00
Junxiao Shi d7631279f7 mgmt: CommandAuthenticator
refs #2063

Change-Id: I19a82d8d1fdfb3cc5a003166b1a8c1c32bbf24b5
2016-08-17 04:16:31 +00:00
Junxiao Shi f5409d434a table: Pit::deleteInOutRecords accepts Entry* instead of shared_ptr
refs #3164

Change-Id: I512da6200d4d744d5631fc78900795d19ad5dd52
2016-08-17 02:47:12 +00:00
Davide Pesavento 1c2c6c45e2 table: silence unused variable warning in release builds
Warning introduced in commit 80f9fcdaa1

refs #3164

Change-Id: I3e97a1f6adf3beedc4b5608cac75a276735891cb
2016-08-16 12:36:06 +00:00
Junxiao Shi b30863e0e2 table: simplify StrategyChoice iterator with Boost.Range
This commit also improves Doxygen in NameTree, Fib, and Pit enumeration.

refs #3738

Change-Id: Ibb56f958df4d1bc2564192d905cfc2e499a7875e
2016-08-15 21:32:01 +00:00
Junxiao Shi 13ad4b7a42 table: simplify FIB iterator with Boost.Range
refs #3738

Change-Id: I0bfe985c9dac86a67988f77a89f4d2694c4fd9f5
2016-08-15 04:51:21 +00:00
Junxiao Shi 9f6ca60f74 table: declare name_tree::Range type
Declare that NameTree enumeration returns name_tree::Range type
instead of an unspecified type usable with range-based for.

refs #3738

Change-Id: I132c583704d0c6164077abf70a694e833b448e85
2016-08-15 04:50:29 +00:00
Junxiao Shi dbef6dc8e2 table: Pit::erase accepts Entry* instead of shared_ptr
refs #3164

Change-Id: I9ff47c80865da42b09870c632707dffd78ed76b9
2016-08-15 02:58:36 +00:00
Junxiao Shi 3248205bb7 table: PIT iterator dereferences to const shared_ptr<pit::Entry>&
refs #3164

Change-Id: Id857e214a727917009f865c2cfac782077844799
2016-08-15 02:05:17 +00:00
Junxiao Shi 09cf13cd9f table: move PIT iterator to a separate file
This commit only moves code around and renames variables.
There's no functional change.

refs #3164

Change-Id: Icb6b249cc0c07fcfe42f7a6d6987de31285566e7
2016-08-15 02:05:00 +00:00
Junxiao Shi 8ff0a86e18 tests: don't store shared_ptr<pit::Entry> in StrategyTester
refs #3205

Change-Id: I20ed5023fe07ba71d8df56a02228013acb8a8cb6
2016-08-13 04:50:50 +00:00
Junxiao Shi b9420cf0c1 fw: accept const shared_ptr<pit::Entry>& in Forwarder pipelines and Strategy actions
refs #3205

Change-Id: Ia683fb1a9e301270f99bcdd4d97493abf3dbec9f
2016-08-13 04:38:52 +00:00
Junxiao Shi 340d5533ea table: make name_tree::Node the sole owner of name_tree::Entry
This commit also improves name_tree::Entry test coverage.

refs #3687

Change-Id: I92375f29fbebab82c67da7dff2ea7a2952ba2cca
2016-08-13 04:00:35 +00:00
Junxiao Shi e7258ffa88 table: cleanupOnFaceRemoval doesn't rely on shared_ptr<name_tree::Entry> anymore
refs #3687

Change-Id: I3901f053bf370ca5a19a0fea72aec8eb58fcfe10
2016-08-12 23:55:47 +00:00
Junxiao Shi dd8f66140b table: NameTree::findLongestPrefixMatch accepts all table entry types
This simplifies longest prefix match procedures in FIB and StrategyChoice.

refs #3687

Change-Id: I9aa93232124b91bae7890d065337ac9389e8398e
2016-08-12 15:42:52 +00:00
Junxiao Shi 15e98b00f5 fw: pass const shared_ptr<pit::Entry>& to Strategy triggers
refs #3205

Change-Id: I8f227c57ee6733526f0569de81f20677210cafa4
2016-08-12 11:21:44 +00:00
Junxiao Shi 759993b922 table: delete unnecessary name_tree::Iterator destructor
refs #3687

Change-Id: Iccb755c0b1234d31bea84797db348fd229b2fde9
2016-08-12 11:19:08 +00:00
Junxiao Shi 7f35843d58 table: NameTree::lookup return Entry& instead of shared_ptr
refs #3687

Change-Id: Ie86057337dd36ff2bc6ef3ea0c73fd4ffc4b13d0
2016-08-11 17:06:33 +00:00
Junxiao Shi f2420fc7a3 table: ensure NameTree::lookup(tableEntry) does not return nullptr
NameTree::lookup(tableEntry) is always equivalent to NameTree::lookup(Name).
NameTree::getEntry(tableEntry) should be used when inserting new name tree entry is undesired.

refs #3687

Change-Id: I0b17cd07dde83341976cfe66c85855dfb2fa6e89
2016-08-11 13:18:21 +00:00
Junxiao Shi 811c010098 table: NameTree findExactMatch, findLongestPrefixMatch return Entry*
refs #3687

Change-Id: I32752fd711b9641228fbb7f356e72144780cf9ec
2016-08-10 04:12:45 +00:00
Davide Pesavento 67f30273dd build: add waf-tool to simplify building with AddressSanitizer & friends
Change-Id: I769be2650c0c174b9e12e0832a5d2eea9bcad2d6
Refs: #2589
2016-08-10 01:55:16 +00:00
Junxiao Shi 352fc82185 fw: AccessStrategy test suite avoid deprecated ndn::Face::expressInterest overload
refs #3703

Change-Id: Ib8f79d56551315c4ebc54f1574a4afbe95b99d9f
2016-08-09 03:53:05 +00:00
Junxiao Shi 9ede5bd312 tests: TopologyTester avoid deprecated ndn::Face::expressInterest overload
refs #3702

Change-Id: I6dcb76be1fcfaa184068390b5ab25640d21a937b
2016-08-09 03:51:27 +00:00
Junxiao Shi e3cf285ee7 table: delete deprecated functions in NameTree
NameTree::eraseEntryIfEmpty is renamed to eraseIfEmpty;
the deprecated overload that accepts shared_ptr<name_tree::Entry> is deleted.
name_tree::Entry::getPrefix is deleted in favor of getName.

This commit also improves Doxygen in NameTree class.

refs #3687

Change-Id: Ia98ca676ce6d3bc7b2e97328adccac911c8167d7
2016-08-09 03:50:56 +00:00
Junxiao Shi f9f7cf35ae tests: fix assertion failure in PIT+FIB benchmark
refs #3571

Change-Id: Icb06adfd9460cd65fdd77428d79f0f75d1e71133
2016-08-08 05:51:06 +00:00
Junxiao Shi b660b4c9c0 table: refactor NameTree hashtable
refs #3687

Change-Id: I908c1d7e67da861fc86a756fc0bc69b99ee696f7
2016-08-06 20:47:44 +00:00
Junxiao Shi 029401f6cc table: refactor NameTree iterator
refs #3687

Change-Id: Icf5be98d79cfaa27597f62832fcd0189df2731d1
2016-08-05 12:55:14 +00:00
Junxiao Shi 9f5b01dfd8 core: move common.hpp to core/
Headers in core/ are now included as `#include "core/*.hpp"`.
This allows NFD to rely less on include paths when used as a submodule in
another codebase, such as ndnSIM and NFD-Android.

refs #3127

Change-Id: Ia38f3c97427e17ff7b5401281f1fe875b5d5313e
2016-08-05 03:54:28 +00:00
Junxiao Shi 38f4ce9f25 tools: refactor nfd-status
refs #3658

Change-Id: Ia347074bea802eba5f539208e276e849a60db8a4
2016-08-04 10:01:52 +00:00
Junxiao Shi 9cff779038 table: pit::FaceRecord stores Face& instead of shared_ptr
refs #3164

Change-Id: Ib23ab2341a37213fee791f2070f13b76da851d53
2016-08-01 21:45:11 +00:00
Junxiao Shi 02b73f5705 table: delete PIT in-record and out-record when face is destroyed
refs #3685

Change-Id: I3c20417c9a30db69c90c9d59a30af1529bc1f98e
2016-07-28 01:48:27 +00:00
Junxiao Shi 2570f3ec4f table: NameTree code style corrections
refs #3687

Change-Id: I25cfac1d8b11236c251c2ab717facb82b62dcb10
2016-07-27 02:48:29 +00:00
Junxiao Shi dcffdaafb5 fw: decouple Forwarder and FaceTable
refs #3679

Change-Id: I449e20e58a0a67a7172bdf3ab02b0d655149690f
2016-07-26 02:23:56 +00:00
Junxiao Shi 80f9fcdaa1 table: don't use shared_ptr in Measurements
refs #3164

Change-Id: I7705d00ac155b15b5db69809610b68e96360a0ae
2016-07-24 22:52:28 -07:00
Junxiao Shi 71d12148c8 daemon: display extended exception information in NfdRunner::run
refs #2541

Change-Id: I1fdc22571e7bce74d430b7938951170765b72bff
2016-07-23 20:10:18 +00:00
Junxiao Shi d23de8b9ef tests: don't inline functions in test-common.hpp
This commit also adds a signData(Data&) overload.

refs #1694

Change-Id: I8e3ff5be7c6734dec8b481d6c20eb6b6eaef0725
2016-07-23 20:05:42 +00:00
Eric Newberry 4a4ccfe7d6 face: Set FaceScope to local for IPv4-mapped IPv6 loopback addresses
refs #3682

Change-Id: I33c22d3585c8fee081b1317cdd6587ec0f0e4ef5
2016-07-23 09:40:27 -07:00
Junxiao Shi 5149320e5b tools: don't use deprecated ndn::encoding::dataBlock
refs #2950

Change-Id: Ibda4af7ab50df5a7f5700d7db5de1da938b7e020
2016-07-23 02:03:08 +00:00
Eric Newberry cb27ea8185 build: Fix build issue with Boost.Asio on Ubuntu+clang
refs #3588

Change-Id: Ica155f22fa615eed8a14b5765cdce0f6e480b1de
2016-07-20 19:59:57 +02:00
Junxiao Shi ae04d34c17 fw: FaceTable signals use Face& instead of shared_ptr
refs #3205

Change-Id: I53ecd0d6a13d379eb1dfb872041bdde8501f05e7
2016-07-19 13:20:22 +00:00
Junxiao Shi b84e6743be fw: FaceTable iterator dereferences to Face& instead of shared_ptr
This commit also improves the speed and reliability of
Mgmt/TestFaceManager/CreateFace test suite.

refs #3205

Change-Id: Idd013488ced2d7f8072ef8a3d910f94da2e0c8ac
2016-07-19 13:16:22 +00:00
Junxiao Shi 5b43f9a74d fw: FaceTable::get returns Face* instead of shared_ptr
refs #3205

Change-Id: I1c61493382fe065389266ff3519ab2b265fe4f79
2016-07-19 13:15:56 +00:00
Junxiao Shi 581cf00ee8 core: fix NFD_LOG compilation error with Boost 1.59
refs #3674

Change-Id: I58ea54478cc333fbfb57c8319d0ccd94c944c75f
2016-07-18 11:48:20 -07:00
Junxiao Shi a49a1abf12 table: StrategyChoice uses unique_ptr instead of shared_ptr
refs #3164

Change-Id: Id3110f72aab83982b0768e596a04bad9f7336975
2016-07-15 18:24:36 +00:00
Junxiao Shi 3978c92af1 table: fix uninitialised memory error in DeadNonceList test suite
refs #2359

Change-Id: I90c1597e4b49edc036cad8225f85edb9ed1437a6
2016-07-15 18:24:11 +00:00
Junxiao Shi 221b6fec69 tests: don't use makeDummyClientFace
refs #3383

Change-Id: I1803a6f482a4e6bf43363cd08a73c4bbcb26d0a2
2016-07-14 18:21:56 +00:00
Junxiao Shi ff10da6575 table: attach unique_ptr<strategy_choice::Entry> onto NameTree
refs #3164

Change-Id: I5cce7e43dba77cdaaa07347ec7ffca13f242113c
2016-07-13 17:57:43 +00:00
Junxiao Shi af9aa366fd docs: ndn-tlv-ping => ndn-tools in INSTALL
refs #2525

Change-Id: I4c137dc838f399bab3dc1dc4128ea4e39d003b13
2016-07-13 13:18:07 +00:00
Junxiao Shi a6de4290c8 table: don't use shared_ptr in FIB
refs #3164

Change-Id: I5b5eb47d60f6bf5b6389c32ac840f793767e4334
2016-07-12 02:08:10 +00:00
Junxiao Shi 8d843148d2 fw: eliminate fibEntry in Strategy API
Strategy::lookupFib can be used to obtain FIB entry.
FIB lookup is skipped when strategy does not need it.

refs #3205

Change-Id: Icba67229cbc261d9def44ffa91461ea4b09982b2
2016-07-11 22:42:42 +00:00
Junxiao Shi 05cc50ae37 fw: Forwarder::lookupFib
refs #3664

Change-Id: I0e0cc3de997653c93db9b7c89e81ea73b4fb12ac
2016-07-11 22:38:21 +00:00
Junxiao Shi b260017fec rib+tools: delete NRD
refs #3570

Change-Id: I9a6e8eb6c74ea5e09a2e724805f07ca4e58af51c
2016-07-11 08:53:53 +00:00
Vince Lehman 8a4c29e8db fw: Adaptive SRTT-based Forwarding strategy
refs: #3566

Change-Id: Idae198bb0c2ae25e25aeceec0552b1c11be89c14
2016-07-11 08:49:35 +00:00
Junxiao Shi fde3f54d67 rib: register /localhost|localhop/nfd/rib in FIB
refs #2857

Change-Id: If3a471c1c5dbe514929ce5d02a4741960dedc02b
2016-07-10 19:54:53 +00:00
Yanbiao Li cf0db02ced rib: refactor RibManager to use ManagementDispatcher
Change-Id: I3f689de7d043e85531f0b3f4accf65345cde5d9e
refs: #2857
2016-07-09 09:43:19 +08:00
Eric Newberry 25a84074ab websocketpp: Update WebSocket++ to version 0.7.0
refs #3588

Change-Id: Ief26695554bf0bfff374ba47496aaf9b75f9c630
2016-06-20 20:13:33 -07:00
Junxiao Shi 891f47bcfa fw: outgoing Interest pipeline prefers newest in-record
refs #3642

Change-Id: I591a9a9c2efdcb4607b69f2c3be584110f9e14aa
2016-06-20 00:02:11 +00:00
Junxiao Shi d41d6077ce fw: use UnitTestTimeFixture in Forwarder tests
refs #3642

Change-Id: I284716a6e6b4bd83bd9eaf9e952f4b966f0d57e5
2016-06-19 23:35:27 +00:00
Alexander Afanasyev 3d1874af59 build: Adjust order of link flags
The previous order of flags (unintentionally) had `-lboost_log` flag
specified before `-lndn-cxx`.  Incidentally, the order adjustment avoids
a symbol collision between the two libraries that prevented nfd-status
and nfdc from working on Ubuntu 14.04. A proper fix will follow (see #2859).

Change-Id: I68a5d37b013c1bf91b25e707a04ab1f66298a7f4
Refs: #3650
2016-06-19 12:30:15 -07:00
Alexander Afanasyev 6ca6cf7474 core: Specify fully-qualified namespaces in logging macros
Without the full specification, compilation may fail if the logging
used outside ::nfd namespace, e.g., in NFD tools.

Change-Id: I24d733acf920bc90521ac457ae1fe6c846a1fe3e
2016-06-17 16:24:01 -07:00
Alexander Afanasyev 67079664ae ci: Add installation of openssl dependency
Change-Id: Iea19a3a617d770687b4f131a068601255a6c94cf
Refs: #3643
2016-06-15 12:36:08 -07:00
Weiwei Liu f5aee94f15 tests: fix running with non-root user
Refs: #3418

Change-Id: If7f5c05baaff0cf748c87c77057517928539df0d
2016-05-31 11:44:00 -07:00
Junxiao Shi 2879779804 table: fix Pit::find leak of NameTreeEntry
refs #3619

Change-Id: If1043a08c9f4f8bb53cad77d2b6f21991553e1cc
2016-05-26 18:10:18 +00:00
Junxiao Shi b184e5324d table: NameTree::getEntry
NameTree::get is renamed to NameTree::lookup.
NameTree::getEntry is introduced to return the NameTreeEntry on which a table entry is attached.
tableEntry::m_nameTreeEntry is changed to weak_ptr to avoid circular shared_ptr reference.

refs #3608, #3619

Change-Id: I425b6a2eb5fe3024bbaff4ff766eb6739be54b02
2016-05-26 18:09:57 +00:00
spirosmastorakis ff920303df table: fix Pit::erase crash when Interest name contains implicit digest
refs #3608

Change-Id: I41e0cd327b9dcc5f2d3a83f4cebff40c2d302fc1
2016-05-26 18:09:31 +00:00
Alexander Afanasyev e0d71b0bc0 build+tests: Correct detection of privilege elevation/drop and the corresponding test case
Change-Id: I005c2846474a00aeeb3e63a1e9761a3f8bc0a572
Refs: #3494, #3632, #3633
2016-05-25 19:07:11 -07:00
Yumin Xia ab49745afe core: use Boost.Log for logging
This makes the logging backend asynchronous

Change-Id: Ib3417e2ae424c5ae7237c071dc4698ca9769a33c
Refs: #2513
2016-05-11 11:33:13 +08:00
Weiwei Liu ace83ac938 tools: display Nack counters in nfd-status
refs #3569

Change-Id: I59e76d421502417a13efbf088284d278da07bae4
2016-04-27 12:15:54 -07:00
Spencer Lee 75142a10be face: improve UnixStreamChannel test suite
Change-Id: I41eaa3c7d1dea9effdc2e597926b110c9a703084
Refs: #3372
2016-04-27 12:15:06 -07:00
Davide Pesavento b84bd3a8c4 common: remove DECL_FINAL/OVERRIDE macros; use C++11 keywords directly
Change-Id: I71a148b0df7c95387b2caa8e2b9fe93b03ca2399
Refs: #3599
2016-04-27 12:15:06 -07:00
Davide Pesavento cafae24473 build: require gcc >= 4.8.2 and boost >= 1.54.0
Change-Id: I6778f55f43e517a3d1d28387e953412a5292f063
Refs: #3599
2016-04-27 12:15:06 -07:00
Davide Pesavento cc7bee7d80 docs+ci: Ubuntu 12.04 is no longer supported
Change-Id: I423a0f22662383f52413d12dc26d2a4ed08579e2
Refs: #3599, #3600
2016-04-27 12:15:06 -07:00
Alexander Afanasyev 6602b3b179 ci: Update Travis-CI to use Ubuntu Linux 14.04 (trusty) and OS X 10.9 VMs
Due to resource constraints, this commit also makes Travis-CI to build
only once (debug, without precompiled headers, with tests).

Change-Id: I65ec64bca545093efae384dd00b51bbeaf7d9b65
Refs: #3360
2016-04-26 18:43:19 -07:00
Weiwei Liu 4f1afaca16 tests: face system benchmark
Change-Id: Ia2d9125486c57f949e5c855ae6b8d95ffd5aa6e3
Refs: #3567
2016-04-17 20:53:55 -07:00
Yumin Xia d72f092052 tests: PIT and FIB benchmark
Change-Id: I906f82f42dc6ca5dbf0871fae99c47fdda62c7a5
Refs: #3571
2016-04-14 09:00:55 -07:00
Junxiao Shi 8744c97a4d fw: hasPendingOutRecords considers Nack
refs #3545

Change-Id: I986187f58e60090518df2a55a8bd9c1f05771b03
2016-04-12 16:20:35 -07:00
Yanbiao Li df846e5904 core: allow ManagerBase be inherited by RibManager
Change-Id: Ie2613e32460fb109a9f9302a0cc4b4b3400ba9f4
refs: #2857
2016-04-12 14:10:55 -07:00
Davide Pesavento eee53aa5d5 tests: skip IPv6 tests if IPv6 is not available
This commit also renames the getAvailableInterfaceIp() API
to getTestIp(), and improves its expressiveness.

Change-Id: I4b0080fb5e85cd523305ecb14183ef6acb34b5cd
Refs: #3367
2016-04-11 19:58:45 +02:00
Junxiao Shi f3410d8c59 fw: use scope_prefix::LOCALHOST in Forwarder
refs #3546

Change-Id: I10a05b642284e7466746cac121d13e7948ca8667
2016-04-05 13:49:44 -07:00
Junxiao Shi 4846f37117 table: simplify pit::Entry API
refs #3546

Change-Id: I6a9cb83b9e56ce1d1bb6047049378c51781605af
2016-04-05 13:39:30 -07:00
Hila Ben Abraham 39a79be5ae fw: NccStrategy explore potential upstreams
ref: #3411

Change-Id: I30593e01b15a28a32011831659cce6e457633791
2016-03-30 22:00:55 -07:00
Junxiao Shi fef73e4b86 table+fw: move forwarding semantics out of PIT entry
refs #3546

Change-Id: I1e6f87fd81176c116b6d758156da1cf96ea03608
2016-03-29 14:15:05 -07:00
Weiwei Liu 2c5a01a67d tools: nfd-status retrieves ForwarderStatus with SegmentFetcher
refs: #3380

Change-Id: I8fbfba38204c7a111a3940ef751e4ebf61890df2
2016-03-26 23:27:26 -07:00
Alexander Afanasyev 58d479cd4a docs+build: Prepare release of version 0.4.1
Change-Id: I03fc06c2b2f5be87e86a1fa1ab6eca83e8cc07a0
Refs: #3385
2016-03-24 14:00:09 -07:00
Davide Pesavento 305529410b build: fix pthread detection code in boost tool
It failed to build with several "null argument where
non-null required" errors on some Linux systems.

Change-Id: Ia3dccf3bb0e63d80d73b870632adc3308da6ecd0
2016-03-22 16:39:00 -08:00
Yanbiao Li 150b80deee tests: concatenate StatusDataset respones after all segments are fetched
Change-Id: Ia1c5b973b40c764d6a00fdd681ae4ade123eb7ab
refs: #2182
2016-03-18 08:25:35 -08:00
Weiwei Liu 280d7dde50 face: improve WebSocketChannel test suite
Change-Id: I7b3dfa930713331e6911a57624727163b8a7b3fe
Refs: #3373
2016-03-18 03:31:36 +01:00
Alexander Afanasyev 8509398137 build: Fix detection of Boost.Log compile flags
Change-Id: Ifdd5c485930a0bc50c1cbd76525947b001b44822
Refs: #2513
2016-03-11 13:44:37 -08:00
Davide Pesavento 42388d6c08 tools: delete deprecated ndn-tlv-peek and ndn-tlv-poke
Superseded by ndnpeek and ndnpoke from ndn-tools repo.

Change-Id: Ief379c53d73e0b3e8e0092dfb22b55c6de0de2b1
Refs: #2819
2016-03-10 12:54:48 -08:00
Minsheng Zhang ffe8bbb8aa table: allow setting CS capacity limit to zero
refs #3503

Change-Id: I6e1bfb64ea3a1f31070a7290c250fbcec46623fb
2016-03-10 13:40:37 -07:00
Junxiao Shi 330136a89e fw: fix PIT leak from DNL-detected duplicate Nonce
refs #3484

Change-Id: Id5928356a39b2f8988b6d4969c15ac744d283e3f
2016-03-10 04:53:08 -07:00
Spencer Lee bb9102f7d4 face: improve UdpChannel test suite
Change-Id: I90124bf6701639ea38154a6e3e62918dfbcfa6dd
Refs: #3371
2016-03-08 18:13:11 +01:00
Vince Lehman 4310d505a7 rib: Fix use-after-free in RibEntry::getRouteWithSecondLowestCostByFaceId
refs: #3319

Change-Id: I7c6aeb541a7cd7d83965a87e50be1a0bdf633a2e
2016-03-07 11:08:29 -06:00
Spencer Lee d5fe0cf158 face: improve TcpChannel test suite
Change-Id: I751eb58d5b794bc6ba6f77c065fe6616cfc07ced
Refs: #3370
2016-03-04 02:03:53 +01:00
Weiwei Liu 9360623853 face: improve WebSocketTransport test suite
refs #3374

Change-Id: I6ebfee61ec5f793f21a33071aa2e76295a5b496a
2016-03-03 11:09:06 -08:00
Alexander Afanasyev e6f0e91590 build: Update boost tool
Change-Id: I4255b617c3f6b9dab068114aa01caaf5e2c22569
Refs: #2513
2016-03-03 11:03:16 -08:00
Alexander Afanasyev dd7e5da016 build: Fix compatibility with Python 3
Change-Id: I7a1b98c38c2ed3a147c7b0e6c7b79d2723f2a3ba
Refs: #3493
2016-03-03 08:39:39 -08:00
Davide Pesavento 459cf197b7 tests: fix build with clang 3.8
Change-Id: Idcb5db7b3c0dc645aa569b70b4ea8df9858b7cd4
Refs: #3498
2016-03-03 02:20:12 +01:00
Weiwei Liu 073da60b19 face: improve Face test suite
refs #3376

Change-Id: Ibc36b16d0e6f620112bfa730ecb30149ddfd7ca5
2016-02-26 17:18:25 -07:00
Junxiao Shi 4370fde844 table: fix PIT not matching full name
refs #3363

Change-Id: I4ff3d02aaf43c3aaba843cfcf6221c218c1cea99
2016-02-24 13:28:45 -08:00
Alexander Afanasyev 965f23dd61 docs: Add licensing statements for NFD and third-party components
Change-Id: I544499af303d020a4275fa8782b2b71656c766be
Refs: #3133
2016-02-23 16:33:15 -08:00
Weiwei Liu 72cee94646 face: improve UdpFactory test suite
refs #3375

Change-Id: I8f6b17e5fcdbcd56cf8a4585993159919035f3a1
2016-02-16 14:34:06 -07:00
Alexander Afanasyev bc9ed49a55 tests: Customize environment to run test cases
This commit minimizes the impact of running unit tests on the host
system. In particular, the test cases will have its own public info and
TPM.

Change-Id: Ic6e78ebd80dea920806ca1898caa6a2eac30348b
2016-01-26 22:41:16 -08:00
Yanbiao Li 6db75f0bd2 rib: delete incorrect assertion in AutoPrefixPropagator::afterEraseRibEntry
Change-Id: Ie78675055317e5297174447ce4782c5e0fafd760
refs: #3362
2016-01-26 01:19:36 -08:00
Junxiao Shi 4100646192 Update copyright notices for files modified in 2016
refs #3415

Change-Id: I187c4709a40d3540e89a59cf678e53cf35ad1676
2016-01-19 07:31:59 -07:00
Alexander Afanasyev 3152abac67 ci: Fix unit test execution with boost 1.60
Change-Id: I461e634e5cdf022fed76ca6b92759b18b1d4aed6
Refs: #3417
2016-01-18 22:44:38 +01:00
Vince Lehman 9aac873415 rib: Don't add inherited routes to RIB entries pending removal
refs: #3404

Change-Id: I33a4ee7aa4e286a562c720656cb9e4ee7753ae05
2016-01-11 17:16:26 -06:00
Alexander Afanasyev da3ba96430 docs+build: Prepare release of version 0.4.0
Change-Id: I3af73fed66b44d708532bbda146376b7f7487d28
Refs: #3008
2015-12-29 20:39:40 -08:00
Junxiao Shi 809462490f mgmt: enhance ForwarderStatusManager test suite
Newly added GeneralStatus dataset as well as its legacy counterpart are tested.
The test suite is simplified with ManagerCommonFixture.

refs #3081

Change-Id: I9a00a6f69866c722d7f7fbaa3e207ae6e2ec79f5
2015-12-29 17:53:18 -07:00
Junxiao Shi 498373dd01 mgmt: publish GeneralStatus dataset
In ForwarderStatusManager, publish ForwarderStatus as a dataset at
/localhost/nfd/status/general.
To maintain backwards compatibility, an Interest to /localhost/nfd/status
also retrieves this dataset.

It's intentional not to update the test suite in this commit,
to illustrate that backwards compatibility is maintained.

refs #3081

Change-Id: I9b636e2e621563185303a7304be402c8221c9863
2015-12-29 17:51:26 -07:00
Eric Newberry c64d30aeff mgmt: re-added expiration time to FaceStatus
refs #3381

Change-Id: I57d3166fc6ed52a54c442a80faffe7a7f4051e1d
2015-12-29 13:11:47 -08:00
Alexander Afanasyev 5c47597be9 tools: Automatically start ndn-autoconfig in nfd-start, if enabled in autoconfig.conf
Change-Id: I09d3fff87f00ce8684e6e304e8327f9d03ca18bf
Refs: #2716
2015-12-28 14:15:50 -08:00
Eric Newberry 6d8ee7acc9 tests: MulticastUdpTransport test suite improvements
refs #3346

Change-Id: I31b272b9b99d97ed317cf534d9e1bc4592bde77d
2015-12-24 20:39:56 -07:00
Junxiao Shi cde37ad608 face: face refactoring completion
* delete old Face
* rename LpFace as Face
* eliminate LpFaceWrapper and use new Face

refs #3172

Change-Id: I08c3a5dfb4cc1b9834b30cccd9ab634535d0608c
2015-12-24 01:02:05 -07:00
Junxiao Shi c5401494fe face: UdpChannel minor refactoring
refs #3172

Change-Id: I36d7a27df6d97e8fc1d8ec76e4e25b7987954cf8
2015-12-23 16:33:22 -07:00
Eric Newberry 65caf20092 tests: UnicastUdpTransport test suite improvements
Fixed m_hasBeenUsedRecently uninitialized in DatagramTransport

refs #3307

Change-Id: I786a84009d9cf01e0bb211c872d4375f46c747fd
2015-12-22 11:26:38 -08:00
Davide Pesavento ca25d72064 face: adjust pcap filter in EthernetTransport to accept only untagged frames
Change-Id: Id14d6e57dc9f7c765f0431335b917c2fe74231c4
Refs: #3348
2015-12-21 19:11:07 -08:00
Alexander Afanasyev f22ebaf7f1 tests+ci: Enable dual XML and HRF output of unit test results
This commit also makes unit tests to run against a debug build, to
ensure assertions are properly evaluated (based on suggestion
in I5f4419ea48d4eb333e9d107115ef3df4123f76e5).

Change-Id: I1bbf14f75aab155ed80a36fc4006f7a5d13f1289
Refs: #2252, #2805
2015-12-21 13:50:29 -08:00
Davide Pesavento f35a5a9b08 tests: in LimitedIo, use std::exception_ptr to avoid slicing
Change-Id: I459792cf80ee189842ada84c3a514134bcd79a29
Refs: #3327
2015-12-18 19:21:46 +01:00
Eric Newberry f68f378a23 tests: UnixStreamTransport test suite improvements
refs #3305

Change-Id: I6c6ca52a5e80266920ded811ff45fc568c3e59b9
2015-12-17 23:51:35 -07:00
Eric Newberry 8717e87046 tests: TcpTransport test suite improvements
refs #3306

Change-Id: I3b342b4df13db7996b03de7d1bed65b579798f85
2015-12-09 15:07:08 -07:00
Junxiao Shi 0de23a29c5 face: use IncomingFaceId, NextHopFaceId, CachePolicy tags
This commit replaces all LocalControlHeader usages with these tags,
and deletes LocalFace.

This commit also does minor improvements in RIB test suites.

refs #3339

Change-Id: I14cbfc296a6723a5860bf8bd95d9804d3bac3da5
2015-12-03 20:07:02 +00:00
Muktadir R Chowdhury 6c4a67af0d tools: adapt to ndn-cxx SegmentFetcher API change
Refs: #2734
Change-Id: Ibce8942007d0b26f34b212140a7b4313c4b6a397
2015-12-01 15:15:51 -07:00
Davide Pesavento 35120ea2f1 face: EthernetTransport
This commit replaces NDNLPv1 fragmentation and reassembly
with NDNLPv2 fragmentation and reassembly.

Change-Id: I10751157fcced94d441167ce470aaed79c12bb54
Refs: #3170
2015-11-26 02:53:20 +01:00
Davide Pesavento eee7b97d7b face: MulticastUdpTransport: set remoteEndpoint for received packets
Change-Id: I0d600d94e41a67c2d58ec10cde3cb6c13f619771
Refs: #3262
2015-11-26 02:49:27 +01:00
Davide Pesavento 762912d711 face: use the correct macro to declare classes final
Change-Id: I7f07d49a4b622ea1207b34d0c4a0f830a0141783
2015-11-26 02:40:51 +01:00
Alexander Afanasyev bd916ad7fc docs: Predefine missing DECL_FINAL macro in doxygen configuration file
Change-Id: Ic7e161bba091b49fe507f913259f53f44d49e862
2015-11-25 17:26:29 -08:00
Eric Newberry 4c3e6b89a1 face: NDNLPv2 fragmentation and reassembly
refs #3171

Change-Id: If29035b697b904ee49cb86d9248be488657c6f9e
2015-11-13 15:47:59 -07:00
Junxiao Shi 8c0500fd97 table: fix Measurements::get(Fib::s_emptyEntry) crash
refs #3275

Change-Id: Ie630111a3421f470756412896154f8a51f60d23d
2015-11-11 08:30:16 -07:00
Junxiao Shi da93f1fd0c face: LpFace counters
FaceCounters for LpFace consist of LinkService::Counters and
Transport::Counters. Old FaceCounters class from 2014 face architecture is
renamed as OldFaceCounters, and can be wrapped with new FaceCounters class.
OldFaceCounters is only used in old Face subclasses.

This commit also updates existing face test suites to use new FaceCounters,
updates ForwarderStatus so that it does not rely on FaceCounters,
and moves the logic of copying face properties and counters into management
structs from face system into FaceManager.

refs #3177

Change-Id: I587e8a32fa72bac3af9d750b2c88342740aa08d6
2015-11-11 06:13:16 -07:00
Junxiao Shi 57df288f5b face: LinkService and Transport counters
refs #3177

Change-Id: Idc495c58c3103dae5f01a2b6ebbff47a2c4a5d2b
2015-11-11 06:12:35 -07:00
Junxiao Shi 52e8540a86 fw: increase initial suppression interval in BestRouteStrategy2
refs #3230

Change-Id: I27217a01c066e90f65b5000a29991c938042a810
2015-11-11 06:06:58 -07:00
Davide Pesavento 077df8fbb6 tests: delete unused SimpleNotification class
Change-Id: I6e574146d335f05a247ec25d0c9bd355c955d945
Refs: #2144
2015-11-11 02:27:58 +01:00
Davide Pesavento 8728a25f1d face: override Transport::beforeChangePersistency in all subclasses
This commit also adds the final specifier to some Transport
subclasses in order to improve code generation.

Change-Id: If2979fa1614476a98019ba79cee3961663fc447b
Refs: #3318
2015-11-10 13:07:10 +01:00
Junxiao Shi d5134a7cd4 tests: defer face deallocation in Face/TestTcp and Face/TestWebSocket
Deallocating face immediately at face closing would cause a Signal object
in the transport to be destructed during its execution, which is disallowed.

refs #3322

Change-Id: I4eb23f34305cfecf7d2122e94454a97353707818
2015-11-08 07:53:24 -07:00
Davide Pesavento 47ab029798 face: deduplicate callback typedefs between Channel and ProtocolFactory
This should have been part of commit 1d7e7afd38

Change-Id: I61623152180d4df288fc7dd3c225518e438d2bda
Refs: #3258
2015-11-04 19:49:58 +01:00
Davide Pesavento ed89ccc521 build: enable -Wextra by default
Change-Id: I1e6783fca6530741bf4b81dd13613a6b4235290a
Refs: #3293
2015-11-02 17:44:30 +01:00
Yukai Tu 16aabbcc3b face: TcpTransport
Change-Id: I3ff898225ad1b0c1178490f389048944e24a9f1b
Refs: #3166
2015-10-27 17:16:07 +01:00
Davide Pesavento 9c7c79f2eb tests: fix "defined but not used" build error with gcc-5
Change-Id: If0cce184f88d76333956e5957db91d5b03e16d39
Refs: #2767
2015-10-27 17:07:40 +01:00
Junxiao Shi a044be7ed9 face: refactor NullFace as LinkService+Transport
refs #3278

Change-Id: I424f70f9402823d58d097671bab8c0c2dc4f2d3b
2015-10-27 07:48:11 -07:00
Yukai Tu 2d6d5637c0 face: WebSocketTransport
Change-Id: I28db9cd6f828e4a9fe5895bb7a6152cca5baa9fc
Refs: #3169, #3160
2015-10-26 11:06:08 -07:00
Junxiao Shi 5b8a2b2128 face: change Transport static properties initialization
Transport constructor now initializes static properties to invalid values.
Subclass constructor must explicitly set every static property.

refs #3259

Change-Id: I7ac3819694e0772c33a8a5d573e260f0eb944bff
2015-10-26 10:56:42 -07:00
Alexander Afanasyev abb307c9c5 docs: Fix doxygen links in release notes and displayed version
Change-Id: Ic1ee22e2607f5ab11c38a9adcaabc27a602c65ae
Refs: #3252
2015-10-26 10:11:02 -07:00
Alexander Afanasyev ba81830e81 docs+build: Prepare release of version 0.4.0 (beta2)
Change-Id: I9c9fe4a9f43d31be9e60fd743699f8729d1ccc4c
Refs: #3252
2015-10-22 11:34:58 -07:00
Alexander Afanasyev b755e9d5a7 docs: Fixing doxygen warnings
Change-Id: Ic85f86f4de8224e2fa5d1c41f6afb0f367af5b37
Refs: #3210
2015-10-22 11:34:56 -07:00
Davide Pesavento c8a66d3530 tests: delete pointless assert
size_t is an unsigned type, therefore the comparison is always true.

Change-Id: I851fa0d59569ebc8e2572b1938020aadabb05f27
2015-10-21 17:28:13 +02:00
Junxiao Shi 1354611277 face: Transport::getMtu
refs #3253

Change-Id: Ia4c5cfe210a99b798ce7d05f74ebdd7cfab214f4
2015-10-14 19:33:07 -07:00
Davide Pesavento 1d7e7afd38 face+mgmt: simplify factories and FaceManager using C++11 features
Change-Id: I113a4c15ef82bff705f61f31b170f49727bc3794
Refs: #3258
2015-10-13 16:28:52 +02:00
Junxiao Shi 6535f1ed28 face: InternalForwarderTransport & InternalClientTransport
InternalForwarderTransport and InternalClientTransport are a pair of forwarder-side
and client-side transports that can be connected with each other, so that link-layer
packets sent by one transport can be received by the other.

They are used together with LpFace, GenericLinkService, and ndn::Face to replace
InternalFace and InternalClientFace used by NFD management.

They also replace TopologyForwarderTransport and TopologyClientTransport used by
TopologyTester of forwarding unit tests.

refs #3225

Change-Id: I5b6b579c43dfd0b1b9def5100be2ce516219cb74
2015-10-10 05:36:34 -07:00
Eric Newberry a1939ba993 face: GenericLinkService drops IDLE packets
refs #3249

Change-Id: I3d16bcf29f4858049d1040a3e421e1c7151b3fed
2015-10-09 21:28:19 -07:00
Alexander Afanasyev 964d4598ef tests: Fix compilation against boost 1.59
Change-Id: Id539021a6c317425b162be33d220e2a8fe574899
2015-10-09 13:03:19 -07:00
Junxiao Shi 747b67d38f build: downgrade keyword-macro from an error to a warning with clang
refs #3235

Change-Id: I48c95d8dd3e767b551618f7ec7fffc33fbd30fd6
2015-10-05 16:42:41 -07:00
Yanbiao Li d7c9636078 rib: redesign of remote prefix registration
Change-Id: I8418de6d5bb9615af898df5dbf9ed4cc2cb6a43a
Refs: #3211, #2413
2015-10-04 20:58:52 -07:00
Junxiao Shi 94735f99cb core: delete NotificationStream
nfd::NotificationStream is no longer necessary because NFD Management
has switched to ndn::util::NotificationStream from ndn-cxx.

refs #2144

Change-Id: I30678c58dea4ea0b41c88a0ef7e660b116579e44
2015-10-04 13:33:50 -07:00
Minsheng Zhang 9c903e063e table: fix PriorityFifoPolicy memory leak
Change-Id: I1bd7d75b3a24b854a0a07e1fa197ef793f66192f
Refs: #3236
2015-10-04 12:17:43 -05:00
Davide Pesavento f485d89f16 build: disable clang's unused-local-typedef warning
This commit also enables color diagnostics on release builds.

Change-Id: I75d898ac1f3cf48097850f0cda807e3bee1cd206
Refs: #3209
2015-10-03 01:57:41 +02:00
Alexander Afanasyev f9572e8439 build: Fix compilation with boost 1.59
Change-Id: Ib2f72a770effa4a35ad6d21585ddc1043a89ac02
Refs: #3227
2015-10-01 16:20:58 -07:00
Alexander Afanasyev 687dba8614 docs+build: Prepare release of version 0.4.0
Change-Id: Ibd3129da74afa24a35115789a517e562f0a12639
Refs: #3178
2015-09-27 19:34:56 -07:00
Spyridon Mastorakis d374c406b2 daemon: display extended exception information in top-level catch
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4912cb
Refs: #2541
2015-09-27 11:36:42 -07:00
Junxiao Shi 259d0d876f Merge branch 'feature-lp' into master
Change-Id: I2efd0bf044c07b8cdaf03ab62a9b6b71a76b8b09
2015-09-26 19:35:42 -07:00
Junxiao Shi 40cb61c6bd mgmt: LpFace faces/enable-local-control workaround
In this temporary workaround,
faces/enable-local-control enables all local fields in GenericLinkService,
and faces/disable-local-control disables all local fields in GenericLinkService.

This commit also modifies FaceTable::remove to retain shared_ptr<Face>
until signal execution is complete.

refs #3226

Change-Id: I3513e97ec2af87df94dbf57a7256b895ed9d2103
2015-09-26 14:38:38 -07:00
Junxiao Shi 643b36b814 face: receive LpPacket in InternalClientFace
refs #3225

Change-Id: Ia37cfb941f00c612fc265594dac33cf13c6ad32c
2015-09-26 14:38:31 -07:00
Yukai Tu 0a49d34342 face: UdpTransport
Change-Id: I54f43248785437cdf951d50099e46e9689962a75
Refs: #3168
2015-09-26 14:38:22 -07:00
Yukai Tu 74c895d316 face: UnixStreamTransport
Change-Id: Iaab3c09887d7167ab9024ba871162367bf835197
Refs: #3165
2015-09-26 14:38:13 -07:00
Junxiao Shi 5e5e445182 fw: Nack in pipelines and best-route strategy
* in PIT out-record, add last incoming Nack field
* create incoming Nack pipeline
* create outgoing Nack pipeline
* modify Interest loop pipeline to send Nack upon duplicate Nonce
* in strategy API, add after receive Nack trigger and send Nack action
* in best-route strategy, send Nack-NoRoute before rejecting pending Interest
* in best-route strategy, process incoming Nack

Other changes include:

* Pit::find
* StrategyTester saved arguments structs
* TopologyTester transmit at Transport level

refs #3156

Change-Id: I7868561c0838231083d471261200aeb280cc6e9d
2015-09-26 14:38:03 -07:00
Eric Newberry 86d3187d9b face: GenericLinkService encoding/decoding
refs #3104

Change-Id: I26e83cd1dd5dc87ebdc040105ab1bad4afdba5f7
2015-09-26 14:37:51 -07:00
Eric Newberry a98bf93a25 face: Refactor Face as LinkService+Transport
LpFace: new Face implementation
LpFaceWrapper: allows new Face system to work with old Face system

Eventually, LpFace will be renamed to Face and LpFaceWrapper will be removed.

refs #3088 #3179

Change-Id: Ia4ad7c84631e65b444d4f24e1d7593392927c8db
2015-09-26 13:40:17 -07:00
Davide Pesavento ec2a698301 Remove illegal std::to_string definition and use ndn::to_string in its place
Change-Id: I81481fea3267bde669c45df182e0aea8ccd1a188
Refs: #3214
2015-09-21 01:17:16 +02:00
Davide Pesavento 01f8dba914 Use make_unique where appropriate
Change-Id: I30c9f0fb2033a810df73a1c9147fcf09d610f763
Refs: #3093
2015-09-19 21:56:34 +02:00
Davide Pesavento d2856a41ef Stop including <ndn-cxx/common.hpp>
It is considered an implementation detail, therefore its presence
and content should not be relied upon by other projects.

Change-Id: I7e53ecadf65336c8e9500481ff3a532761bac1f1
Refs: #2098
2015-09-19 21:30:47 +02:00
Alexander Afanasyev 441ba2175e daemon: Properly handle exception from NetworkMonitor when the platform doesn't support it
Change-Id: I713a6b6ebe4ac1e49f939325c7372954cb28e159
Refs: #3195
2015-09-17 16:50:56 -07:00
Alexander Afanasyev 435d705138 build: Fix compilation warnings/errors with clang-700.0.72 (apple LLVM 7.0.0)
Change-Id: Iedbebae03740a5d779c84e78d22b74dd9b9009f7
Refs: #3209
2015-09-17 15:10:25 -07:00
Junxiao Shi 06a29459dc docs: delete NRD manpage from toctree
refs #2489

Change-Id: I98bf2bbd6895b1c64c3cd4dc24abc493969a0de4
2015-09-10 06:08:25 -07:00
Alexander Afanasyev 483c43396c Merge feature branch 'mgmt-refactoring'
Change-Id: I3f122ede5bcfbad40800d8dae440dfea887bb10e
Refs: #2107
2015-09-08 18:41:01 -07:00
Alexander Afanasyev ecbf584299 mgmt refactoring: Correct ForwarderStatus publishing
Change-Id: I8207af814757b5f4ce3ea9b8bb66d7f5a369af2f
Refs: #2107
2015-09-08 17:25:23 -07:00
Vince Lehman 63ab1bb27a mgmt: Add tables.network_region section in config file to populate NetworkRegionTable
refs: #3159

Change-Id: If049eea2baf64a22abc9437d3ec117dd0d27bbab
2015-09-07 21:50:11 -07:00
Yanbiao Li 6704a4a6e4 mgmt refactoring: StrategyChoiceManager
Change-Id: Ib6df3f627070a3b6d4777f8efbe30e601e4c1512
Refs: #2107
2015-09-07 19:00:41 -07:00
Yanbiao Li 7cec7eafce mgmt refactoring: ForwarderStatusServer (renamed StatusServer)
Change-Id: I83aceca49e02f49553c9b17e16d6b50fb93e32de
Refs: #2107
2015-09-07 19:00:30 -07:00
Yanbiao Li 711c793171 mgmt refactoring: FibManager
Change-Id: Ied235d025cbe5059545c6482bfed0f38f987fdeb
Refs: #2107
2015-09-07 19:00:20 -07:00
Yanbiao Li 73860e3397 mgmt refactoring: FaceManager
Change-Id: I292a3e3d702746d6e946a2844e6f88f64cd711a4
Refs: #2107
2015-09-07 19:00:07 -07:00
Yanbiao Li 698f4fea3a mgmt refactoring: ManagerBase
Change-Id: I0710297f352723874d05092d091128b02b3747a2
Refs: #2107
2015-09-07 18:59:01 -07:00
Yanbiao Li 4ee73d42a4 mgmt refactoring: Refactor InternalFace
InternalFace is now exclusively for internal use by NFD's forwarding
pipelines.  A separate InternalClientFace has been introduced, intended
to be used by the NFD internal applications, including FIB, Face, RIB
manager, and others.

Change-Id: I4a06b9d05b1613a456c6267582091924557d73be
Refs: #2107
2015-09-07 18:58:48 -07:00
Yanbiao Li 36f3500d21 mgmt refactoring: Remove legacy code
Change-Id: Ib443ff3d45f9c49edee59d79c42a932017fc66ec
Refs: #2107
2015-09-07 18:58:34 -07:00
Joao Pereira c6184cdb3e tools: Extend nfdc to allow creation of permanent faces
Change-Id: If108fc3c7ae2ba1adab50269db3a23b426553b56
Refs: #2993
2015-09-04 20:22:01 -07:00
Yukai Tu 8149d1077b mgmt: Process FacePersistency in FaceManager
Change-Id:I3a93bd658d40f3d77f7790b72e8873646ecc7990
Refs: #2991
2015-09-04 10:44:24 -07:00
Junxiao Shi 0355e9fd06 fw: Forwarder processes Link for mobility
This commit also adds NetworkRegionTable to store producer region names,
and checks packets are well-formed before entering forwarding pipelines.

refs #3034, #3155

Change-Id: I8de4c482e8a289b922be70139675bc4661f9a301
2015-09-02 07:24:53 -07:00
Alexander Afanasyev 2fc649bfc6 docs+build: Prepare release of version 0.3.4
Change-Id: I7e0276ce210cf5322fd5f3195821b3edee74fc64
Refs: #3132
2015-08-31 09:10:26 -07:00
Junxiao Shi 67ba8d28df fw: rename BroadcastStrategy to MulticastStrategy
BroadcastStrategy is temporarily retained for backwards compatibility.

This commit also updates nfd.conf and ndn-autoconfig to use MulticastStrategy
in place of BroadcastStrategy.

refs #3011

Change-Id: I011f1cf75db26b3c93552f8322a0bba4ce8dd033
2015-08-21 21:21:28 -07:00
Yukai Tu 375dcb0bd6 face: minimal UDP permanent face
Change-Id: I44f652b95c911667107fd30829c7ce6e5acab706
Refs: #2989
2015-08-18 15:04:21 -07:00
Junxiao Shi 0e092aee5c mgmt: revert router name configuration options
This reverts commit ee7c8441c8.
That implementation introduces a global static variable which conflicts with ndnSIM.

refs #3026

Change-Id: I803e2ab497f71ec259d96d7b094ba0d04718c344
2015-08-18 15:03:15 -07:00
Vince Lehman faa5c0cd3c fw: Correct log message in onContentStoreHit
refs: #3114

Change-Id: I918cffc5d0551484b4cc31a4b7d6aeb73b8969ae
2015-08-18 15:02:25 -07:00
Spyridon Mastorakis 149e02cf7d Enhance exception throwing with Boost Exception library
Change-Id: I471023fc23ffaebe04d9668426b4c1b03e4919aa
Refs: #2541
2015-08-17 16:17:33 -07:00
Alexander Afanasyev a714792b03 docs: Remove nrd manpage
Change-Id: Ib6185c5e32ccbe01ea3803e2e9fb50749ffc9bfe
Refs: #2489
2015-08-09 23:51:06 -07:00
Alexander Afanasyev 66c569ddcc mgmt: Fix compilation and test cases when dropping privileges is not supported
Change-Id: I7da7eca3e5019dd5a7ed20b26f6e0c3260a03850
Refs: #3064, #2447
2015-08-09 23:45:13 -07:00
Alexander Afanasyev 3f41ade02d daemon: Reload face_system section of the config file when NIC configuration changes
The main desired effect of the reloading is re-creation of multicast
faces, e.g., when a new interface appears in the system.

Change-Id: I8384e5f96285ddca363981c92e1b6de39e0072ef
Refs: #2460
2015-08-07 12:17:14 -07:00
Minsheng Zhang 0315269228 table: add CS policy LRU
Change-Id: Ief9e3d993782730069cedc8a99b8011d5d18ce7c
refs: #2219
2015-08-04 12:32:08 -07:00
Stumble 62b19a6c09 docs: add spec of prefixes that are automaticly registered upon discovery of hub
Change-Id: I26a19e4c0f3608e0f159801e63e201d2d376d0ed
Refs: #2718
2015-08-03 18:15:07 -07:00
Yukai Tu 7c90e6dfea face: ProtocolFactory::createFace with FacePersistency
Change-Id: If02510bd631e9aaa63b3cca89ced31a42e192ded
Refs: #2989
2015-07-29 23:50:25 +08:00
Joao Pereira 4e274ac915 nfd-status-http-server: erroneous <!DOCTYPE html> display
refs: #3019

Change-Id: I9b400446c12ed1b6b0899dced0d9b4aff8720d4c
2015-07-23 11:54:52 -04:00
Vince Lehman ee7c8441c8 mgmt: Add router name configuration options
refs: #3026

Change-Id: I44250476e7e7f25cbc2b40d6a59f64b55872b24a
2015-07-17 19:06:24 -07:00
Vince Lehman c1dfdb44da rib: Accept KeyChain in RibManager constructor
refs: #2390

Change-Id: I45c9aae4bb111d75de63dcbcba4b3e6296eb2426
2015-07-17 08:18:28 -07:00
Alexander Afanasyev a4527cc837 ci: Fix TravisCI script
Change-Id: Ic5d725eb825b7db71735f865852685830dacfffd
Refs: #3041
2015-07-15 22:39:20 +08:00
hwyuan 8082993f7f table: Remove useless boolean in NameTree::const_iterator::operator++
Refs: #2808

Change-Id: Ief819d46a4c44eede5e1fecb951fb3e6002ad409
2015-07-12 19:41:38 -07:00
Alexander Afanasyev b81cff966e ci: Enable automatic dependency installation in Jenkins scripts
This commit also unifies TravisCI dependency installation using Jenkins
scripts.

Change-Id: Ia7bae2e2f31e781c07acea729d61fa07345760ab
Refs: #2843
2015-07-12 10:50:31 +08:00
Yukai Tu 731f0d70fa face: replace isOnDemand with FacePersistency
Change-Id: Ie6995b2d03bbb90faad158de2b055f72dd9ba73d
Refs: #2989
2015-07-09 07:46:52 -07:00
Joao Pereira 08f07016a3 ci: build ndn-cxx as shared library
refs #2992

Change-Id: Ia65a5d1868d2a63b30adf3bd496be071bc57dd6b
2015-07-08 03:52:25 -07:00
Alexander Afanasyev 2666473042 docs+build: Prepare release of version 0.3.3
Change-Id: Ia53f820fb60e8a9ed5da0ac1667b8d10ef79c414
Refs: #2812
2015-07-01 11:23:12 -07:00
Joao Pereira 5b6deaea18 docs: Fix indentation in nfdc manpage
refs #2995

Change-Id: I154b1ccc73022f59ff8166d4353ee3a23dc75215
2015-06-30 16:03:20 -07:00
Yukai Tu 971d3c2b09 tools: Simplify nfd-status using SegmentFetcher
refs #2456

Change-Id: I5beb402b211717816ae11d3474b41ade15c7418c
2015-06-29 09:47:43 -07:00
Alexander Afanasyev dbe4f9fefe tests: Fix compilation errors because of changes ndn-cxx library
Change-Id: I10fb7eb366a03c2e06e6d2efefdde8a9dd0da724
Refs: #2951
2015-06-28 11:24:51 -07:00
Alexander Afanasyev 692842d6ad rib: Avoid deprecated nfd::CommandOptions::setSigningIdentity method
Change-Id: Id98538d96368c67ac1db939e0ad0fd43ec0c6ab9
Refs: #2893
2015-06-23 14:26:45 -07:00
Minsheng Zhang cb6e05f2dd table: add CS policy interface
Change-Id: I1946fe03ca00150b1ff9f08acae48c01bc569904
Refs: #1207
2015-06-12 10:03:17 -05:00
Junxiao Shi 5620fb2ac9 tools: deprecate ndn-tlv-peek and ndn-tlv-poke
refs #2817

Change-Id: Iee198533659320bf2e9219b92195e06a3ba2b25f
2015-06-07 20:59:38 -07:00
Junxiao Shi 965d3a4e72 fw: AccessStrategy avoid loop back new Interest
refs #2831

Change-Id: I1680fd62cdf8f11eaa7817dd6d4b7794c305c5eb
2015-06-01 06:55:23 -07:00
Eric Newberry 187ade8566 contrib: Add unit file and instructions for systemd
refs #1586

Change-Id: I06b91804fc8b8613560ef98687307f56262689fb
2015-05-15 14:43:31 -07:00
Alexander Afanasyev 2d1b64066c docs: Add missing item in the release notes for version 0.3.2
Change-Id: Iba4f70c2125a702905e11c1db7846495ef377a97
Refs: #2618
2015-05-12 21:15:06 -07:00
Alexander Afanasyev ed808ab2c9 docs+build: Prepare release of version 0.3.2
Change-Id: I43223e09c2201c7d3185a3d8929a691ae963c5d1
Refs: #2618
2015-05-12 13:36:59 -07:00
Junxiao Shi 7b0f4d1dd8 fw: AccessStrategy extends measurements lifetime
refs #2452

Change-Id: I79ffcc65cb222854c163c5df339bb1061785a518
2015-05-12 13:36:59 -07:00
Alexander Afanasyev 483d652d95 build: Disable precompiled headers on OS X with clang < 6.1.0
Change-Id: I4e88f35d6e649eb5b2eefef868ac29576e293877
Refs: #2804
2015-05-12 13:36:59 -07:00
Alexander Afanasyev 1c85221192 build: Update waf to version 1.8.9 (with custom patches)
https://github.com/cawka/waf/tree/2a098b1e9bc626c19cbd47c1f670758c17edf54c

Change-Id: I1e6c352f6ffa272e896391b983fee4cca7cdf8a6
Refs: #2792
2015-05-06 14:51:38 -07:00
Wentao Shang d397d7773c face: switch to non-throwing version of websocketpp APIs
Change-Id: I0291dff14373cadeec16d44c73d9db43011fff4b
Refs: #2630
2015-04-29 18:20:27 -07:00
Vince Lehman f91ab74da9 rib: Stop removed namespace from inheriting ancestor route
refs: #2757

Change-Id: I9f9e18109f0d8ee45571d23a6eea7f254302a56f
2015-04-27 10:00:14 -05:00
Davide Pesavento db9d37edab Fix several "defined but not used" warnings with gcc-5
GCC 5 is able to prove that in some translation units the static Logger
instance is defined but never used, and generates an unused variable
warning for each one of them. These warnings become fatal errors when
building in debug mode, due to -Werror.

Silence the compiler by not declaring the unused variables.

refs #2767

Change-Id: Icacc579d917d660582221ef090954ec827f46149
2015-04-24 10:25:56 -07:00
Alexander Afanasyev ce81230b09 build: Emulate std::to_string when it is missing
Change-Id: I4a08cf4abe7a2064a0c53d29582cbb761a1d131f
Refs: #2743
2015-04-14 23:37:03 -07:00
Mathias Gibbens 802c092d1a face: Use C version of snprintf
Change-Id: I18f85f6debda47af17a4006699f1283dc75b735d
Refs: #2299
2015-04-14 14:47:20 -07:00
Junxiao Shi e8f4246e13 docs: update Planned Features - face enhancements
refs #2617

Change-Id: I64dd36025bf1baf0f93a631d02c7d2a6754c6eba
2015-04-06 21:37:28 -07:00
Alexander Afanasyev cdb8f364c1 build: Tweak default pkg-config search paths
Change-Id: Id9b656104b00fd18c9302165b0eeeffd17f6c87a
Fixes: #2711
2015-03-31 17:19:35 -07:00
Alexander Afanasyev e06b627f31 build: Update waf to version 1.8.8-dev (with custom patches)
https://github.com/cawka/waf/tree/8f714a523d3b8c66f2949aaa8db91d6f7be55e55

This patch also ensures that unused-local-typedef warning does not
generate errors.

Change-Id: I024438c338d0455df11508779c10a2737d25caab
Refs: #2209, #2657
2015-03-26 14:36:02 -05:00
multicast proxy d6474640da tools: Fix hanging of nfdc on wrong input
Change-Id: I4fd4fb95d3dee72f5e0b8bc2435f7fffca87e5e3
Refs: #2690
2015-03-26 14:36:02 -05:00
Vince Lehman 9dcfc40f21 rib: Fix TestFibUpdates/EraseFace on Ubuntu 14.04 32-bit
Change-Id: I1381bc3eb813a1afad9b666fba30688216ee38dc
Refs: #2697
2015-03-26 12:34:26 -07:00
Davide Pesavento 2231ab526f Get rid of the last use of ndn::dns in NFD
Change-Id: I9a3188379a4755f5535af05a860a2e3a12ddc8ba
Refs: #2422
2015-03-19 13:13:25 -07:00
mzhang4 eab7249b74 table: change ContentStore lookup API to allow async implementations
refs: #2411

Change-Id: Ifbb4179c34cf10a7913f8113a2f9238476d8eafa
2015-03-19 04:59:33 -07:00
Davide Pesavento 292e5e1436 face: use move semantics for sockets where possible
Change-Id: I2af595073f862c570c1ce0dcb3717f3d2b9cfd71
Refs: #2613
2015-03-17 21:32:49 -07:00
taylorchu 5ae2877796 build: make wscript compatible with python3
Change-Id: I5b29d85d0b758ec2d154eb71a2637cd73658807a
Refs: #2625
2015-03-17 16:45:27 -07:00
Vince Lehman 76c751ce80 rib: Perform FIB updates before modifying RIB
refs: #1941

Change-Id: I1457f71ddd1c120daae48308d5cc02a7c0ecf93d
2015-03-13 19:57:39 -07:00
Junxiao Shi e4eec13108 face: avoid deprecated Block::fromBuffer overloads
This commit also does some cleanups in NDNLP PartialMessageStore.

refs #2553

Change-Id: I6a74929e58d38bde1a9ac365f7d5c42862d37592
2015-03-13 15:40:49 -07:00
Davide Pesavento 6ad890a098 face: Stop using shared_ptr to manage acceptors
This commit also includes a major cleanup of all channels.

Change-Id: I10db9709e0cba6a0691a86482c60b5dbb2956f68
Refs: #2613
2015-03-11 22:04:40 +01:00
Alexander Afanasyev 8896478926 build: Update version number to 0.3.1
Change-Id: Ibbb64815f3d334c830bee734928813bbf99308bf
Refs: #2588
2015-03-03 20:10:59 -08:00
Alexander Afanasyev 58ad5d4dd7 docs: Prepare release notes for version 0.3.1
Change-Id: Ic7ff46a119f1dd5b898338ddc6673262aef026e0
Refs: #2588
2015-03-03 12:30:28 -08:00
Wentao Shang ce07470031 face: update websocketpp to version 0.5.1
Change-Id: Id5ce36532d30c7d37da466762b335b740e67ad67
2015-03-02 21:07:34 -08:00
Junxiao Shi ebaf7b61fc table: delete nfd::cs::skip_list::Entry
This type is part of the old ContentStore implementation,
which should have been deleted during the merge.

refs #2254

Change-Id: Ib64ee8a65b39bd191d8bdcf4e71ebd5460d342a9
2015-03-02 10:40:03 -08:00
Junxiao Shi 083f778321 face: no exceptions in NDNLP PartialMessageStore
refs #2261

Change-Id: I711502be23bb4b3691eb44fc63332ffd0bfb8d34
2015-03-01 20:46:11 -07:00
Junxiao Shi 78926c9083 face/rib/tools: avoid deprecate Block::fromBuffer overloads
refs #2553

Change-Id: I32ea424ab7547f59fea2fca70ad6f41cd90bab58
2015-02-28 23:02:31 -07:00
Alexander Afanasyev e84044e87d tests: Fix segfault in TableNameTree test suite when all test logs are enabled
Change-Id: I0acb886d38a09b764cb3e324490a7c52b945d4fa
Refs: #2564
2015-02-27 11:31:19 -08:00
Davide Pesavento 9427941781 face: refactor handling of LinkType face trait
This commit also includes some cleanups, fixes EthernetFace to report
the correct LinkType, and makes (get|set)Description non-virtual.

Change-Id: I53909d7bfa02a92641b523a766359413c966aae6
Refs: #2563
2015-02-27 15:12:16 +01:00
Davide Pesavento 13b76f0937 face: copy also the link type in copyStatusTo
Change-Id: I3787210328f326fd788e7f0f3e23493e4dfa9ddd
Refs: #2563
2015-02-26 18:45:19 +01:00
Davide Pesavento be40fb1e56 face: Introduce Face-specific logging macros
Change-Id: I169065de664d4c4394ccd08673bbe1f881c4d7e0
Refs: #2450
2015-02-26 18:42:59 +01:00
Junxiao Shi 684fa0f89d fw: use RetxSuppressionExponential in best-route
Retransmission suppression algorithm of best route strategy
is changed from fixed interval to exponential backoff.
This is a semantical change which requires an increment of the
strategy's version number from 2 to 3.
Version 2 is not retained because it's mostly same as version 3.

refs #1913

Change-Id: I0f18511a3b96384b071024864e638ae3b3ec7080
2015-02-23 21:39:57 -07:00
Davide Pesavento 0e97a97603 table: Reduce priority of DeadNonceList log messages
Change-Id: Id0419b9c38ec693b6111ce5b8f91a6d1aa04f705
2015-02-23 14:57:19 -08:00
Vince Lehman ff8b39746b rib: Change register/unregister logging to INFO
refs: #2547

Change-Id: Iedf72cb9c9f36742ea43650f8cdd4a9450c987de
2015-02-23 12:45:26 -08:00
Junxiao Shi 35b16b1984 table: ContentStore recognizes CachingPolicy-NoCache
refs #2185

Change-Id: Id3dab8936c4dafc96c5d8933d7e75c6cc2e31ff2
2015-02-21 21:42:11 -07:00
Spyridon Mastorakis d0381c05a6 tests: Change to updated naming conventions
Change-Id: I9351c669282c3c02fd533237489beeb10fe7d15e
Refs: #2497
2015-02-21 13:02:47 -08:00
Minsheng Zhang 60d06d8770 tools: change prefix of routable-prefixes packet to under /localhop/nfd
refs #2512

Change-Id: Ib399e61b3d7b84f7993a5b887ff6b5b7c3e93a45
2015-02-20 16:49:15 -06:00
Junxiao Shi 0d6d036e4f docs: change prefix of routable-prefixes packet to under /localhop/nfd
refs #2479

Change-Id: I49c02bbfe5eed282c33ecfe99ce8b1894a1b7d23
2015-02-20 08:21:16 -08:00
Chengyu Fan addecff68b management: clarify the inconsistency in UDP face timeouts in nfd.conf
refs #2473

Change-Id: Iceeda5f03bc426dfab1e67cf508996d3fe96ac42
2015-02-18 07:18:29 -08:00
Alexander Afanasyev 4d384fcce5 tests: Revert changes to s_normalUid/s_normalGid in MgmtGeneralConfigSection test suite
If changes to s_normalUid/s_normalGid are not reverted, the subsequent call
to PrivilegeHelper::drop() will throw exception if test cases run by an
unprivileged user.

Change-Id: I27e8b159d61e1b5f6dd21879f36ed63667f5c045
Refs: #2521
2015-02-17 09:22:29 -08:00
Junxiao Shi faf3eb0823 fw: register strategy with macro
refs #2410

Change-Id: Ifa79c194c58d0ebe1bca6236fc0a47debe2da05e
2015-02-16 22:30:16 -07:00
Junxiao Shi 73b909a514 fw: RetxSuppressionExponential
refs #1913

Change-Id: I9bb2bae8d7600722920534f646cc8056b3d4843a
2015-02-16 16:23:28 -08:00
Alexander Afanasyev a4ff44ce6f face: Update code to work with updated LocalControlHeader implementation
Change-Id: I3a73269ad30cfd8d7e366115aae08728f17c3b17
Refs: #2183
2015-02-16 11:40:06 -08:00
Alexander Afanasyev 90c20face8 face: Properly handle error conditions in UdpChannel::newPeer
Change-Id: Ia34eb738a6cc8977bbcba91f0055fe4623df4d32
Refs: #2516
2015-02-15 12:43:57 -08:00
Alexander Afanasyev baba2535e1 face: Remove Tcp|UdpChannel::connect overloads that perform DNS resolution
Change-Id: Ib5da2a43d1e33654940aa42f568b6a604c171e3e
Refs: #2422
2015-02-15 12:43:57 -08:00
Alexander Afanasyev c3ea5a7886 rib: Use only a forward declaration of RibManager in the header of Nrd class
Change-Id: I8a681dc9a75ac8cdabc289e685ec6a505cfb5aac
2015-02-15 12:43:57 -08:00
Alexander Afanasyev 2bda6f8d9c daemon: Replace shared_ptr with unique_ptr in Nfd
Change-Id: I97d39ddb793abfe4552002c94778b95e6b96f869
Refs: #2496
2015-02-15 12:43:57 -08:00
Alexander Afanasyev f08a7376e9 daemon+rib: Merge nrd and nfd into a single process (separate threads)
Change-Id: I41952d5b8ee29f109130c570e0d13ccad6970d2f
Refs: #2489
2015-02-15 12:43:49 -08:00
Alexander Afanasyev 63df436e5f core: Make global random generator thread-local
Change-Id: Ib17ea05592445cf99af9726ef7799ead813ca0fe
Refs: #2489
2015-02-15 11:58:52 -08:00
Alexander Afanasyev 6b34ab9cec core: Make logger thread-safe
Change-Id: Ic45dc0912da9c2e3f074d3f74921bfe33741bf63
Refs: #2489
2015-02-14 12:26:32 -08:00
Alexander Afanasyev 5d57f97fa7 core: Make global io_service and scheduler thread-local
Change-Id: I3d6b6cd3ca7a6e53b0dc0f4cae7a2f3270c7fd50
Refs: #2489
2015-02-14 12:25:19 -08:00
Alexander Afanasyev 9cfeecaa2f core: Prevent exception throwing when dropping privileges is not supported and not requested
The exception still be thrown, if config file requests privilege dropping.

Change-Id: I856207958354410fa45da7ccc73b46b99f74d9e7
Refs: #2515
2015-02-12 16:44:24 -08:00
Alexander Afanasyev 6f570de8d7 core: Make PrivilegeHeper::drop|raise no-op operations on platforms that do not support drop/elevation of privileges
Change-Id: I13b53ba27cee59d58b816d060501499517e6dc37
2015-02-11 20:59:09 -08:00
Alexander Afanasyev 31367925c6 rib: Refactor initialization of NRD instance
This commit also makes Face used inside NRD be adaptive to nfd.conf.
More specifically, it will use the same unix socket path as specified in
face_system.unix section.  If this section is not present, it will use
the same tcp port as specified in face_system.tcp section.  If tcp
section is also absent, nrd will abort execution.

Change-Id: I48f75ddf972f259055cd61824e3c228ca1d6a639
Refs: #2496
2015-02-11 16:13:26 -08:00
Alexander Afanasyev 31c781e453 daemon: Refactor initialization of NFD instance
Change-Id: Ie4181a0b65e249c7067a11e941dcea77f010e4b1
Refs: #2496
2015-02-10 19:12:05 -08:00
Alexander Afanasyev 8269a05874 core: Allow customization of Logger and LoggerFactory
Change-Id: I48a8217ab4cfb34ce2993f11a26266723d8d2923
Refs: #2433
2015-02-10 19:12:04 -08:00
Alexander Afanasyev 95ff7112aa tests: Fix compilation due to refactoring of EncodingImpl in ndn-cxx library
Change-Id: I3b96dd01fef810dfd2cd57d910a46f137a13879e
Refs: #2494
2015-02-10 19:11:33 -08:00
Alexander Afanasyev c0273e3505 core: Extend ConfigFile to support passing a parsed ConfigSection
Change-Id: I955220c08d8e6ed07c77d82149f6ff3ae48b2b12
Refs: #2495
2015-02-09 13:33:45 -08:00
Junxiao Shi a788e25e70 fw: rename RetransmissionSuppression to RetxSuppressionFixed
This commit also declares RetxSuppression base class as the API
for any retransmission suppression decision algorithms,
so that other algorithms can be introduced.

refs #1913

Change-Id: I5539565d2dd238d1421f5bd828fde4ecfba0a820
2015-02-04 06:56:03 -08:00
Alexander Afanasyev 3056e08c9e docs: Update link to the right version of developer's guide
Change-Id: I6a39507df56141d648728bebc9f6305584ecb067
2015-02-03 16:00:31 -08:00
Alexander Afanasyev 7c10b3bdc8 docs: Prepare release notes for version 0.3.0
Change-Id: If0ae14cbf97ee3d9b92a3467d0b6592c10e66698
Refs: #2462, #2352, #2209
2015-02-02 19:21:57 -08:00
Junxiao Shi 5af9bd3d6d table: reduce implicit digest computation in ContentStore
refs #1706

Change-Id: Ic6c4c25f2ef722b9ee37e22362ad57a434bbf821
2015-02-02 15:37:34 -08:00
Alexander Afanasyev ba3f79ec4f tools: Ensure that ndn-autoconfig quits after successful discovery in non-daemon mode
Change-Id: Ifde24e1800faba630cafb7b04d034b916a6c069d
Refs: #2469
2015-02-02 15:37:20 -08:00
Davide Pesavento 66ff0989c5 face: cleanup log messages in all faces and print fail reason
Change-Id: I405198b375a0317663d29810ee87922a19edccaa
Refs: #2450
2015-02-02 17:59:02 +01:00
Alexander Afanasyev e46279dc83 tools: Daemon mode for ndn-autoconfig (re-run detection when connectivity changes)
Change-Id: I3cb870b13ba60d255162862c7dd0053ec5b578c4
Refs: #2417
2015-01-31 21:16:39 -08:00
Yanbiao Li de88b46ac1 rib: recognize /localhop/nfd HUB prefix in RemoteRegistrator
Change-Id: If4d29b17e381f121d025ee8a9a52466a68e46a83
refs: #2412
2015-01-30 23:28:29 -08:00
Davide Pesavento 9a090a0f91 EthernetFace: report packets dropped by the kernel if debug is enabled
Change-Id: I8b0f9774c4ad785da476aba88f0b6a212256bf51
Refs: #2441
2015-01-30 03:55:23 +01:00
Steve DiBenedetto 8919abe4c4 core: set FreshnessPeriod on segment publisher Data
refs #2438

Change-Id: Ibf46dad33b0483f0716bbfef6697d73cc00a117b
2015-01-29 11:52:31 -08:00
Alexander Afanasyev 748e9892da build: Fix misdetection of privilege drop/elevation functions
Now detection uses an explicit code fragment

Change-Id: I209f8623f3db4f1c3574c09eb2770decc554a2e4
Refs: #2419
2015-01-28 15:43:59 -08:00
Alexander Afanasyev bda8366ada tools: ndn-autoconfig: Register also /localhop/nfd prefix towards the hub
Change-Id: Ia5f9ac5514470070160d32ed8883d3fa04d33e10
Refs: #2416
2015-01-28 14:17:46 -08:00
Alexander Afanasyev 2a655f70a1 tools: Refactoring ndn-autoconfig implementation
Change-Id: Ib92942ba40f04aaee83479177b9ba5d32a09af04
Refs: #2421
2015-01-28 14:17:10 -08:00
Alexander Afanasyev 262203b644 build: Support tools with multiple translation units
Change-Id: I95c7ec4c0923e59b2652c6bba4ed2c0f00aa71da
Refs: #2344
2015-01-27 18:14:10 -08:00
Alexander Afanasyev 49343f6fab build: Add conditional compilation
Two conditionals are introduced in this commit:
- if <ifaddrs.h> is not available, NetworkInterface helper will always return
  an empty set of interfaces
- If dropping/elevating effective user/group is not supported, an error
  will be thrown if used (e.g., if general.user or general.group is
  configured)

Both conditionals are necessary on Android platform.

Change-Id: Ib360e03514af97ed2d68032fbcbe279a8dc84682
2015-01-27 18:13:50 -08:00
Alexander Afanasyev 5d4c977f64 core: Use C version of snprintf
Change-Id: I7d6b6ce3bce7be2df8d004bbbf18bea43e8079d0
Refs: #2299
2015-01-27 11:05:45 -08:00
Alexander Afanasyev 76818632e0 build: Several updates of the build scripts
- Update of waf script (based on custom fork https://github.com/cawka/waf)

- Redesign the way default compile flags are determined.

  This includes a small semantical change with flag processing:
  * there are now "general" compiler and link flags. These are added (if
    supported) even if CXXFLAGS and/or LINKFLAGS environmental variables
    are set.
  * optimization/debug-mode flags that are applied only if CXXFLAGS
    and/or LINKFLAGS environmental variables are not set.

Change-Id: I6affeed08cc49bca28f076839e40ff790e57437b
Refs: #2209
2015-01-27 11:05:45 -08:00
Alexander Afanasyev d7bb88b53a tools: Fix broken link to documentation in NFD status web page
Change-Id: Ic47a1c2be6ccc185b9ff8b67c863a356a63746fe
Refs: #2405
2015-01-27 11:05:13 -08:00
Alexander Afanasyev 0e156df634 face: Remove unnecessary use of DNS resolver in (Udp|Tcp|WebSocket)Factory
Change-Id: Idbc743fe4c7d567a09acccef98fe6de26f8295f0
Refs: #2422
2015-01-27 09:24:35 -08:00
Junxiao Shi a37405dbd8 face: fix NDNLP PartialMessage cleanup scheduling
refs #2414

Change-Id: Ida9e47e41c4dde9b3ee0ee7003fc4aaa79ea55df
2015-01-26 15:05:26 -07:00
Junxiao Shi 80ee7cb931 fw: access strategy
refs #1999

Change-Id: I5fc284d7ae82ed933bf5937d5c687885e73c3e0a
2015-01-24 21:44:20 -07:00
Junxiao Shi fbf783450c rib+tools: subscribe to FaceMonitor notifications using connect
refs #2350

Change-Id: I1b1b33cdcc3638c7344b6c690f928aff25aa5c8c
2015-01-23 14:46:41 -07:00
Junxiao Shi 04cf5a99d9 Merge branch 'feature-cs' into master
refs #2254

Change-Id: Iafd4b8d51477fc11340156cc65c2732923e16354
2015-01-22 17:35:49 -07:00
Vince Lehman 7c7d33a4b5 rib: Insert RIB command prefixes into RIB
refs: #2312

Change-Id: I9452f60d4c2162ad265603d3d5d44f083452ec58
2015-01-22 10:39:36 -08:00
Junxiao Shi 85d17fcaed table: ContentStore benchmark
refs #2254

Change-Id: I422a7e6d4ca3ad17db2465460e67b8cd2130fd36
2015-01-21 22:34:03 -07:00
Vince Lehman 218be0a884 rib: Rename FaceEntry to Route
refs: #2159

Change-Id: Ia324a47816cac514dacc4a69a29fd30d08932e5b
2015-01-21 15:33:34 -08:00
Junxiao Shi 6316220d36 fw: fix NccStrategy loop back to sole downstream
refs #1998

Change-Id: I81c089f67aa6278a4fcb42ec79a32eed065e19f5
2015-01-21 14:26:21 -08:00
Chengyu Fan 5010123d5c tools: fix bug that nfdc register does not terminate if FaceUri canonization fails
refs #2397

Change-Id: I8c1dce00cfbf4926ead7c4794d02158e43008000
2015-01-21 11:24:27 -07:00
Junxiao Shi fc20696c59 table: ContentStore enumeration
refs #2254

Change-Id: Ic440afea2197f12f7720adb559b836d08e864bed
2015-01-20 12:16:43 -07:00
Chengyu Fan 4381fb6b11 core: use ndn::dns from ndn-cxx
refs #2207

Change-Id: Ice97c9203283b5b89982049cb29c0ccfed0ef422
2015-01-19 23:08:52 -08:00
Alexander Afanasyev 319f2c8dbc src: Update copyright notices for files modified in 2015
Change-Id: Ia52e6e891a06fcc7ace06eafd2fffecd7bd55a95
Refs: #2352
2015-01-19 21:45:21 -08:00
Hila Ben Abraham 6cdbdfc5ff tools: ndn-autoconfig: canonize FaceUri before creating face
refs: #2387

Change-Id: I4d5682206cd44c93f61d28b5ae3bca60d5086277
2015-01-19 12:30:14 -08:00
Junxiao Shi 192af1f71c fw: abstract retransmission suppression logic
Consumer retransmission suppression logic of best-route v2 strategy
is abstracted into RetransmissionSuppression class, so that it can
be reused in other strategies.

refs #2377

Change-Id: I7de2c2d0e60c5ad3467e24283e9b03bd03f65bdc
2015-01-19 10:50:32 -07:00
Junxiao Shi 5640ec8934 table: better ContentStore findRightmost algorithm
refs #2254

Change-Id: Ib8f473f0cce1a1636b600a98494292499d71972e
2015-01-15 21:43:55 -07:00
Junxiao Shi b283128b6f table: use UnitTestTimeFixture in DeadNonceList test suite
refs #2359

Change-Id: I8ccec1970d89268b0550b8b10e87ebd2d594c25e
2015-01-09 19:26:16 -08:00
Junxiao Shi 35353963db table: MeasurementsAccessor findLongestPrefixMatch & findExactMatch
This commit also improves unit testing of MeasurementsAccessor,
and changes signature of MeasurementsAccessor constructor.

refs #2314

Change-Id: Ie0494628c6d3faac0473bc4cfb21998f89270aaf
2015-01-09 14:04:43 -08:00
Junxiao Shi 1e46be30e4 core: rename nfd::EventId to nfd::scheduler::EventId
refs #2298

Change-Id: I5d4f4c5234fd370666e81a8a8e7d312694a6ad5d
2015-01-09 09:52:56 -07:00
Junxiao Shi 767cb33632 table: Measurements::findLongestPrefixMatch(pit::Entry)
refs #2314

Change-Id: Iebe80240760b22b573da1e6d23b43273ff3efbeb
2015-01-08 09:35:49 -07:00
Junxiao Shi b30c7b0596 table: accept predicate in Measurements::findLongestPrefixMatch
This commit also deletes unused Measurements::s_defaultLifetime constant.

refs #2314

Change-Id: I6ffce7dee828f1f9aa47099777df6ee0615ce4f1
2015-01-07 23:52:58 -08:00
Junxiao Shi c099ddb587 face: replace EventEmitter usage with Signal
refs #2300

Change-Id: I17d0d65d2c474b17dd9f23f271a6144b0b4fbc07
2015-01-06 20:50:15 -07:00
Junxiao Shi a22a217261 face: fix overhead estimation in NDNLP slicer
refs #2317

Change-Id: I1b2ec985a075083386c7117494478666eb28802e
2015-01-06 12:07:44 -08:00
Alexander Afanasyev c91ebfa900 table: Allow iteration over CS entries
Change-Id: I23bf0da9a853de70187c9e72a0f7a5cb98107fbd
Refs: #2340
2015-01-06 10:50:27 -08:00
Alexander Afanasyev 8934c4212a table: Ensure that Cs::erase removes the item from the cleanup index
Change-Id: Iefe658904829fa662c4854c38a5d57dad5e80222
Refs: #2348
2015-01-06 10:50:27 -08:00
Alexander Afanasyev 750fa1cf86 table: Allow iteration over PIT entries
Change-Id: If48d7f827ccb5df0480cfa27bd2f3db4e3f796fa
Refs: #2339
2015-01-06 10:50:27 -08:00
Alexander Afanasyev 09fc3d9df8 table: Ensure Fib::const_iterator is default and copy constructible
This functionality is necessary for ndnSIM python bindings and is
technically required by ForwardIterator C++ concept
(http://en.cppreference.com/w/cpp/concept/ForwardIterator)

Change-Id: Ibe0812c3a2cf05840cd3e83b941cc52affe2ac65
Refs: #2338
2015-01-06 10:50:27 -08:00
Alexander Afanasyev eae4f80d2c face: Limit exposure of EthernetFace implementation
It seems that gcc 4.6 on Ubuntu 12.04 has some issue with
std::unordered_map in EthernetFace implementation, causing it segfault
in some cases.

Change-Id: I0c5a3be66e357e2bd83841d833d601c2fba6936a
Refs: #2347
2015-01-06 10:48:00 -08:00
Junxiao Shi 39ef261a29 table: StrategyInfoHost stores multiple StrategyInfo of distinct types
refs #2240

Change-Id: I25062260e3bb4f2f36989305431d4b718d320505
2015-01-04 04:55:45 -08:00
Steve DiBenedetto 158f73fce2 docs: Update config file instructions for disabling unix sockets
refs: #2190

Change-Id: Ie6001e561b5dd40813da95185c123935ee51baa4
2015-01-03 16:44:14 -07:00
Junxiao Shi 3cb4fc6778 fw: use UnitTestTimeFixture in NCC test case
This commit also changes StrategyTester<S>::onAction to use Signal.

refs #2163

Change-Id: Icd30cfa640972c53efdd8c7f7164b7eb9fc34c1e
2014-12-30 06:54:19 -08:00
Davide Pesavento f8b41eb1b1 face: Fix ioctl() calls on platforms where libpcap uses /dev/bpf*
Change-Id: I2ed2cacf4915458d9b95f0a07beda46039aaa39d
Refs: #2327, #2328
2014-12-30 03:14:33 +01:00
Davide Pesavento 4147c002ec build: disable EthernetFace only with boost 1.56.0, not later versions.
The regression has been fixed in boost version 1.57.0

Change-Id: I187c523b2a715c0fd00ff438840f4275c7c55a64
Refs: #1922
2014-12-23 17:45:01 -08:00
Davide Pesavento 8eb9957db6 face: Support MTU larger than 1500 in EthernetFace (for jumbo frames)
Change-Id: Id784315569e11794dceaceffb4bb0af21b69be44
Refs: #2305
2014-12-19 19:14:36 +01:00
Alexander Afanasyev c5173de511 face: Don't crash when attempting to create UdpFace over a half-working connection
Change-Id: Ib32128074f8dfe834fde033517325f994d648767
Refs: #2311
2014-12-18 13:12:42 -08:00
Yanbiao Li b9d439d202 rib: remote prefix registration
resolve 3 bugs:

There are redundant registrations/unregistrations if loading the
config file multiple times.

Remote registration/unregistration will fail if localhop_security
is enabled.

Unstable RemoteRegistrator/UnregisterAdvanced test case.

Change-Id: I4437292e9f6c0e340c761ef7556a9bdc703ac06c
refs: #2294
2014-12-16 22:58:56 -08:00
Chengyu Fan b94af7c82f mgmt: Allow only canonical FaceUri in faces/create command
refs #1910

Change-Id: I89a84cd8584d5a718bcc85db05cc337b4b4f8f73
2014-12-16 21:47:07 -08:00
Alexander Afanasyev 508411efb5 docs: Installation instruction updates
- Suggest checking out master branch in install instructions
- Add a note to run `./waf distclean` after change of dependencies

Change-Id: Ia4ee122986840815968920bf3ba14a9892c25363
Refs: #2136, #1980
2014-12-16 13:34:52 -08:00
Junxiao Shi e5e1e250cd docs: list pkg-config as a compilation dependency
This commit also updates supported OS versions in INSTALL.rst.

refs #2191

Change-Id: I5e00c2b4f3755be571d2842cc19915c3e3a06af9
2014-12-16 06:29:54 -07:00
Junxiao Shi a938818047 table: rewrite ContentStore
This is the first of a series of commits that rewrites the ContentStore
with a cleaner design.

refs #2254

Change-Id: I6595dca63137760d2283934a8f311a14dc2183bf
2014-12-15 21:48:30 -07:00
Junxiao Shi 27533da4f1 core: scheduler::ScopedEventId
refs #2295

Change-Id: I17bc949882bebadbf4d19aaede4c634a12121787
2014-12-15 20:44:47 -08:00
Alexander Afanasyev 7e14816e85 core: Add a warning comment for listNetworkInterfaces() function
Change-Id: I2d0edaa4fced667cd79d8f7170c4a2968abd0390
Refs: #2292
2014-12-15 17:49:06 -08:00
Junxiao Shi 49e11e797e fw: give strategy access to FaceTable
refs #2272
Change-Id: I1a390dac1da8489adcffb71d488b3b8a52d257bd
2014-12-15 11:31:01 -08:00
Junxiao Shi 1e064171da fw: use Signal in FaceTable
refs #2272

Change-Id: I831963b8311c257178ad0da16d62e48b476bfee3
2014-12-15 11:30:55 -08:00
Chengyu Fan 27be0b0d41 tools: nfdc accepts FaceUri in all commands
refs #1995

Change-Id: Ifd05eb835bdf86d6e44bca4f8fe1c973ddb7a6ee
2014-12-13 15:33:57 -08:00
Junxiao Shi 1c93cae6c5 fw: add override specifier to Strategy triggers
refs #2281

Change-Id: I5357ac6a93260492900d24c8955fdd7397ef2d27
2014-12-12 06:47:59 -08:00
Steve DiBenedetto cd4ee5fcb4 mgmt,rib: check command length before accessing verb
refs: #2151

Change-Id: I0e67fd4b4df10d842648797ed42771af7c53a938
2014-12-09 00:12:43 -07:00
Junxiao Shi ac7b437cdb table/face: fix unused variable warnings in NameTree and NDNLP Slicer
refs #2290, #2287

Change-Id: I40f80f4c8a9fe830edafeada2bbd0b881194d0a3
2014-12-15 07:33:22 -08:00
Junxiao Shi 584a569a26 fw: use UnitTestClock in BestRouteStrategy2 test
refs #2160

Change-Id: I555337ecd913f73f93116455079a1a83ff7dfbc3
2014-12-14 17:39:19 -08:00
Alexander Afanasyev 70aaf8ad81 face: Prevent infinite loop in TcpFactory and UdpFactory
Change-Id: Idd694bc08033c524f3c0e569ed74341aa33fce31
Refs: #2292
2014-12-14 17:32:29 -08:00
Alexander Afanasyev 6077b39ae5 build+ci: Fixing compilation and CI scripts
Change-Id: If3c5fe06f19b5aaddc1ee8c7b73b2b3de4c45892
Refs: #2288
2014-12-14 15:05:45 -08:00
Matteo Sammarco 66df974ce8 face: implement NDNLP fragmentation in EthernetFace
Change-Id: I5b9ff271087ca0b2d5ee38be2f77911cfe9283f4
Refs: #1209
2014-12-08 06:35:09 -08:00
Junxiao Shi e368d999a1 table: simplify Measurements with C++11 features
This commit also changes TableMeasurements test suite to use UnitTestTimeFixture.

refs #2100

Change-Id: I6af9fbae435fb50d26f6ec54abc7219680c8ade8
2014-12-07 19:56:27 -07:00
Hila Ben Abraham 2ef995772b tools: display nfd software verion in nfd-status-http-server and nfd-status
refs #1916

Change-Id: I0ba272d4ba9314d483776526d05eaf0f2393dbac
2014-12-06 23:32:34 -08:00
Junxiao Shi afbd74d9f1 core: eliminate MapValueIterator in favor of boost::adaptors::map_values
refs #2239

Change-Id: Ifcc03513b1cbe580de12725baa4338f822a71417
2014-12-04 03:39:16 -08:00
Junxiao Shi 5ccd0c27fd table: use boost::iterator_range in NameTree
refs #2155

Change-Id: I14efacf26aa1143177038fff3cf20d9d845f2c68
2014-12-04 01:41:45 -08:00
Junxiao Shi 4b2e6cb321 table: fix Fib::removeNextHopFromAllEntries invalidating NameTree iterator
refs #2177

Change-Id: I19b8234d94b804273404176d6751a91f082653b7
2014-12-03 10:36:27 -08:00
Davide Pesavento 7726ae5182 face: make EthernetFace more robust against errors.
We now call .fail() instead of throwing an exception.

Also modernize the code with some C++11 features.
In particular, std::unique_ptr is now used to manage
the pcap instance.

Change-Id: I91200ff9ab64ddb2d86f082647043e42ca85f538
Refs: #1984
2014-12-02 20:35:27 +01:00
Junxiao Shi 75ab6b765f fw: use LimitedIo in FwForwarder/SimpleExchange test case
refs #2161

Change-Id: I1aedfe9d75d8aabdb6b096170d5c8b697f812d16
2014-11-30 21:50:27 -08:00
Alexander Afanasyev 6db058c4af build: Embed setting of PKG_CONFIG_PATH variable to commonly used values
Change-Id: I8f70e1bedad13f77bbd40ab53d2e31717836a667
Refs: #2178
2014-11-29 17:52:47 -08:00
Junxiao Shi 60607c734d table: make NameTree enumeration usable with range-based for
NameTree::fullEnumerate and NameTree::partialEnumerate are changed
to return a type usable with range-based for.

NameTree enumeration test cases are also simplified.

refs #2155

Change-Id: I315d9502d2194670aa7054ab956ededefb0c7ca0
2014-11-29 10:35:06 -08:00
Junxiao Shi 2bf8d2a703 table: pit::FaceRecord uses DEFAULT_INTEREST_LIFETIME from ndn-cxx
refs #2202

Change-Id: If3988f34006d0f5e86aa801774f3a9be15bfa9b8
2014-11-29 10:26:15 -08:00
Junxiao Shi 455581daa7 fw: use UnitTestClock in Forwarder persistent loop test case
refs #2162

Change-Id: Ibbf1d5fa615e4275a86caf64f79890d40cb09a77
2014-11-29 10:24:22 -08:00
Junxiao Shi 759f7060e3 build: disable assertions in release builds
refs #2139

Change-Id: Id4cc0b360848d06a0d1e5759cf2017cd1b4227ec
2014-11-29 10:19:22 -07:00
Junxiao Shi 2e0db686bd cs-smoketest: data.wireEncode() before CS insert
refs #2217

Change-Id: Id93d8ab5df4228cf156c53f21891c9b9efb64698
2014-11-27 21:22:27 -07:00
Yanbiao Li c17de8379b rib: remote prefix registration
Change-Id: I0ee01317c213380481eed5c3a13cc19fb0b897ee
Refs: #2056
2014-11-26 21:24:58 -08:00
Davide Pesavento 10783f221d EthernetFace: avoid putting the NIC in promiscuous mode if possible.
Try to use the PACKET_ADD_MEMBERSHIP socket option and the
SIOCADDMULTI ioctl, and only if they fail or are not available
we fall back to promiscuous mode.

Change-Id: Ib534e161ff86ca855e084240b94a166bc4d33ce1
Refs: #1278
2014-11-23 23:38:09 +01:00
Davide Pesavento b499a601b5 core: ignore non-Ethernet AF_LINK addresses when enumerating NICs.
Also modernize the code with some C++11 features.

Change-Id: Ibd29b39c37fdce8f87f917ab0cf48750e631e76c
2014-11-22 20:15:28 -08:00
Junxiao Shi 2b73ca3216 table: make NameTree::findAllMatches usable with range-based for
refs #2155

Change-Id: I298825145cf544faaeeb9e558f6deb6703d434c0
2014-11-19 09:30:08 -08:00
Junxiao Shi 376f73762a tests: use DummyClientFace from ndn-cxx
refs #2186

Change-Id: Ie6f959b846202f201514d757d12d96921fc19bd6
2014-11-19 06:03:28 -08:00
Chengyu Fan ab205c20e6 mgmt: respond Nack when query is invalid
refs #1993

Change-Id: I21e398cd7b2e562b7dc759a89f6e668960e72c41
2014-11-18 11:10:37 -07:00
Alexander Afanasyev ec3e4fc305 tests: Removing usage of deprecated MetaInfo::TYPE_* constants
Change-Id: I475ff8e73e8a7f0478ce62e9a54654aa4ff74e41
Refs: #2128, #1993
2014-11-18 11:56:30 -05:00
Steve DiBenedetto dbcb1a1192 mgmt: remove listen option from unix channel configuration
refs: #2188

Change-Id: I11adf075b03eab3d22f8160e5d619e3ed445dd29
2014-11-17 12:24:44 -07:00
Junxiao Shi 70db992dd1 core: simplify Logger with C++11 features
refs #2146

Change-Id: I6ad9e7281c8a6b60c46b51de727bcddded42ba3d
2014-11-16 21:17:16 -07:00
Junxiao Shi b2bcbcd866 table: simplify PIT with C++11 features
refs #2100

Change-Id: I1159761d9439f0a2ff9f6463f89f39372a696e48
2014-11-14 15:03:18 -08:00
Junxiao Shi a1937bf54c core: use FaceUri from ndn-cxx
refs #2143

Change-Id: Ida06daf406f941a699c9f1013450951db3cd28e9
2014-11-14 12:44:55 -08:00
Junxiao Shi 913806d047 fw: fix clang compilation error in best-route v2 test case
refs #2179

Change-Id: Ibee6e9c27fd3a0aae7bd1611428f986cff1d1df0
2014-11-14 11:45:10 -07:00
Chengyu Fan 320d23334f mgmt: Implement Query Operation in FaceManager
refs #1993

Change-Id: Ieb59bb68bfe839242d1cdd0dd7e3a079a8a0c8de
2014-11-14 03:56:25 -08:00
Junxiao Shi cd55cde10d tools/tests: fix compilation errors caused by bind and placeholders
refs #2175

Change-Id: I65eadb0d0ccf468c3d478236335dbf09aa4dcc71
2014-11-13 16:03:24 -07:00
Junxiao Shi 21303afdf1 common.hpp: delete boost::scoped_ptr
refs #2154

Change-Id: I56730705418a1a10a02b2a0148b8edbf5828f99e
2014-11-12 21:40:36 -07:00
Junxiao Shi 8e273cac72 rib+tools: avoid deprecated ndn::nfd::Controller(Face&) constructor
refs #2039

Change-Id: I8fde413a9f38b18d00b71878b623f0eeb3551b09
2014-11-12 00:42:29 -07:00
Alexander Afanasyev 3651fd75f7 tests: Marking some cs test cases with expected failures
The marked test cases are failing because of the changes with implicit
digest processing.

Change-Id: I6827223c53f576d4377998339cc0e122ae81e52d
Refs: #2157, #1640
2014-11-10 10:41:47 -08:00
Alexander Afanasyev 689f0e9d52 tools+core: Moving Network class implementation to core
Change-Id: I312b827215c8ec3d13aff61584f162125fc48d2a
Refs: #2153
2014-11-09 19:17:11 -08:00
Junxiao Shi 838c4f1a2a table: simplify StrategyChoice with C++11 features
refs #2100

Change-Id: If0082c8561d706df86e92c14cb87762962ff200b
2014-11-09 19:16:07 -08:00
Junxiao Shi 7c7c136dc4 fw: fix best-route v2 strategy test case
refs #2126

Change-Id: I9badfb011385097f7f32c2a7ead3f25e5e8ee032
2014-11-09 17:56:15 -08:00
Junxiao Shi 3a8b1b5add table: simplify dead nonce list with C++11 features
refs #2100

Change-Id: I095bae18f47f4d1c85830fb9ceb87053fe3529e7
2014-11-09 09:47:55 -07:00
Junxiao Shi 56a21bf34a table: simplify FIB with C++11 features
refs #2100

Change-Id: I293044ae321b9a1d7c07a34f631c49c791c7856d
2014-11-07 14:35:01 -08:00
Junxiao Shi 39cd633013 face: use MAX_NDN_PACKET_SIZE constant from ndn-cxx
refs #2099

Change-Id: I46331436e0605f77f6b6ac7b49d50fe1570817b8
2014-11-07 04:20:15 -08:00
Junxiao Shi 3ffe66d4ef core: use ethernet::Address from ndn-cxx
refs #2142

Change-Id: I1258a0a1cadbedb31c506c69c84b7906a61fc761
2014-11-06 20:27:23 -08:00
Wentao Shang 6990e4c7b8 face: drop WebSocket message if the size is larger than maximum NDN packet size
Change-Id: I8e2bd81bbd0d4ba3598ab7c16a3125189b38ca4f
refs: #2081
2014-11-06 19:33:09 -07:00
Junxiao Shi 1f30aac8a2 fw: redesign best-route v2 strategy test case
New test case doesn't require exact timing, so that it's less likely
to fail on a busy/slow system.

refs #2126

Change-Id: I87fc34df40911de56e5acd2b5e5ff6f03c928ecf
2014-11-06 19:32:38 -07:00
Steve DiBenedetto c0640f5e97 mgmt: add config file-based strategy selection
refs: #2053

Change-Id: I76b5945768403578651429ca3170f29d9e66ad54
2014-11-05 09:52:54 -07:00
Alexander Afanasyev b4bac92547 tools: Fix status-http-server hanging when nfd-status output is >64k
Refs: #2121

Change-Id: I84382bc01891cd1c7e52912f9a6ef2c131e1046a
2014-11-04 15:37:41 -08:00
Alexander Afanasyev 4e88e07f76 ci: Make sure we build NFD with tests and precompiled headers
Change-Id: I0f867124bdc76e688152340bcca2f0c2691bd9b2
2014-11-03 13:54:08 -08:00
Junxiao Shi cf1e6e7465 core: use EventEmitter from ndn-cxx
Deleting EventEmitter in core/.

refs #2117

Change-Id: Ieab631c0b3101e313a0af44af7085bcf090596b0
2014-11-02 21:38:22 -07:00
Wentao Shang 306df5eeac build: compile websocketpp in C++11
Change-Id: Iad6a34f2b081030c4806ecc2b8f732206bd80d7a
Refs: #1930, #2082
2014-10-31 19:05:20 -07:00
Davide Pesavento ab1e8f2497 build: Always build in C++11 mode.
This commit also includes update of websocketpp submodule, as the
previous version has compilation problems on OSX with XCode 6.1

Change-Id: I8c9670d0026d840838d77e610e50679ee5ede7a5
Refs: #1930, #2082
2014-10-29 23:53:23 -07:00
Felix Rabe 35eefdfa1a INSTALL.md: Uppercase
Change-Id: I0847869c88c91c5173b85f677dfd3257af9fe4b2
2014-10-27 13:39:58 -07:00
Alexander Afanasyev 4d4e725233 ci: Embedding CI build and test running script
This commit also unifies build and test scripts for Jenkins and Travis CI

Change-Id: Ieaf2d8793c2320a23ce9958c9cf06b3abd4d500f
2014-10-26 18:24:45 -07:00
Alexander Afanasyev 4cf4170b75 table: Evict unsolicited Data in FIFO order
Change-Id: Iba97441e3e23e686da0612810b09108090e64aca
Refs: #2043
2014-10-20 10:38:10 -04:00
Junxiao Shi 67f11acf5c all: avoid usage of deprecated namespace ndn::Tlv
refs #2079

Change-Id: I3d8748929706726b55fe1a9a0f6ae00857ea3547
2014-10-20 06:52:36 -07:00
Junxiao Shi a110f268c7 fw: use dead Nonce list in pipelines
refs #1953

Change-Id: I0faef2a985b03fe96387c2e0181588713550b9ce
2014-10-19 20:50:48 -07:00
Chengyu Fan dae253025c nfdc: ensure FaceUri is in canonical form
refs #1909

Change-Id: If0560c03f3cafe3cd3a181246a7c185e07ade1ca
2014-10-19 14:08:30 -06:00
Chengyu Fan 9942cea529 tools, tests: replace FaceFlags with individual fields
refs #1992

Change-Id: Ic635deb5c6c03f2eba4c440357ca435a46a91588
2014-10-14 11:24:09 -06:00
Chengyu Fan 27d570a089 tools: Display face attribute fields instead of FaceFlags
refs #1991

Change-Id: I413db0afd77ceaa1549fcd11d6cb832fff02020b
2014-10-11 10:32:30 -06:00
Tai-Lin Chu 6687aabbc2 mgmt: allow omitted FaceId in faces/create command
Change-Id: I27655e8b7e67dce88e787a0b4b18fe34cafbf5d5
Refs: #2031
2014-10-09 18:18:22 -07:00
Junxiao Shi 8bfd56d051 fw: NccStrategy proper detection for new PIT entry
A PIT entry during straggler timer should be treated as new PIT entry
for strategy purposes.

refs #1971

Change-Id: I1156630ac0635f8e311a4f18400c5d7b535e3f20
2014-10-09 16:57:11 -07:00
Junxiao Shi 15539105df fw: optimize FwNccStrategy/FavorRespondingUpstream test case
This test case previously relies on precise timing, and the slack is 3ms
in the worst case. Failure rate is high if system is slow.
This commit optimizes this tests case with several operation-limited
io runs, so that it doesn't rely on precise timing.

refs #2037

Change-Id: I80b87d830dcf8d87fce511e79eb9349f75c1c34d
2014-10-09 16:13:00 -07:00
Chengyu Fan f9c2bb19fe mgmt: replace FaceFlags with individual fields
refs #1992

Change-Id: I41d55b3227c916a253705aaeefbe66c7c18e22a9
2014-10-08 21:56:38 -06:00
Steve DiBenedetto 77c8751576 mgmt: update strategy-choice/set to return a versioned strategy name
refs: #1972

Change-Id: I1616574a4643884dac050d240b771423ec2a0846
2014-10-08 11:53:53 -07:00
Steve DiBenedetto b4336c2e0a test: move general config section test to tests/daemon/mgmt
refs: #1997

Change-Id: I9639226825d2145c5ffe7724ed52743c5b492a14
2014-10-08 11:29:24 -07:00
Junxiao Shi 0e42c574ed table: dead Nonce list
refs #1953

Change-Id: I65eb2346716dd47bcf1850c832e37e5354042fd0
2014-10-07 16:32:51 -07:00
Wentao Shang 98733147f5 face: detect websocket connection failure using ping/pong messages.
Change-Id: I66ef6a3921a56f1bb8e49fb6fdb4fa14b6a379c7
Refs: #1903
2014-10-05 14:57:46 -07:00
Wentao Shang b1c1a83db3 face: update websocketpp submodule to version 0.3.0
Change-Id: Ifc92b49a92cf7c76d1751105abf35ab9da6bfd8f
Refs: #1903
2014-10-01 12:26:35 -07:00
Alexander Afanasyev 60d06387da table: Remove operator== for Exclude, which is now a part of the library
Change-Id: I7b6d80cff6200e2c7d7d8529d2736bc275f1b6e7
2014-09-22 07:38:03 -07:00
Junxiao Shi e93d6a3401 table: allow strategy versioning
refs #1893

Change-Id: I44eb8dd319d737d786b6ce6f753ae2f9076cf9c1
2014-09-08 14:09:01 -07:00
Junxiao Shi 82e7f58c4f fw: NccStrategy remembers only best face
refs #1961

Strategy::beforeSatisfyPendingInterest is renamed to
Strategy::beforeSatisfyInterest, so as to match the semantics of this trigger.
This is a backwards-incompatible change that requires function renaming in
all subclasses of Strategy class.

LimitedIo::afterOp gets a bugfix that allows it to be invoked out of
LimitedIo::run without leaving io_service unusable.

Change-Id: Ia4c632beb62c554724b83846a3d6358ae08779ad
2014-09-07 15:21:02 -07:00
Alexander Afanasyev 3b21fa3258 build: Fix build error with python3
Change-Id: Ie90c6a9856b2616131ff9c0c3916aede1978ea94
Refs: #1302
2014-09-02 19:43:10 -07:00
Alexander Afanasyev c2642ca20c tools: Small formatting correction in plain text output of nfd-status
Change-Id: I7657d10ce91ce7f90d264296e69b87179c08c1a7
2014-09-02 18:54:31 -07:00
Yingdi Yu 7b0e9cf792 tools: Publish /localhop/ndn-autoconf/routable-prefixes from ndn-autoconfig-server
Change-Id: I2902b91cebf1f4b8ac1a7dabedb0f0cbd0a13b24
Refs: #1954
2014-09-02 11:01:24 -07:00
Davide Pesavento 3f5655fce5 face: Fix spurious assertion failure in StreamFace
Change-Id: Id487ae8d01ab3dc0ffa647dc69ff594f8a1d3c12
Refs: #1856
2014-08-30 21:45:23 +02:00
Alexander Afanasyev 86bc91ae56 face: Allow trailing slash for UDP and TCP FaceUri's
Change-Id: I472bfdaf1e032f70dbba24a0d5a3117f198a526d
Refs: #1944
2014-08-28 22:29:16 -07:00
Alexander Afanasyev 2075788ffc docs: Update to generate proper google analytics code
This commit also includes minor doxygen style improvement.

Change-Id: I5ced859c0759a2fd0240068296949067f9ac4c46
2014-08-26 13:52:52 -07:00
Steve DiBenedetto 62a939462e doc: streamline NFD homepage and README documentation
refs: #1905

Change-Id: I7e03c05467cadd440efc0e0b1deb3abac930fd78
2014-08-24 19:34:38 -07:00
Alexander Afanasyev 186c316dfe docs: Updated release notes
Change-Id: I4c56a4ed41fc186b44e6ad284c7a9c18a82889ba
2014-08-24 13:07:00 -07:00
Alexander Afanasyev e918621ca8 build: Disable Ethernet face support on OSX with Boost 1.56
Change-Id: Ib3415d5fa1d64e76877bb0f1dcfda783cfe47ca7
Refs: #1877
2014-08-24 13:06:52 -07:00
Alexander Afanasyev 48f5a3ca47 build: Enable detailed version information when built from shallow clone or tarball
Change-Id: Ie2cc05687f4bce136451d316f32e9bab3e82844a
Refs: #1915
2014-08-23 20:02:05 -07:00
Junxiao Shi 986b8497c6 fw: Best Route Strategy version 2
refs #1871

Change-Id: I196a5ff0839f72caf9210af61ad54066242ba9c2
2014-08-23 07:26:28 -07:00
Vince Lehman 26b215c603 rib: Add periodic invalid face clean up
refs: #1744, #1875

Change-Id: I4e6780ef6abb95b2c4ad7c1e6291897693cb551a
2014-08-21 16:14:01 -05:00
Vince Lehman 281ded753b rib: Cancel expiration on unregistration
refs: #1902

Change-Id: I85a75370ecc3677c8a9ebf3a48f3c0857598da2d
2014-08-21 14:51:13 -05:00
Chengyu Fan 1c630ba026 tools: display RIB flags by name in nfd-status page
refs #1870

Change-Id: I327ef9a672dc845f814930c818982fa2700f6402
2014-08-20 13:27:58 -05:00
Junxiao Shi ad3f1cbc87 fw: when Interest matches CS, set straggler timer on PIT entry
refs #1882

Change-Id: I2291783ff3175912ab646fabf247e29dba530e25
2014-08-18 14:05:48 -07:00
Vince Lehman bc05b761a4 rib: Log individual FIB updates
refs: #1868

Change-Id: I400d9bed369c7c27237c2ebd7f3c31865b5c9853
2014-08-18 11:58:15 -05:00
Chengyu Fan 671796414b tools: display face flags and expiration in nfd-status page
refs #1862

Change-Id: I62919316ee503a8a6b816bdce995c693c3b436d2
2014-08-16 17:49:44 -06:00
Alexander Afanasyev 6a75b763f4 build: Do not warn about C99 extensions
Change-Id: I21317771b43bfd3a6d3e1c5a3067e6ff6dc19f9d
Refs: #1865
2014-08-14 19:49:36 -07:00
Alexander Afanasyev f056c11fd4 tools: Process auto-registration for faces that existed prior to start of nfd-autoreg
Change-Id: I3848f1a20a0d816258759f95d427cf91cb3b9713
Refs: #1863
2014-08-14 17:21:40 -07:00
Alexander Afanasyev 81c1a2a267 tools: Enable "all-faces-prefix" option to register prefix for all face (on-demand and non-on-demand)
Change-Id: I6f2e894f2b46ba80c33c501623e47ca08a294795
Refs: #1861
2014-08-14 16:50:21 -07:00
Chengyu Fan a55663d729 tools: fixing bug of misleading lifetime and plural time unit for RIB in HTTP status page
refs #1854 #1855

Change-Id: Ifa112a88210e7882120f529f8c5c3f524d85aa03
2014-08-14 16:50:10 -07:00
Davide Pesavento 4c1a0786db face: increment link layer byte counters in EthernetFace
refs #1780

Change-Id: I27b9c19ef70b976c83f35bcd569dc7eb7f9802cd
2014-08-14 11:13:53 -07:00
Alexander Afanasyev 483efd1668 rib: Disable FaceId check for self-registrations
Change-Id: I9e022d3067c5c4ecb3ec0a10a4446e9af49c68eb
Refs: #1852
2014-08-14 10:51:18 -07:00
Junxiao Shi cbb490a6de fw: NccStrategy always sets pitEntryEntry->maxInterval
Change-Id: I675745cbd40e8d9c6651e6a728deb194ff37d189
refs: #1853
2014-08-13 12:24:24 -07:00
Alexander Afanasyev 585e5a6ff8 rib+tools: Make use of ndn::nfd::FaceMonitor from the ndn-cxx library
NFD still uses its own NotificationStream, as ApiFace needs to be
changed to use library's version of the class.

Change-Id: Ifc5727a555528a1aa48ccf7379fcbb61a33049d7
2014-08-12 11:50:17 -07:00
Junxiao Shi 15b12e759d core: use markers in StatusDataset and NotificationStream
This commit also refactors FaceMonitor as generic NotificationSubscriber,
and refactors AutoregServer to use FaceMonitor.

refs #1837 #1838

Change-Id: I8b40dfae118853d1224c8290cf92e7cc0daa116f
2014-08-10 19:23:09 -07:00
Alexander Afanasyev b3033247ee table: Fix segfault during Fib::removeNextHopFromAllEntries
Change-Id: I905a3c0da2f2a9197942cfeba7fd698b779e6e4a
Refs: #1816
2014-08-08 16:09:44 -07:00
Vince Lehman cd613c5008 rib: Verify face before route registration
refs: #1811

Change-Id: If99f59734b29a46eca4f6139d35361a8563a9010
2014-08-07 14:35:29 -07:00
Wentao Shang e612e2f9bf face: increment link layer byte counters in WebSocketFace
Change-Id: I88b7dea1cbd291765345982ce193700aacd73eb3
Refs: #1781
2014-08-04 17:40:51 -07:00
Chengyu Fan 8a53caf629 tools: include the key name in keylocator as the NFD id in nfd-status
refs #1807

Change-Id: I28f17c459efb720f957f33a6fc27a55edde719ea
2014-08-03 22:52:27 -06:00
777 changed files with 85475 additions and 48867 deletions

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
Dockerfile
/build/
.waf-*-*/
.waf3-*-*/
.lock-waf*
/VERSION.info
+21
View File
@@ -0,0 +1,21 @@
name: CI
on:
push:
paths-ignore:
- 'docs/**'
- '*.conf.sample*'
- '*.md'
- '.mailmap'
workflow_dispatch:
permissions: {}
jobs:
Ubuntu:
uses: named-data/actions/.github/workflows/jenkins-script-ubuntu.yml@v1
with:
submodules: true
macOS:
uses: named-data/actions/.github/workflows/jenkins-script-macos.yml@v1
with:
submodules: true
+81
View File
@@ -0,0 +1,81 @@
name: Publish Docker image
on:
push:
branches:
- master
paths-ignore:
- '*.md'
- '.mailmap'
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
nfd:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/nfd
flavor: latest=true
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
pull: true
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
nfd-status-http-server:
needs: nfd
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/nfd-status-http-server
flavor: latest=true
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./tools
file: ./tools/Dockerfile.nfd-status-http-server
pull: true
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+24
View File
@@ -0,0 +1,24 @@
name: Docs
on:
push:
workflow_dispatch:
inputs:
skip-deploy:
description: 'Skip deployment?'
required: true
type: boolean
permissions: {}
jobs:
html:
uses: named-data/actions/.github/workflows/docs-html.yml@v1
with:
submodules: true
# Deploy only the master branch and release tags
deploy: ${{ !inputs.skip-deploy && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/NFD-')) }}
secrets: inherit
man:
uses: named-data/actions/.github/workflows/docs-man.yml@v1
with:
submodules: true
+28 -6
View File
@@ -1,7 +1,29 @@
.DS*
.waf-1*
.waf3-*
.lock*
**/*.pyc
build/
# Emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
.\#*
# Visual Studio Code
.vscode/
# macOS
.DS_Store
.AppleDouble
.LSOverride
._*
# Waf build system
/build/
.waf-*-*/
.waf3-*-*/
.lock-waf*
# Compiled python code
__pycache__/
*.py[cod]
# Other
/VERSION.info
+1 -1
View File
@@ -1,3 +1,3 @@
[submodule "websocketpp"]
path = websocketpp
url = https://github.com/zaphoyd/websocketpp.git
url = https://github.com/cawka/websocketpp.git
Executable
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -eo pipefail
case $(uname) in
Linux)
if [[ -e /etc/os-release ]]; then
source /etc/os-release
else
source /usr/lib/os-release
fi
export ID VERSION_ID
export ID_LIKE="${ID} ${ID_LIKE} linux"
export PATH="${HOME}/.local/bin${PATH:+:}${PATH}"
;;
Darwin)
# Emulate a subset of os-release(5)
export ID=macos
export VERSION_ID=$(sw_vers -productVersion)
export PATH="/usr/local/bin${PATH:+:}${PATH}"
if [[ -x /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -x /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
;;
esac
export CACHE_DIR=${CACHE_DIR:-/tmp}
if [[ $JOB_NAME == *"code-coverage" ]]; then
export DISABLE_ASAN=yes
export DISABLE_HEADERS_CHECK=yes
fi
# https://reproducible-builds.org/docs/source-date-epoch/
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
for file in .jenkins.d/*; do
[[ -f $file && -x $file ]] || continue
if [[ -n $GITHUB_ACTIONS ]]; then
label=$(basename "$file" | sed -E 's/[[:digit:]]+-(.*)\..*/\1/')
echo "::group::${label}"
fi
echo "\$ $file"
"$file"
if [[ -n $GITHUB_ACTIONS ]]; then
echo "::endgroup::"
fi
done
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -eo pipefail
APT_PKGS=(build-essential pkg-config python3-minimal
libboost-all-dev libssl-dev libsqlite3-dev
libpcap-dev libsystemd-dev)
FORMULAE=(boost openssl pkg-config)
PIP_PKGS=()
case $JOB_NAME in
*code-coverage)
APT_PKGS+=(lcov python3-pip)
PIP_PKGS+=('gcovr~=5.2')
;;
*Docs)
APT_PKGS+=(doxygen graphviz python3-pip)
FORMULAE+=(doxygen graphviz)
PIP_PKGS+=(sphinx sphinxcontrib-doxylink)
;;
esac
set -x
if [[ $ID == macos ]]; then
if [[ -n $GITHUB_ACTIONS ]]; then
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
fi
brew update
brew install --formula "${FORMULAE[@]}"
elif [[ $ID_LIKE == *debian* ]]; then
sudo apt-get -qq update
sudo apt-get -qy install "${APT_PKGS[@]}"
elif [[ $ID_LIKE == *fedora* ]]; then
sudo dnf -y install gcc-c++ libasan lld pkgconf-pkg-config python3 \
boost-devel openssl-devel sqlite-devel \
libpcap-devel systemd-devel
fi
if (( ${#PIP_PKGS[@]} )); then
pip3 install --user --upgrade --upgrade-strategy=eager "${PIP_PKGS[@]}"
fi
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -exo pipefail
pushd "$CACHE_DIR" >/dev/null
INSTALLED_VERSION=
if [[ $ID == macos ]]; then
BOOST=$(brew list --formula --versions boost)
OLD_BOOST=$(cat boost.txt || :)
if [[ $OLD_BOOST != $BOOST ]]; then
echo "$BOOST" > boost.txt
INSTALLED_VERSION=NONE
fi
fi
if [[ -z $INSTALLED_VERSION ]]; then
INSTALLED_VERSION=$(git -C ndn-cxx rev-parse HEAD 2>/dev/null || echo NONE)
fi
sudo rm -rf ndn-cxx-latest
git clone --depth 1 https://github.com/named-data/ndn-cxx.git ndn-cxx-latest
LATEST_VERSION=$(git -C ndn-cxx-latest rev-parse HEAD 2>/dev/null || echo UNKNOWN)
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
sudo rm -rf ndn-cxx
mv ndn-cxx-latest ndn-cxx
else
sudo rm -rf ndn-cxx-latest
fi
sudo rm -f /usr/local/bin/ndnsec*
sudo rm -fr /usr/local/include/ndn-cxx
sudo rm -f /usr/local/lib{,64}/libndn-cxx*
sudo rm -f /usr/local/lib{,64}/pkgconfig/libndn-cxx.pc
pushd ndn-cxx >/dev/null
./waf --color=yes configure --without-osx-keychain
./waf --color=yes build
sudo ./waf --color=yes install
popd >/dev/null
popd >/dev/null
if [[ $ID_LIKE == *fedora* ]]; then
sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64
fi
if [[ $ID_LIKE == *linux* ]]; then
sudo ldconfig
fi
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -eo pipefail
if [[ -z $DISABLE_ASAN ]]; then
ASAN="--with-sanitizer=address"
fi
if [[ $JOB_NAME == *"code-coverage" ]]; then
COVERAGE="--with-coverage"
fi
if [[ -n $DISABLE_PCH ]]; then
PCH="--without-pch"
fi
set -x
if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
# Build in release mode with tests and without precompiled headers
./waf --color=yes configure --with-tests --without-pch
./waf --color=yes build
# Cleanup
./waf --color=yes distclean
# Build in release mode without tests, but with "other tests"
./waf --color=yes configure --with-other-tests $PCH
./waf --color=yes build
# Cleanup
./waf --color=yes distclean
fi
# Build in debug mode with tests
./waf --color=yes configure --debug --with-tests $ASAN $COVERAGE $PCH
./waf --color=yes build
# (tests will be run against the debug version)
# Install
sudo ./waf --color=yes install
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -eo pipefail
# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
ASAN_OPTIONS="color=always"
ASAN_OPTIONS+=":check_initialization_order=1"
ASAN_OPTIONS+=":detect_stack_use_after_return=1"
ASAN_OPTIONS+=":strict_init_order=1"
ASAN_OPTIONS+=":strict_string_checks=1"
ASAN_OPTIONS+=":detect_invalid_pointer_pairs=2"
ASAN_OPTIONS+=":detect_container_overflow=0"
ASAN_OPTIONS+=":detect_leaks=0"
ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
export ASAN_OPTIONS
# https://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/runtime_config/summary.html
export BOOST_TEST_BUILD_INFO=1
export BOOST_TEST_COLOR_OUTPUT=1
export BOOST_TEST_DETECT_MEMORY_LEAK=0
ut_log_args() {
echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-log${1:+-$1}.xml
}
set -x
# Prepare environment
rm -rf ~/.ndn
# First run all tests as unprivileged user
./build/unit-tests-core $(ut_log_args core)
./build/unit-tests-daemon $(ut_log_args daemon)
./build/unit-tests-rib $(ut_log_args rib)
./build/unit-tests-tools $(ut_log_args tools)
# Then use sudo to run those tests that need superuser powers
sudo --preserve-env=ASAN_OPTIONS,BOOST_TEST_COLOR_OUTPUT \
./build/unit-tests-daemon -t TestPrivilegeHelper $(ut_log_args daemon-privilege-helper)
sudo --preserve-env=ASAN_OPTIONS,BOOST_TEST_COLOR_OUTPUT \
./build/unit-tests-daemon -t Face/*Ethernet* $(ut_log_args daemon-ethernet)
sudo --preserve-env=ASAN_OPTIONS,BOOST_TEST_COLOR_OUTPUT \
./build/unit-tests-daemon -t Face/TestUdpFactory $(ut_log_args daemon-udp)
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -exo pipefail
if [[ $JOB_NAME == *"code-coverage" ]]; then
# Generate an XML report (Cobertura format) and a detailed HTML report using gcovr
# Note: trailing slashes are important in the paths below. Do not remove them!
gcovr --object-directory build \
--exclude tests/ \
--exclude websocketpp/ \
--exclude-throw-branches \
--exclude-unreachable-branches \
--cobertura build/coverage.xml \
--html-details build/gcovr/ \
--print-summary
# Generate a detailed HTML report using lcov
lcov --quiet \
--capture \
--directory . \
--exclude "$PWD/tests/*" \
--exclude "$PWD/websocketpp/*" \
--no-external \
--rc lcov_branch_coverage=1 \
--output-file build/coverage.info
genhtml --branch-coverage \
--demangle-cpp \
--legend \
--output-directory build/lcov \
--title "NFD unit tests" \
build/coverage.info
fi
+36
View File
@@ -0,0 +1,36 @@
# Continuous Integration Scripts
## Environment Variables
- `ID`: lower-case string that identifies the operating system, for example: `ID=ubuntu`,
`ID=centos`. See [os-release(5)] for more information. On macOS, where `os-release` is
not available, we emulate it by setting `ID=macos`.
- `ID_LIKE`: space-separated list of operating system identifiers that are closely related
to the running OS. See [os-release(5)] for more information. The listed values are used
by the CI scripts to select the proper behavior for different platforms and OS flavors.
Examples:
- On CentOS, `ID_LIKE="centos rhel fedora linux"`
- On Ubuntu, `ID_LIKE="ubuntu debian linux"`
- `VERSION_ID`: identifies the operating system version, excluding any release code names.
See [os-release(5)] for more information. Examples: `VERSION_ID=42`, `VERSION_ID=22.04`.
- `JOB_NAME`: defines the type of the current CI job. Depending on the job type, the CI
scripts can perform different tasks.
Supported values:
- empty: default build task
- `code-coverage`: debug build with tests and code coverage analysis
- `limited-build`: only a single debug build with tests
- `CACHE_DIR`: directory containing cached files from previous builds, e.g., a compiled
version of ndn-cxx. If not set, `/tmp` is used.
- `DISABLE_ASAN`: disable building with AddressSanitizer. This is automatically set for
the `code-coverage` job type.
[os-release(5)]: https://www.freedesktop.org/software/systemd/man/os-release.html
+16
View File
@@ -0,0 +1,16 @@
<aa@cs.fiu.edu> <alexander.afanasyev@ucla.edu>
Alexander Lane <awlane@memphis.edu>
<chghasemi@cs.arizona.edu> <chavoosh.ghasemi@gmail.com>
<davidepesa@gmail.com> <davide.pesavento@lip6.fr>
<enewberry@email.arizona.edu> <enewberry@cs.arizona.edu>
Haowei Yuan <hyuan@wustl.edu>
Hila Ben Abraham <hilata@gmail.com>
<lybmath2009@gmail.com> <lybmath@ucla.edu>
Md Ashiqur Rahman <marahman@email.arizona.edu>
Minsheng Zhang <jimmyzms5@gmail.com>
Spyridon Mastorakis <spiros.mastorakis@gmail.com>
Susmit Shannigrahi <susmit@cs.colostate.edu>
Tai-Lin Chu <tailinchu@gmail.com>
<tuyukai1994@gmail.com> <tyk@bupt.edu.cn>
Vince Lehman <vslehman@memphis.edu> <vlehman1@gmail.com>
Yumin Xia <me@yumin-xia.com>
-43
View File
@@ -1,43 +0,0 @@
# For Ubuntu only
language: cpp
os:
- linux
compiler:
- gcc
notifications:
email:
on_success: always
on_failure: always
before_install:
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install -qq libssl-dev libpcap-dev libboost1.48-all-dev libcrypto++-dev libsqlite3-dev
- travis_retry git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx
- cd ndn-cxx
- ./waf configure
- ./waf -j1
- sudo ./waf install
- sudo ldconfig
- cd ..
- ndnsec-keygen /tmp/key | ndnsec-install-cert -
script:
- ./waf configure --with-tests
- ./waf -j1
- sudo ./waf install
- ./build/unit-tests-core
- ./build/unit-tests-daemon
- ./build/unit-tests-rib
# Tutorial for setting up notifications:
# http://docs.travis-ci.com/user/notifications/
# Here's a simple example for email notifications:
#
# notifications:
# email:
# recipients:
# - one@example.com
# - other@example.com
# on_success: [always|never|change] # default: change
# on_failure: [always|never|change] # default: always
#
# There are also other types of notifications available, including:
# IRC, Campfire, Flowdock, HipChat, and Webhook.
# For more infomation about notifications, please visit the link above.
+252 -97
View File
@@ -30,15 +30,15 @@ When using this tool, the wscript will look like:
Options are generated, in order to specify the location of boost includes/libraries.
The `check_boost` configuration function allows to specify the used boost libraries.
It can also provide default arguments to the --boost-static and --boost-mt command-line arguments.
It can also provide default arguments to the --boost-mt command-line arguments.
Everything will be packaged together in a BOOST component that you can use.
When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
- you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
Errors: C4530
- boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
So before calling `conf.check_boost` you might want to disabling by adding:
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
So before calling `conf.check_boost` you might want to disabling by adding
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
Errors:
- boost might also be compiled with /MT, which links the runtime statically.
If you have problems with redefined symbols,
@@ -52,24 +52,60 @@ import sys
import re
from waflib import Utils, Logs, Errors
from waflib.Configure import conf
from waflib.TaskGen import feature, after_method
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/homebrew/lib', '/opt/local/lib', '/sw/lib', '/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/homebrew/include', '/opt/local/include', '/sw/include']
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu', '/usr/local/ndn/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include', '/usr/local/ndn/include']
BOOST_VERSION_FILE = 'boost/version.hpp'
BOOST_VERSION_CODE = '''
#include <iostream>
#include <boost/version.hpp>
int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
'''
BOOST_SYSTEM_CODE = '''
BOOST_ERROR_CODE = '''
#include <boost/system/error_code.hpp>
int main() { boost::system::error_code c; }
'''
PTHREAD_CODE = '''
#include <pthread.h>
static void* f(void*) { return 0; }
int main() {
pthread_t th;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&th, &attr, &f, 0);
pthread_join(th, 0);
pthread_cleanup_push(0, 0);
pthread_cleanup_pop(0);
pthread_attr_destroy(&attr);
}
'''
BOOST_THREAD_CODE = '''
#include <boost/thread.hpp>
int main() { boost::thread t; }
'''
BOOST_LOG_CODE = '''
#include <boost/log/trivial.hpp>
int main() { BOOST_LOG_TRIVIAL(info) << "boost_log is working"; }
'''
BOOST_LOG_SETUP_CODE = '''
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
int main() {
using namespace boost::log;
add_common_attributes();
add_console_log(std::clog, keywords::format = "%Message%");
BOOST_LOG_TRIVIAL(info) << "boost_log_setup is working";
}
'''
# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
PLATFORM = Utils.unversioned_sys_platform()
detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
@@ -101,34 +137,37 @@ BOOST_TOOLSETS = {
def options(opt):
opt = opt.add_option_group('Boost Options')
opt.add_option('--boost-includes', type='string',
default='', dest='boost_includes',
help='''path to the directory where the boost includes are, e.g., /path/to/boost_1_55_0/stage/include''')
help='''path to the directory where the boost includes are,
e.g., /path/to/boost_1_55_0/stage/include''')
opt.add_option('--boost-libs', type='string',
default='', dest='boost_libs',
help='''path to the directory where the boost libs are, e.g., /path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-static', action='store_true',
default=False, dest='boost_static',
help='link with static boost libraries (.lib/.a)')
help='''path to the directory where the boost libs are,
e.g., path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-mt', action='store_true',
default=False, dest='boost_mt',
help='select multi-threaded libraries')
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
help='''select libraries with tags (dgsyp, d for debug), see doc Boost, Getting Started, chapter 6.1''')
opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
help='''select libraries with tags (gd for debug, static is automatically added),
see doc Boost, Getting Started, chapter 6.1''')
opt.add_option('--boost-linkage_autodetect', action='store_true', dest='boost_linkage_autodetect',
help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
opt.add_option('--boost-toolset', type='string',
default='', dest='boost_toolset',
help='force a toolset e.g. msvc, vc90, gcc, mingw, mgw45 (default: auto)')
help='force a toolset e.g. msvc, vc90, \
gcc, mingw, mgw45 (default: auto)')
py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
opt.add_option('--boost-python', type='string',
default=py_version, dest='boost_python',
help='select the lib python with this version (default: %s)' % py_version)
help='select the lib python with this version \
(default: %s)' % py_version)
@conf
def __boost_get_version_file(self, d):
if not d:
return None
dnode = self.root.find_dir(d)
if dnode:
return dnode.find_node(BOOST_VERSION_FILE)
@@ -141,33 +180,30 @@ def boost_get_version(self, d):
if node:
try:
txt = node.read()
except (OSError, IOError):
Logs.error("Could not read the file %r" % node.abspath())
except EnvironmentError:
Logs.error('Could not read the file %r' % node.abspath())
else:
re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
m1 = re_but1.search(txt)
re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d+)', re.M)
m2 = re_but2.search(txt)
if m1 and m2:
return (m1.group(1), m2.group(1))
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(':')
@conf
def boost_get_includes(self, *k, **kw):
includes = k and k[0] or kw.get('includes', None)
if includes and self.__boost_get_version_file(includes):
return includes
for d in Utils.to_list(self.environ.get('INCLUDE', '')) + BOOST_INCLUDES:
for d in self.environ.get('INCLUDE', '').split(';') + BOOST_INCLUDES:
if self.__boost_get_version_file(d):
return d
if includes:
self.end_msg('headers not found in %s' % includes)
self.end_msg('headers not found in %s' % includes, 'YELLOW')
self.fatal('The configuration failed')
else:
self.end_msg('headers not found, please provide a --boost-includes argument (see help)')
self.end_msg('headers not found, please provide a --boost-includes argument (see help)', 'YELLOW')
self.fatal('The configuration failed')
@@ -195,7 +231,9 @@ def __boost_get_libs_path(self, *k, **kw):
path = self.root.find_dir(libs)
files = path.ant_glob('*boost_*')
if not libs or not files:
for d in Utils.to_list(self.environ.get('LIB', [])) + BOOST_LIBS:
for d in self.environ.get('LIB', '').split(';') + BOOST_LIBS:
if not d:
continue
path = self.root.find_dir(d)
if path:
files = path.ant_glob('*boost_*')
@@ -208,10 +246,10 @@ def __boost_get_libs_path(self, *k, **kw):
break
if not path:
if libs:
self.end_msg('libs not found in %s' % libs)
self.end_msg('libs not found in %s' % libs, 'YELLOW')
self.fatal('The configuration failed')
else:
self.end_msg('libs not found, please provide a --boost-libs argument (see help)')
self.end_msg('libs not found, please provide a --boost-libs argument (see help)', 'YELLOW')
self.fatal('The configuration failed')
self.to_log('Found the boost path in %r with the libraries:' % path)
@@ -226,15 +264,10 @@ def boost_get_libs(self, *k, **kw):
according to the parameters
'''
path, files = self.__boost_get_libs_path(**kw)
t = []
if kw.get('mt', False):
t.append('mt')
if kw.get('abi', None):
t.append(kw['abi'])
tags = t and '(-%s)+' % '-'.join(t) or ''
files = sorted(files, key=lambda f: (len(f.name), f.name), reverse=True)
toolset = self.boost_get_toolset(kw.get('toolset', ''))
toolset_pat = '(-%s[0-9]{0,3})+' % toolset
version = '(-%s)+' % self.env.BOOST_VERSION
toolset_pat = '(-%s[0-9]{0,3})' % toolset
version = '-%s' % self.env.BOOST_VERSION
def find_lib(re_lib, files):
for file in files:
@@ -248,28 +281,109 @@ def boost_get_libs(self, *k, **kw):
name = name[3:]
return name[:name.rfind('.')]
libs = []
for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
# Trying libraries, from most strict match to least one
for pattern in ['boost_%s%s%s%s%s' % (lib, toolset_pat, tags, py, version),
'boost_%s%s%s%s' % (lib, tags, py, version),
'boost_%s%s%s' % (lib, tags, version),
# Give up trying to find the right version
'boost_%s%s%s%s' % (lib, toolset_pat, tags, py),
'boost_%s%s%s' % (lib, tags, py),
'boost_%s%s' % (lib, tags)]:
self.to_log('Trying pattern %s' % pattern)
file = find_lib(re.compile(pattern), files)
if file:
libs.append(format_lib_name(file.name))
break
else:
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
self.fatal('The configuration failed')
def match_libs(lib_names, is_static):
libs = []
lib_names = Utils.to_list(lib_names)
if not lib_names:
return libs
t = []
if kw.get('mt', False):
t.append('-mt')
if kw.get('abi', None):
t.append('%s%s' % (is_static and '-s' or '-', kw['abi']))
elif is_static:
t.append('-s')
tags_pat = t and ''.join(t) or ''
ext = is_static and self.env.cxxstlib_PATTERN or self.env.cxxshlib_PATTERN
ext = ext.partition('%s')[2] # remove '%s' or 'lib%s' from PATTERN
return path.abspath(), libs
for lib in lib_names:
if lib == 'python':
# for instance, with python='27',
# accepts '-py27', '-py2', '27' and '2'
# but will reject '-py3', '-py26', '26' and '3'
tags = '({0})?((-py{2})|(-py{1}(?=[^0-9]))|({2})|({1}(?=[^0-9]))|(?=[^0-9])(?!-py))'.format(tags_pat, kw['python'][0], kw['python'])
else:
tags = tags_pat
# Trying libraries, from most strict match to least one
for pattern in ['boost_%s%s%s%s%s$' % (lib, toolset_pat, tags, version, ext),
'boost_%s%s%s%s$' % (lib, tags, version, ext),
# Give up trying to find the right version
'boost_%s%s%s%s$' % (lib, toolset_pat, tags, ext),
'boost_%s%s%s$' % (lib, tags, ext),
'boost_%s%s$' % (lib, ext),
'boost_%s' % lib]:
self.to_log('Trying pattern %s' % pattern)
file = find_lib(re.compile(pattern), files)
if file:
libs.append(format_lib_name(file.name))
break
else:
self.end_msg('lib %s not found in %s' % (lib, path.abspath()), 'YELLOW')
self.fatal('The configuration failed')
return libs
return path.abspath(), match_libs(kw.get('lib', None), False), match_libs(kw.get('stlib', None), True)
@conf
def _check_pthread_flag(self, *k, **kw):
'''
Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode
Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
boost/thread.hpp will trigger a #error if -pthread isn't used:
boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
is not turned on. Please set the correct command line options for
threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
'''
var = kw.get('uselib_store', 'BOOST')
self.start_msg('Checking the flags needed to use pthreads')
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# (none): in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -lpthreads: AIX (must check this before -lpthread)
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
# -pthreads: Solaris/GCC
# -mthreads: MinGW32/GCC, Lynx/GCC
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# -lpthread: GNU Linux, etc.
# --thread-safe: KAI C++
if Utils.unversioned_sys_platform() == 'sunos':
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
boost_pthread_flags = ['-pthreads', '-lpthread', '-mt', '-pthread']
else:
boost_pthread_flags = ['', '-lpthreads', '-Kthread', '-kthread', '-llthread', '-pthread',
'-pthreads', '-mthreads', '-lpthread', '--thread-safe', '-mt']
for boost_pthread_flag in boost_pthread_flags:
try:
self.env.stash()
self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False, quiet=True)
self.end_msg(boost_pthread_flag)
return
except self.errors.ConfigurationError:
self.env.revert()
self.end_msg('none')
@conf
def check_boost(self, *k, **kw):
@@ -282,7 +396,10 @@ def check_boost(self, *k, **kw):
if not self.env['CXX']:
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
params = {'lib': k and k[0] or kw.get('lib', None)}
params = {
'lib': k and k[0] or kw.get('lib', None),
'stlib': kw.get('stlib', None)
}
for key, value in self.options.__dict__.items():
if not key.startswith('boost_'):
continue
@@ -291,48 +408,70 @@ def check_boost(self, *k, **kw):
var = kw.get('uselib_store', 'BOOST')
self.start_msg('Checking boost includes')
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
versions = self.boost_get_version(inc)
self.env.BOOST_VERSION = versions[0]
self.env.BOOST_VERSION_NUMBER = int(versions[1])
self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
int(versions[1]) / 100 % 1000,
int(versions[1]) % 100))
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
if not self.env.DONE_FIND_BOOST_COMMON:
self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
if self.env.DPKG_ARCHITECTURE:
deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())
if not params['lib']:
self.start_msg('Checking boost includes')
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
versions = self.boost_get_version(inc)
self.env.BOOST_VERSION = versions[0]
self.env.BOOST_VERSION_NUMBER = int(versions[1])
self.end_msg('%d.%d.%d' % (int(versions[1]) / 100000,
int(versions[1]) / 100 % 1000,
int(versions[1]) % 100))
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
self.env.DONE_FIND_BOOST_COMMON = True
if not params['lib'] and not params['stlib']:
return
if 'static' in kw or 'static' in params:
Logs.warn('boost: static parameter is deprecated, use stlib instead.')
self.start_msg('Checking boost libs')
suffix = params.get('static', None) and 'ST' or ''
path, libs = self.boost_get_libs(**params)
self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
self.env['%sLIB_%s' % (suffix, var)] = libs
self.end_msg('ok')
path, libs, stlibs = self.boost_get_libs(**params)
self.env['LIBPATH_%s' % var] = [path]
self.env['STLIBPATH_%s' % var] = [path]
self.env['LIB_%s' % var] = libs
self.env['STLIB_%s' % var] = stlibs
self.end_msg(' '.join(libs + stlibs))
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % path)
Logs.pprint('CYAN', ' libs : %s' % libs)
Logs.pprint('CYAN', ' shared libs : %s' % libs)
Logs.pprint('CYAN', ' static libs : %s' % stlibs)
def has_shlib(lib):
return params['lib'] and lib in params['lib']
def has_stlib(lib):
return params['stlib'] and lib in params['stlib']
def has_lib(lib):
return has_shlib(lib) or has_stlib(lib)
if has_lib('thread'):
# not inside try_link to make check visible in the output
self._check_pthread_flag(k, kw)
def try_link():
if 'system' in params['lib']:
self.check_cxx(
fragment=BOOST_SYSTEM_CODE,
use=var,
execute=False,
)
if 'thread' in params['lib']:
self.check_cxx(
fragment=BOOST_THREAD_CODE,
use=var,
execute=False,
)
if has_lib('system'):
self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
if has_lib('thread'):
self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
if has_lib('log') or has_lib('log_setup'):
if not has_lib('thread'):
self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
if has_shlib('log') or has_shlib('log_setup'):
self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
if has_lib('log_setup'):
self.check_cxx(fragment=BOOST_LOG_SETUP_CODE, use=var, execute=False)
else:
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
if params.get('linkage_autodetect', False):
self.start_msg("Attempting to detect boost linkage flags")
self.start_msg('Attempting to detect boost linkage flags')
toolset = self.boost_get_toolset(kw.get('toolset', ''))
if toolset in ['vc']:
if toolset in ('vc',):
# disable auto-linking feature, causing error LNK1181
# because the code wants to be linked against
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
@@ -352,27 +491,43 @@ def check_boost(self, *k, **kw):
# we attempt to play with some known-to-work CXXFLAGS combinations
for cxxflags in (['/MD', '/EHsc'], []):
self.env.stash()
self.env["CXXFLAGS_%s" % var] += cxxflags
self.env['CXXFLAGS_%s' % var] += cxxflags
try:
try_link()
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
e = None
self.end_msg('ok: winning cxxflags combination: %s' % (self.env['CXXFLAGS_%s' % var]))
exc = None
break
except Errors.ConfigurationError as exc:
except Errors.ConfigurationError as e:
self.env.revert()
e = exc
exc = e
if e is not None:
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
if exc is not None:
self.end_msg('Could not auto-detect boost linking flags combination, you may report it to boost.py author', ex=exc)
self.fatal('The configuration failed')
else:
self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
self.end_msg('Boost linkage flags auto-detection not implemented (needed ?) for this toolchain')
self.fatal('The configuration failed')
else:
self.start_msg('Checking for boost linkage')
try:
try_link()
except Errors.ConfigurationError as e:
self.end_msg("Could not link against boost libraries using supplied options")
self.end_msg('Could not link against boost libraries using supplied options', 'YELLOW')
self.fatal('The configuration failed')
self.end_msg('ok')
@feature('cxx')
@after_method('apply_link')
def install_boost(self):
if install_boost.done or not Utils.is_win32 or not self.bld.cmd.startswith('install'):
return
install_boost.done = True
inst_to = getattr(self, 'install_path', '${BINDIR}')
for lib in self.env.LIB_BOOST:
try:
file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
self.bld.install_files(inst_to, self.bld.root.find_node(file))
except:
continue
install_boost.done = False
+4 -6
View File
@@ -1,17 +1,15 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
#
# Copyright (c) 2014, Regents of the University of California
#
# GPL 3.0 license, see the COPYING.md file for more information
from waflib import TaskGen
def options(opt):
opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
help='''Set compiler flags for gcc to enable code coverage information''')
opt.add_option('--with-coverage', action='store_true', default=False,
help='Add compiler flags to enable code coverage information')
def configure(conf):
if conf.options.with_coverage:
if not conf.options.debug:
conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
+219 -41
View File
@@ -1,62 +1,240 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
#
# Copyright (c) 2014, Regents of the University of California
#
# GPL 3.0 license, see the COPYING.md file for more information
from waflib import Logs, Configure
import platform
from waflib import Configure, Logs, Utils
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
help='''Compile in debugging mode without all optimizations (-O0)''')
opt.add_option('--with-c++11', action='store_true', default=False, dest='use_cxx11',
help='''Enable C++11 mode (experimental, may not work)''')
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
help='Compile in debugging mode with minimal optimizations (-Og)')
def configure(conf):
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
defaultFlags = []
conf.start_msg('Checking C++ compiler version')
if conf.options.use_cxx11:
defaultFlags += ['-std=c++0x', '-std=c++11']
cxx = conf.env.CXX_NAME # generic name of the compiler
ccver = tuple(int(i) for i in conf.env.CC_VERSION)
ccverstr = '.'.join(conf.env.CC_VERSION)
errmsg = ''
warnmsg = ''
if cxx == 'gcc':
if ccver < (7, 4, 0):
errmsg = ('The version of gcc you are using is too old.\n'
'The minimum supported gcc version is 9.3.')
elif ccver < (9, 3, 0):
warnmsg = ('Using a version of gcc older than 9.3 is not '
'officially supported and may result in build failures.')
conf.flags = GccFlags()
elif cxx == 'clang':
if Utils.unversioned_sys_platform() == 'darwin':
if ccver < (10, 0, 0):
errmsg = ('The version of Xcode you are using is too old.\n'
'The minimum supported Xcode version is 12.4.')
elif ccver < (12, 0, 0):
warnmsg = ('Using a version of Xcode older than 12.4 is not '
'officially supported and may result in build failures.')
elif ccver < (7, 0, 0):
errmsg = ('The version of clang you are using is too old.\n'
'The minimum supported clang version is 7.0.')
conf.flags = ClangFlags()
else:
defaultFlags += ['-std=c++03']
warnmsg = f'{cxx} compiler is unsupported'
conf.flags = CompilerFlags()
defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long', '-Wno-unneeded-internal-declaration']
if errmsg:
conf.end_msg(ccverstr, color='RED')
conf.fatal(errmsg)
elif warnmsg:
conf.end_msg(ccverstr, color='YELLOW')
Logs.warn('WARNING: ' + warnmsg)
else:
conf.end_msg(ccverstr)
conf.areCustomCxxflagsPresent = len(conf.env.CXXFLAGS) > 0
# General flags are always applied (e.g., selecting C++ language standard)
generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']
@Configure.conf
def check_compiler_flags(conf):
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
# corresponding environment variables are not set.
# DEFINES are always applied.
if conf.options.debug:
conf.define('_DEBUG', 1)
defaultFlags += ['-O0',
'-Og', # gcc >= 4.8
'-g3',
'-fcolor-diagnostics', # clang
'-fdiagnostics-color', # gcc >= 4.9
'-Werror',
'-Wno-error=maybe-uninitialized', # Bug #1560
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
else:
conf.add_supported_cxxflags(defaultFlags)
extraFlags = conf.flags.getDebugFlags(conf)
if conf.areCustomCxxflagsPresent:
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
if missingFlags:
Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"'
% ' '.join(conf.env.CXXFLAGS))
Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags))
else:
defaultFlags += ['-O2', '-g']
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(defaultFlags)
extraFlags = conf.flags.getOptimizedFlags(conf)
if not conf.areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
conf.env.DEFINES += extraFlags['DEFINES']
@Configure.conf
def add_supported_cxxflags(self, cxxflags):
"""
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
Check which cxxflags are supported by the active compiler and add them to env.CXXFLAGS variable.
"""
self.start_msg('Checking allowed flags for c++ compiler')
if len(cxxflags) == 0:
return
self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
for flag in cxxflags:
if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
supportedFlags += [flag]
for flags in cxxflags:
flags = Utils.to_list(flags)
if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
self.env.prepend_value('CXXFLAGS', supportedFlags)
@Configure.conf
def add_supported_linkflags(self, linkflags):
"""
Check which linkflags are supported by the active compiler and add them to env.LINKFLAGS variable.
"""
if len(linkflags) == 0:
return
self.start_msg('Checking supported LINKFLAGS')
supportedFlags = []
for flags in linkflags:
flags = Utils.to_list(flags)
if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('LINKFLAGS', supportedFlags)
class CompilerFlags:
def getCompilerVersion(self, conf):
return tuple(int(i) for i in conf.env.CC_VERSION)
def getGeneralFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
return {
'CXXFLAGS': [],
'LINKFLAGS': [],
'DEFINES': ['BOOST_FILESYSTEM_NO_DEPRECATED'],
}
def getDebugFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
def getOptimizedFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
class GccClangCommonFlags(CompilerFlags):
"""
This class defines common flags that work for both gcc and clang compilers.
"""
def getGeneralFlags(self, conf):
flags = super().getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++17']
if Utils.unversioned_sys_platform() != 'darwin':
flags['LINKFLAGS'] += ['-fuse-ld=lld']
return flags
__cxxFlags = [
'-fdiagnostics-color',
'-Wall',
'-Wextra',
'-Wpedantic',
'-Wenum-conversion',
'-Wextra-semi',
'-Wno-unused-parameter',
]
__linkFlags = ['-Wl,-O1']
def getDebugFlags(self, conf):
flags = super().getDebugFlags(conf)
flags['CXXFLAGS'] += ['-Og', '-g'] + self.__cxxFlags + [
'-Werror',
'-Wno-error=deprecated-declarations', # Bug #3795
'-Wno-error=maybe-uninitialized', # Bug #1615
]
flags['LINKFLAGS'] += self.__linkFlags
return flags
def getOptimizedFlags(self, conf):
flags = super().getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-O2', '-g1'] + self.__cxxFlags
flags['LINKFLAGS'] += self.__linkFlags
return flags
class GccFlags(GccClangCommonFlags):
__cxxFlags = [
'-Wcatch-value=2',
'-Wcomma-subscript', # enabled by default in C++20
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wlogical-op',
'-Wredundant-tags',
'-Wvolatile', # enabled by default in C++20
]
def getDebugFlags(self, conf):
flags = super().getDebugFlags(conf)
flags['CXXFLAGS'] += self.__cxxFlags
if platform.machine() == 'armv7l':
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
return flags
def getOptimizedFlags(self, conf):
flags = super().getOptimizedFlags(conf)
flags['CXXFLAGS'] += self.__cxxFlags
if platform.machine() == 'armv7l':
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
return flags
class ClangFlags(GccClangCommonFlags):
def getGeneralFlags(self, conf):
flags = super().getGeneralFlags(conf)
if Utils.unversioned_sys_platform() == 'darwin':
# Bug #4296
brewdir = '/opt/homebrew' if platform.machine() == 'arm64' else '/usr/local'
flags['CXXFLAGS'] += [
['-isystem', f'{brewdir}/include'], # for Homebrew
['-isystem', '/opt/local/include'], # for MacPorts
]
elif Utils.unversioned_sys_platform() == 'freebsd':
# Bug #4790
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
return flags
__cxxFlags = [
'-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
def getDebugFlags(self, conf):
flags = super().getDebugFlags(conf)
flags['CXXFLAGS'] += self.__cxxFlags
return flags
def getOptimizedFlags(self, conf):
flags = super().getOptimizedFlags(conf)
flags['CXXFLAGS'] += self.__cxxFlags
return flags
+5 -5
View File
@@ -4,10 +4,10 @@ from waflib import Options, Logs
from waflib.Configure import conf
def addDependencyOptions(self, opt, name, extraHelp=''):
opt.add_option('--with-%s' % name, type='string', default=None,
dest='with_%s' % name,
opt.add_option('--with-%s' % name, metavar='PATH',
help='Path to %s, e.g., /usr/local %s' % (name, extraHelp))
setattr(Options.OptionsContext, "addDependencyOptions", addDependencyOptions)
setattr(Options.OptionsContext, 'addDependencyOptions', addDependencyOptions)
@conf
def checkDependency(self, name, **kw):
@@ -18,8 +18,8 @@ def checkDependency(self, name, **kw):
kw['mandatory'] = kw.get('mandatory', True)
if root:
isOk = self.check_cxx(includes="%s/include" % root,
libpath="%s/lib" % root,
isOk = self.check_cxx(includes='%s/include' % root,
libpath='%s/lib' % root,
**kw)
else:
isOk = self.check_cxx(**kw)
+1 -1
View File
@@ -85,7 +85,7 @@ class doxygen(Task.Task):
# Override with any parameters passed to the task generator
if getattr(self.generator, 'pars', None):
for k, v in self.generator.pars.iteritems():
for k, v in self.generator.pars.items():
self.pars[k] = v
self.doxy_inputs = getattr(self, 'doxy_inputs', [])
+5 -5
View File
@@ -52,7 +52,7 @@ Note that precompiled header must have multiple inclusion guards. If the guards
"""
import os
from waflib import Task, TaskGen, Logs, Utils
from waflib import Task, TaskGen, Utils
from waflib.Tools import c_preproc, cxx
@@ -90,8 +90,8 @@ def apply_pch(self):
if getattr(self, 'name', None):
try:
task = self.bld.pch_tasks[self.name]
self.bld.fatal("Duplicated 'pch' task with name %r" % self.name)
task = self.bld.pch_tasks["%s.%s" % (self.name, self.idx)]
self.bld.fatal("Duplicated 'pch' task with name %r" % "%s.%s" % (self.name, self.idx))
except KeyError:
pass
@@ -104,7 +104,7 @@ def apply_pch(self):
self.pch_task = task
if getattr(self, 'name', None):
self.bld.pch_tasks[self.name] = task
self.bld.pch_tasks["%s.%s" % (self.name, self.idx)] = task
@TaskGen.feature('cxx')
@TaskGen.after_method('process_source', 'propagate_uselib_vars')
@@ -129,7 +129,7 @@ def add_pch(self):
x.env.append_value('CXXFLAGS', self.env['CXXPCH_F'] + [pch.target])
class gchx(Task.Task):
run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CPPFLAGS} ${CXXPCH_FLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXXPCH_F:SRC} ${CXX_SRC_F}${SRC[0].abspath()} ${CXX_TGT_F}${TGT[0].abspath()}'
run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CXXPCH_FLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXXPCH_F:SRC} ${CXX_SRC_F}${SRC[0].abspath()} ${CXX_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
scan = c_preproc.scan
color = 'BLUE'
ext_out=['.h']
+22
View File
@@ -0,0 +1,22 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def options(opt):
opt.add_option('--with-sanitizer', action='store', default='', dest='sanitizers',
help='Comma-separated list of compiler sanitizers to enable [default=none]')
def configure(conf):
for san in conf.options.sanitizers.split(','):
if not san:
continue
sanflag = '-fsanitize=%s' % san
conf.start_msg('Checking if compiler supports %s' % sanflag)
if conf.check_cxx(cxxflags=['-Werror', sanflag, '-fno-omit-frame-pointer'],
linkflags=[sanflag], mandatory=False):
conf.end_msg('yes')
conf.env.append_unique('CXXFLAGS', [sanflag, '-fno-omit-frame-pointer'])
conf.env.append_unique('LINKFLAGS', [sanflag])
else:
conf.end_msg('no', color='RED')
conf.fatal('%s sanitizer is not supported by the current compiler' % san)
+8 -8
View File
@@ -44,28 +44,28 @@ def apply_sphinx(self):
task.inputs.append(conf)
confdir = conf.parent.abspath()
buildername = getattr(self, "builder", "html")
srcdir = getattr(self, "srcdir", confdir)
outdir = self.path.find_or_declare(getattr(self, "outdir", buildername)).get_bld()
doctreedir = getattr(self, "doctreedir", os.path.join(outdir.abspath(), ".doctrees"))
buildername = getattr(self, 'builder', 'html')
srcdir = getattr(self, 'srcdir', confdir)
outdir = self.path.find_or_declare(getattr(self, 'outdir', buildername)).get_bld()
doctreedir = getattr(self, 'doctreedir', os.path.join(outdir.abspath(), '.doctrees'))
task.env['BUILDERNAME'] = buildername
task.env['SRCDIR'] = srcdir
task.env['DOCTREEDIR'] = doctreedir
task.env['OUTDIR'] = outdir.abspath()
task.env['VERSION'] = "version=%s" % self.VERSION
task.env['RELEASE'] = "release=%s" % self.VERSION
task.env['VERSION'] = 'version=%s' % self.version
task.env['RELEASE'] = 'release=%s' % getattr(self, 'release', self.version)
import imp
confData = imp.load_source('sphinx_conf', conf.abspath())
if buildername == "man":
if buildername == 'man':
for i in confData.man_pages:
target = outdir.find_or_declare('%s.%d' % (i[1], i[4]))
task.outputs.append(target)
if self.install_path:
self.bld.install_files("%s/man%d/" % (self.install_path, i[4]), target)
self.bld.install_files('%s/man%d/' % (self.install_path, i[4]), target)
else:
task.outputs.append(outdir)
+7 -7
View File
@@ -1,13 +1,13 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
#
# Copyright (c) 2014, Regents of the University of California
# Copyright (c) 2014-2019, Regents of the University of California
#
# GPL 3.0 license, see the COPYING.md file for more information
from waflib import Options
BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK = '''
#include <boost/asio.hpp>
#include <boost/asio/local/basic_endpoint.hpp>
#ifndef BOOST_ASIO_HAS_LOCAL_SOCKETS
#error "Unix sockets are not available on this platform"
#endif
@@ -15,8 +15,9 @@ BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK = '''
def addUnixOptions(self, opt):
opt.add_option('--force-unix-socket', action='store_true', default=False,
dest='force_unix_socket', help='''Forcefully enable Unix sockets support''')
setattr(Options.OptionsContext, "addUnixOptions", addUnixOptions)
help='Forcefully enable Unix sockets support')
setattr(Options.OptionsContext, 'addUnixOptions', addUnixOptions)
def configure(conf):
def boost_asio_has_local_sockets():
@@ -24,6 +25,5 @@ def configure(conf):
fragment=BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK,
features='cxx', use='BOOST', mandatory=False)
if conf.options.force_unix_socket or boost_asio_has_local_sockets():
conf.define('HAVE_UNIX_SOCKETS', 1)
conf.env['HAVE_UNIX_SOCKETS'] = True
conf.env.HAVE_UNIX_SOCKETS = conf.options.force_unix_socket or boost_asio_has_local_sockets()
conf.define_cond('HAVE_UNIX_SOCKETS', conf.env.HAVE_UNIX_SOCKETS)
+26 -32
View File
@@ -1,24 +1,22 @@
# encoding: utf-8
from waflib import Options, Logs, Errors
from waflib.Configure import conf
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
from waflib import Options, Logs, Errors, Configure
import re
def addWebsocketOptions(self, opt):
opt.add_option('--without-websocket', action='store_false', default=True,
dest='with_websocket',
help='Disable WebSocket face support')
setattr(Options.OptionsContext, "addWebsocketOptions", addWebsocketOptions)
dest='with_websocket', help='Disable WebSocket face support')
@conf
setattr(Options.OptionsContext, 'addWebsocketOptions', addWebsocketOptions)
@Configure.conf
def checkWebsocket(self, **kw):
if not self.options.with_websocket:
return
isMandatory = kw.get('mandatory', True)
self.start_msg('Checking for WebSocket includes')
self.start_msg('Checking for WebSocket++ includes')
try:
websocketDir = self.path.find_dir('websocketpp/websocketpp')
@@ -27,53 +25,49 @@ def checkWebsocket(self, **kw):
versionFile = websocketDir.find_node('version.hpp')
if not websocketDir:
raise Errors.WafError('Corrupted: WebSocket version file not found')
raise Errors.WafError('WebSocket++ version file not found')
try:
txt = versionFile.read()
except (OSError, IOError):
raise Errors.WafError('Corrupted: cannot read WebSocket version file')
# Looking for the following:
# static int const major_version = 0;
# static int const minor_version = 3;
# static int const patch_version = 0;
raise Errors.WafError('Cannot read WebSocket++ version file')
version = [None, None, None]
# Looking for the following:
# static int const major_version = 0;
# static int const minor_version = 7;
# static int const patch_version = 0;
majorVersion = re.compile('^static int const major_version = (\\d+);$', re.M)
version[0] = majorVersion.search(txt)
minorVersion = re.compile('^static int const minor_version = (\\d+);$', re.M)
version[1] = minorVersion.search(txt)
patchVersion = re.compile('^static int const patch_version = (\\d+);$', re.M)
version[2] = patchVersion.search(txt)
if not version[0] or not version[1] or not version[2]:
raise Errors.WafError('Corrupted: cannot detect websocket version')
raise Errors.WafError('Cannot detect WebSocket++ version')
self.env['WEBSOCKET_VERSION'] = [i.group(1) for i in version]
self.env.WEBSOCKET_VERSION = [i.group(1) for i in version]
# todo: version checking, if necessary
self.end_msg('.'.join(self.env['WEBSOCKET_VERSION']))
self.end_msg('.'.join(self.env.WEBSOCKET_VERSION))
self.env['INCLUDES_WEBSOCKET'] = websocketDir.parent.abspath()
self.env['HAVE_WEBSOCKET'] = True
self.env.append_unique('DEFINES', ['_WEBSOCKETPP_CPP11_STL_'])
self.env.INCLUDES_WEBSOCKET = websocketDir.parent.abspath()
self.env.HAVE_WEBSOCKET = True
self.define('HAVE_WEBSOCKET', 1)
except Errors.WafError as error:
if isMandatory:
self.end_msg(str(error), color='RED')
Logs.warn('If you are using git NFD repository, checkout websocketpp submodule: ')
Logs.warn(' git submodule init && git submodule update')
Logs.warn('Otherwise, manually download and extract websocketpp library:')
Logs.warn(' mkdir websocketpp')
Logs.warn(' curl -L https://github.com/zaphoyd/websocketpp/tarball/65cc3765a892ee5928160ba478178e747233aa6c > websocket.tar.gz')
Logs.warn(' tar zxf websocket.tar.gz -C websocketpp/ --strip 1')
Logs.warn('If you are using NFD from the git repository, checkout the websocketpp submodule: ')
Logs.warn(' git submodule update --init')
Logs.warn('Otherwise, manually download and extract the websocketpp library:')
Logs.warn(' mkdir -p websocketpp')
Logs.warn(' curl -L https://github.com/cawka/websocketpp/archive/0.8.1-hotfix.tar.gz > websocketpp.tar.gz')
Logs.warn(' tar xf websocketpp.tar.gz -C websocketpp/ --strip 1')
Logs.warn('Alternatively, WebSocket support can be disabled with --without-websocket')
self.fatal("The configuration failed")
self.fatal('WebSocket++ not found')
else:
self.end_msg(str(error))
+59 -61
View File
@@ -1,65 +1,63 @@
NFD Authors
===========
# NFD Authors
NFD is an open source project started in late 2013, includes contributions
from many people around the world, and open for new contributions from new
volunteers.
The following lists maintainers, primary developers, and all much-appreciated contributors to NFD in alphabetical order.
The specific contributions of individual authors can be obtained from the git history of the [official NFD repository](https://github.com/named-data/NFD).
If you would like to become a contributor to the official repository, please follow the recommendations in <https://github.com/named-data/.github/blob/main/CONTRIBUTING.md>.
* Jerald Paul Abraham <https://cs.arizona.edu/~jeraldabraham>
* ***(Maintainer)*** Alexander Afanasyev <https://users.cs.fiu.edu/~afanasyev>
* Syed Obaid Amin <http://obaidamin.weebly.com>
* Hila Ben Abraham <https://sites.wustl.edu/hbabraham>
* Muktadir R Chowdhury <https://github.com/alvyC>
* Tai-Lin Chu <https://www.linkedin.com/pub/tai-lin-chu/55/5b2/669>
* Stephanie DiBenedetto
* Saurab Dulal <https://dulalsaurab.github.io>
* Chengyu Fan <https://github.com/chengyu>
* Ashlesh Gawande <https://www.linkedin.com/in/agawande>
* Chavoosh Ghasemi <https://chavoosh.github.io>
* Mathias Gibbens <https://calenhad.com>
* Nick Gordon <https://github.com/gorgonical>
* Giulio Grassi <https://www.lip6.fr/actualite/personnes-fiche.php?ident=D1461>
* Yi Huang <https://www.linkedin.com/in/yihuang1991>
* Alexander Lane <https://github.com/awlane>
* Jongseok Lee <https://github.com/imwhiz>
* Spencer Lee <https://www.linkedin.com/in/spenlee>
* Vince Lehman <http://vslehman.com>
* Yanbiao Li <https://www.linkedin.com/pub/yanbiao-li/24/7a1/4ba>
* Teng Liang <https://cs.arizona.edu/~philoliang>
* Weiwei Liu <https://www.linkedin.com/in/weiweiliu10>
* Spyridon Mastorakis <https://sites.google.com/site/spyridonmastorakis>
* Ernest McCracken <https://github.com/emccrckn>
* Ilya Moiseenko <https://www.linkedin.com/in/ilya-moiseenko-52884317>
* Eric Newberry <https://ericnewberry.com>
* Ju Pan <https://cs-jupan.com>
* João Pereira <http://website.jpereira.co.uk>
* ***(Maintainer)*** Davide Pesavento <https://github.com/Pesa>
* Felix Rabe <https://twitter.com/felixrabe>
* Md Ashiqur Rahman <https://ashiqrahman.com>
* Matteo Sammarco <https://www.linkedin.com/in/matteo-sammarco-9b544530>
* Niv Sardi <http://core.evilgiggle.com>
* Klaus Schneider <https://cs.arizona.edu/~klaus>
* Wentao Shang <https://irl.cs.ucla.edu/~wentao>
* Susmit Shannigrahi <https://susm.it>
* ***(Former Maintainer)*** Junxiao Shi <https://cs.arizona.edu/~shijunxiao>
* Yukai Tu <https://irl.cs.ucla.edu/~yukai>
* Sebastian Wölke <https://inet.haw-hamburg.de/members/alumni-1/sebastian-woelke>
* Yumin Xia <https://github.com/Stumble>
* Yingdi Yu <https://irl.cs.ucla.edu/~yingdi>
* Haowei Yuan <http://www.cse.wustl.edu/~yuanh>
* Hang Zhang <http://netlab.bit.edu.cn/z_hang>
* Minsheng Zhang <https://github.com/mzhang4>
* Zhiyi Zhang <https://zhiyi-zhang.com>
* Qi Zhao <https://web.cs.ucla.edu/~qi.zhao>
* Wenkai Zheng <https://github.com/wenkaizheng>
## Project technical leads:
## Technical Advisors
* Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
* Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/>
## Technical advisors:
* Beichuan Zhang <http://www.cs.arizona.edu/~bzhang/>
* Lixia Zhang <http://www.cs.ucla.edu/~lixia/>
## All project authors and contributors and their affiliations:
* University of California, Los Angeles
* Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
* Ilya Moiseenko <http://ilyamoiseenko.com/>
* Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/web/index.html>
* Wentao Shang <http://irl.cs.ucla.edu/~wentao/>
* Lixia Zhang <http://www.cs.ucla.edu/~lixia/>
* The University of Arizona
* Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/>
* Yi Huang <ethanhuang1991@gmail.com>
* Jerald Paul Abraham <http://www.cs.arizona.edu/people/jeraldabraham/>
* Beichuan Zhang <http://www.cs.arizona.edu/~bzhang/>
* Colorado State University
* Steve DiBenedetto <http://www.cs.colostate.edu/~dibenede/>
* Chengyu Fan <chengyu@cs.colostate.edu>
* Christos Papadopoulos <http://www.cs.colostate.edu/~christos/>
* University Pierre & Marie Curie, Sorbonne University
* Davide Pesavento <http://www.lip6.fr/actualite/personnes-fiche.php?ident=D1469>
* Giulio Grassi <http://www.lip6.fr/actualite/personnes-fiche.php?ident=D1461>
* Giovanni Pau <http://www.cs.ucla.edu/~gpau/Giovanni_Paus_Home_Page/Home.html>
* Beijing Institute of Technology
* Hang Zhang <http://netlab.bit.edu.cn/z_hang>
* Tian Song <http://cs.bit.edu.cn/songtian>
* Washington University in St. Louis
* Haowei Yuan <http://www.cse.wustl.edu/~yuanh/>
* Hila Ben Abraham <http://research.engineering.wustl.edu/~abrahamh/>
* Patrick Crowley <http://www.arl.wustl.edu/~pcrowley/>
* The University of Memphis
* Syed Obaid Amin <http://obaidamin.weebly.com/>
* Vince Lehman <vslehman@memphis.edu>
* Lan Wang <http://www.cs.memphis.edu/~lanwang/>
* Patrick Crowley <https://www.arl.wustl.edu/~pcrowley>
* Christos Papadopoulos <https://www.cs.colostate.edu/~christos>
* Giovanni Pau <https://www.unibo.it/sitoweb/giovanni.pau/en>
* Tian Song <http://www.bit-netlab.org/songtian>
* Lan Wang <http://www.cs.memphis.edu/~lanwang>
* Beichuan Zhang <https://cs.arizona.edu/~bzhang>
* Lixia Zhang <https://cs.ucla.edu/~lixia>
+17
View File
@@ -0,0 +1,17 @@
cff-version: 1.2.0
message: If you use NFD in your research, please cite it as below.
license: GPL-3.0-or-later
repository-code: "https://github.com/named-data/NFD"
title: Named Data Networking Forwarding Daemon
url: "https://docs.named-data.net/NFD/"
preferred-citation:
authors:
- name: Named Data Networking Project Team
date-published: "2021-07-30"
journal: NDN Technical Report NDN-0021
month: 7
title: NFD Developer's Guide
type: generic
url: "https://named-data.net/publications/techreports/ndn-0021-11-nfd-guide/"
version: 11
year: 2021
+382 -356
View File
File diff suppressed because it is too large. Load diff
+45
View File
@@ -0,0 +1,45 @@
FROM ghcr.io/named-data/ndn-cxx:latest as builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpcap-dev \
&& rm -rf /var/lib/apt/lists/*
COPY . /NFD
RUN cd /NFD \
&& ./waf configure --without-pch --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
&& ./waf \
&& ./waf install \
# get list of dependencies
&& mkdir -p /shlibdeps/debian && cd /shlibdeps && touch debian/control \
&& dpkg-shlibdeps --ignore-missing-info /usr/lib/libndn-cxx.so* /usr/bin/nfdc /usr/bin/nfd \
&& sed -n '/^shlibs:Depends=/ s|shlibs:Depends=||p' debian/substvars | sed -e 's|,||g' -e 's| ([^)]*)||g' > /deps.txt
# use same base distro version as named-data/ndn-cxx
FROM debian:bookworm
COPY --from=builder /deps.txt /
RUN apt-get update \
&& apt-get install -y --no-install-recommends $(cat /deps.txt) \
&& rm -rf /var/lib/apt/lists/* /deps.txt
COPY --from=builder /usr/lib/libndn-cxx.so* /usr/lib/
COPY --from=builder /usr/bin/nfd /usr/bin/
COPY --from=builder /usr/bin/nfdc /usr/bin/
COPY --from=builder /usr/bin/nfd-status-http-server /usr/bin/
COPY --from=builder /usr/share/ndn/ /usr/share/ndn/
COPY --from=builder /etc/ndn/nfd.conf.sample /config/nfd.conf
ENV HOME=/config
VOLUME /config
VOLUME /run/nfd
EXPOSE 6363/tcp
EXPOSE 6363/udp
EXPOSE 9696/tcp
ENTRYPOINT ["/usr/bin/nfd"]
CMD ["--config", "/config/nfd.conf"]
-5
View File
@@ -1,5 +0,0 @@
NFD Installation Instructions
=============================
See [`docs/install.rst`](https://github.com/named-data/NFD/blob/master/docs/INSTALL.rst)
for detailed NFD installation instructions.
+31 -34
View File
@@ -1,20 +1,21 @@
Notes for NFD developers
========================
# Notes for NFD developers
Requirements
------------
If you are new to the NDN software community, please read our
[Contributor's Guide](https://github.com/named-data/.github/blob/main/CONTRIBUTING.md).
Include the following license boilerplate into all `.hpp` and `.cpp` files:
## Code style
NFD code is subject to [NFD code style](https://redmine.named-data.net/projects/nfd/wiki/CodeStyle).
## Licensing
Contributions to NFD must be licensed under the GPL v3 or a compatible license.
If you choose the GPL v3, please use the following license boilerplate in all `.hpp`
and `.cpp` files:
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
/*
* Copyright (c) [Year(s)], [Copyright Holder(s)].
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -29,44 +30,41 @@ Include the following license boilerplate into all `.hpp` and `.cpp` files:
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
////// [optional part] //////
*
* \author Author's Name <email@domain>
* \author Other Author's Name <another.email@domain>
////// [end of optional part] //////
*/
Recommendations
---------------
If you are affiliated to an NSF-supported NDN project institution, please use the [NDN Team License
Boilerplate](https://redmine.named-data.net/projects/nfd/wiki/NDN_Team_License_Boilerplate_(NFD)).
NFD code is subject to NFD [code style](http://redmine.named-data.net/projects/nfd/wiki/CodeStyle).
## Logging
Fine-grained per-module logging can be configured via the `NDN_LOG` environment variable.
This is especially useful when running unit tests or tools such as `nfdc` that do not
have a configuration file. See `ndn-log(7)` manual page for syntax and examples.
Running unit-tests
------------------
## Unit tests
To run unit tests, NFD needs to be configured and build with unit test support:
./waf configure --with-tests
./waf configure --with-tests # --debug is also strongly recommended while developing
./waf
The simplest way to run tests, is just to run the compiled binary without any parameters:
The simplest way to run the tests is to launch the compiled binary without any parameters:
# Run core tests
./build/unit-tests-core
# Run NFD daemon tests
# Run NFD daemon tests
./build/unit-tests-daemon
# Run NFD RIB management tests
./build/unit-tests-rib
However, [Boost.Test framework](http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/)
The [Boost.Test framework](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/index.html)
is very flexible and allows a number of run-time customization of what tests should be run.
For example, it is possible to choose to run only a specific test suite, only a specific
test case within a suite, or specific test cases within specific test suites:
# Run only TCP Face test suite of NFD daemon tests (see tests/daemon/face/tcp.cpp)
# Run only the TCP Face test suite of NFD daemon tests
./build/unit-tests-daemon -t FaceTcp
# Run only test case EndToEnd4 from the same test suite
@@ -77,8 +75,8 @@ test case within a suite, or specific test cases within specific test suites:
By default, Boost.Test framework will produce verbose output only when a test case fails.
If it is desired to see verbose output (result of each test assertion), add `-l all`
option to `./build/unit-tests` command. To see test progress, you can use `-l test_suite`
or `-p` to show progress bar:
option to `./build/unit-tests` command. To see test progress, you can use `-l test_suite`,
or `-p` to show a progress bar:
# Show report all log messages including the passed test notification
./build/unit-tests-daemon -l all
@@ -92,7 +90,6 @@ or `-p` to show progress bar:
# Show progress bar
./build/unit-tests-core -p
There are many more command line options available, information about
which can be obtained either from the command line using `--help`
switch, or online on [Boost.Test library](http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/)
website.
There are many more command line options available, information about which can be obtained
either from the command line using the `--help` switch, or online on the
[Boost.Test website](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/runtime_config.html).
+37 -64
View File
@@ -1,33 +1,22 @@
NFD - Named Data Networking Forwarding Daemon
=============================================
<div align="center">
NFD overview, release notes for the released versions, getting started tutorial, and other
additional documentation are available online on
[NFD's homepage](http://named-data.net/doc/NFD/).
[<img alt height="65" src="docs/named_data_theme/static/ndn-logo.svg"/>](https://named-data.net/)
# NFD: Named Data Networking Forwarding Daemon
</div>
[![CI](https://github.com/named-data/NFD/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/NFD/actions/workflows/ci.yml)
[![Docs](https://github.com/named-data/NFD/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/NFD/actions/workflows/docs.yml)
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
![Latest version](https://img.shields.io/github/v/tag/named-data/NFD?label=Latest%20version)
## Overview
NFD is a network forwarder that implements and evolves together with the Named Data
Networking (NDN) [protocol](http://named-data.net/doc/ndn-tlv/). After the initial
release, NFD will become a core component of the
[NDN Platform](http://named-data.net/codebase/platform/) and will follow the same release
cycle.
NFD is an open and free software package licensed under GPL 3.0 license and is the
centerpiece of our committement to making NDN's core technology open and free to all
Internet users and developers. For more information about the licensing details and
limitation, refer to
[`COPYING.md`](https://github.com/named-data/NFD/blob/master/COPYING.md).
NFD is developed by a community effort. Although the first release was mostly done by the
members of [NSF-sponsored NDN project team](http://named-data.net/project/participants/),
it already contains significant contributions from people outside the project team (for
more details, refer to [`AUTHORS.md`](https://github.com/named-data/NFD/blob/master/AUTHORS.md)).
We strongly encourage participation from all interested parties, since broader community
support is key for NDN to succeed as a new Internet architecture. Bug reports and
feedback are highly appreciated and can be made through
[Redmine site](http://redmine.named-data.net/projects/nfd) and the
[ndn-interest mailing list](http://www.lists.cs.ucla.edu/mailman/listinfo/ndn-interest).
NFD is a network forwarder that implements and evolves together with the Named
Data Networking (NDN) [protocol](https://docs.named-data.net/NDN-packet-spec/).
Since the initial public release in 2014, NFD has been a core component of the
[NDN Platform](https://named-data.net/codebase/platform/).
The main design goal of NFD is to support diverse experimentation of NDN technology. The
design emphasizes *modularity* and *extensibility* to allow easy experiments with new
@@ -38,51 +27,35 @@ algorithms; over time, better implementations may emerge within the same design
NFD will keep evolving in three aspects: improvement of the modularity framework, keeping
up with the NDN protocol spec, and addition of other new features. We hope to keep the
modular framework stable and lean, allowing researchers to implement and experiment
with various features, some of which may eventually work into the protocol spec.
modular framework stable and lean, allowing researchers to implement and experiment with
various features, some of which may eventually work into the protocol spec.
The design and development of NFD benefited from our earlier experience with
[CCNx](http://www.ccnx.org) software package. However, NFD is not in any part derived from
CCNx codebase and does not maintain compatibility with CCNx.
## Documentation
Binary release
--------------
See [`docs/INSTALL.rst`](docs/INSTALL.rst) for compilation and installation instructions.
As of release 0.1.0, we are providing NFD binaries for the supported platforms, which are
the preferred installation method of NFD:
Extensive documentation is available on NFD's [homepage](https://docs.named-data.net/NFD/).
- [Ubuntu 12.04, 13.10, and 14.04](http://named-data.net/doc/NFD/current/FAQ.html#how-to-start-using-ndn-ppa-repository-on-ubuntu-linux)
## Reporting bugs
- [OSX 10.8, 10.9 with MacPorts](http://named-data.net/doc/NFD/current/FAQ.html#how-to-start-using-ndn-macports-repository-on-osx)
Please submit any bug reports or feature requests to the
[NFD issue tracker](https://redmine.named-data.net/projects/nfd/issues).
Next releases would include support for other platforms. Please send us feedback on the
platforms you're using, so we can prioritize our goals. We would also appreciate if
someone can provide help with packaging the current NFD release for other platforms.
## Contributing
Besides simplicity of installation, the binary release includes automatic initial
configuration and platform-specific tools to automatically start NFD and related daemons.
In particular, on OSX NFD is controlled using
[launchd](https://github.com/named-data/NFD/tree/master/contrib/osx-launchd) and on Ubuntu
using [upstart](https://github.com/named-data/NFD/tree/master/contrib/upstart) mechanisms.
In both cases, `nfd-start` and `nfd-stop` scripts are convenience wrappers for launchd and
upstart.
NFD is developed by a community effort. Although the first release was mostly done by the
members of [NSF-sponsored NDN project team](https://named-data.net/project/participants/),
it already contains significant contributions from people outside the project team (see
[`AUTHORS.md`](AUTHORS.md)). We strongly encourage participation from all interested parties,
since broader community support is key for NDN to succeed as a new Internet architecture.
Source releases
---------------
Contributions to NFD are greatly appreciated and can be made through our
[Gerrit code review site](https://gerrit.named-data.net/).
If you are new to the NDN software community, please read our
[Contributor's Guide](https://github.com/named-data/.github/blob/main/CONTRIBUTING.md)
and [`README-dev.md`](README-dev.md) to get started.
The source code and source-code installation instructions are always available on NFD's homepage:
## License
- [Getting Started with NFD](http://named-data.net/doc/NFD/current/getting-started.html)
- [Github NFD repository](https://github.com/named-data/NFD)
Additional information
----------------------
- [NFD Wiki](http://redmine.named-data.net/projects/nfd/wiki/)
- Feature requests and bug reports are welcome on our
[NDN Redmine](http://redmine.named-data.net/projects/nfd)
Besides officially supported platforms, NFD is known to work on: Fedora 20, CentOS 6,
Raspberry Pi, OpenWRT, FreeBSD 10.0, and several other platforms. We are soliciting help
with documenting common problems / pitfalls in installing/using NFD on different platforms
on [NFD WiKi](http://redmine.named-data.net/projects/nfd/wiki/Wiki#Installation-experiences-for-selected-platforms).
NFD is free software distributed under the GNU General Public License version 3.
See [`COPYING.md`](COPYING.md) for details.
+3
View File
@@ -0,0 +1,3 @@
# Enable ndn-autoconfig to run in parallel with NFD. Disabled by default
# enabled=true
enabled=false
-95
View File
@@ -1,95 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_COMMON_HPP
#define NFD_COMMON_HPP
#include "config.hpp"
#ifdef WITH_TESTS
#define VIRTUAL_WITH_TESTS virtual
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED public
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE public
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE protected
#else
#define VIRTUAL_WITH_TESTS
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED protected
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE private
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE private
#endif
#include <cstddef>
#include <list>
#include <set>
#include <queue>
#include <vector>
#include <ndn-cxx/common.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/data.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/assert.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/noncopyable.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/scoped_ptr.hpp>
namespace nfd {
using std::size_t;
using boost::noncopyable;
using boost::scoped_ptr;
using ndn::shared_ptr;
using ndn::weak_ptr;
using ndn::enable_shared_from_this;
using ndn::make_shared;
using ndn::static_pointer_cast;
using ndn::dynamic_pointer_cast;
using ndn::const_pointer_cast;
using ndn::function;
using ndn::bind;
using ndn::ref;
using ndn::cref;
using ndn::Interest;
using ndn::Data;
using ndn::Name;
using ndn::Exclude;
using ndn::Block;
namespace tlv {
using namespace ndn::Tlv;
}
namespace name = ndn::name;
namespace time = ndn::time;
} // namespace nfd
#endif // NFD_COMMON_HPP
@@ -1,25 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>net.named-data.nrd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/nrd</string>
<string>--config</string>
<string>/usr/local/etc/ndn/nfd.conf</string>
</array>
<key>UserName</key><string>ndn</string>
<key>GroupName</key><string>ndn</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key><string>/usr/local/var/lib/ndn/nrd</string>
</dict>
<key>Debug</key><true/>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
<key>StandardErrorPath</key><string>/usr/local/var/log/ndn/nrd.log</string>
<key>ProcessType</key><string>Background</string>
</dict>
</plist>
-144
View File
@@ -1,144 +0,0 @@
Starting NFD on Linux with upstart
==================================
Some Linux distributions, such as Ubuntu, use [upstart](http://upstart.ubuntu.com/) as a
standard mechanism to start system daemons, monitor their health, and restart
when they die.
Initial setup
-------------
Edit `nfd.conf` and `nrd.conf` correcting paths for `nfd` and `nfd` binaries,
configuration file, and log files.
# Copy upstart config file for nfd (forwarding daemon)
sudo cp nfd.conf /etc/init/
# Copy upstart config file for nrd (RIB management daemon)
sudo cp nrd.conf /etc/init/
# Copy upstart config file for nfd-watcher (will restart NFD when network change detected)
sudo cp nfd-watcher.conf /etc/init/
### Assumptions in the default scripts
* `nfd` and `nrd` are installed into `/usr/local/bin`
* Configuration file is `/usr/local/etc/ndn/nfd.conf`
* `nfd` will be run as root
* `nrd` will be run as user `ndn` and group `ndn`
* Log files will be written to `/usr/local/var/log/ndn` folder, which is owned by user `ndn`
* Whenever network connectivity changes, both `nfd` and `nrd` are restarted
### Creating users
If `ndn` user and group does not exists, they need to be manually created.
# Create group `ndn`
addgroup --system ndn
# Create user `ndn`
sudo adduser --system \
--disabled-login \
--ingroup ndn \
--home /nonexistent \
--gecos "NDN User" \
--shell /bin/false \
ndn
### Creating folders
Folder `/usr/local/var/log/ndn` should be created and assigned proper user and group:
sudo mkdir -p /usr/local/var/log/ndn
sudo chown -R ndn:ndn /usr/local/var/log/ndn
`HOME` directories for `nfd` and `nrd` should be created prior to starting. This is
necessary to manage unique security credentials for the deamons.
# Create HOME and generate self-signed NDN certificate for nfd
sudo mkdir -p /usr/local/var/lib/ndn/nfd/.ndn
sudo HOME=/usr/local/var/lib/ndn/nfd ndnsec-keygen /localhost/daemons/nfd | \
sudo HOME=/usr/local/var/lib/ndn/nfd ndnsec-install-cert -
# Create HOME and generate self-signed NDN certificate for nrd
sudo mkdir -p /usr/local/var/lib/ndn/nrd/.ndn
sudo chown -R ndn:ndn /usr/local/var/lib/ndn/nrd
sudo -u ndn -g ndn HOME=/usr/local/var/lib/ndn/nrd ndnsec-keygen /localhost/daemons/nrd | \
sudo -u ndn -g ndn HOME=/usr/local/var/lib/ndn/nrd ndnsec-install-cert -
### Configuring NFD's security
NFD sample configuration allows anybody to create faces, add nexthops to FIB, and set
strategy choice for namespaces. While such settings could be a good start, it is
generally not a good idea to run NFD in this mode.
While thorough discussion about security configuration of NFD is outside the scope of this
document, at least the following change should be done to ``nfd.conf`` in authorize
section:
authorizations
{
authorize
{
certfile certs/localhost_daemons_nrd.ndncert
privileges
{
faces
fib
strategy-choice
}
}
authorize
{
certfile any
privileges
{
faces
strategy-choice
}
}
}
While this configuration still allows management of faces and updating strategy choice by
anybody, only NFD's RIB Manager Daemon (`nrd`) is allowed to manage FIB.
As the final step to make this configuration work, nrd's self-signed certificate needs to
be exported into `localhost_daemons_nrd.ndncert` file:
sudo mkdir /usr/local/etc/ndn/certs
sudo sh -c 'sudo -u ndn -g ndn HOME=/usr/local/var/lib/ndn/nrd \
ndnsec-dump-certificate -i /localhost/daemons/nrd \
> /usr/local/etc/ndn/certs/localhost_daemons_nrd.ndncert'
Enable auto-start
-----------------
After copying the provided upstart scripts, `nfd` and `nrd` daemons will automatically run
after the reboot. To manually start them, use the following commands:
sudo start nfd
# nrd will be automatically started by upstart
Note that an additional upstart job, ``nfd-watcher``, will automatically monitor for
network connectivity changes, such as when network interface gets connected, disconnected,
or IP addresses of the network interface get updated. When ``nfd-watcher`` detects the
event, it will restart `nfd` and `nrd`.
Disable auto-start
------------------
To stop `nrd` and `nfd` daemon, use the following commands:
sudo stop nfd
# nrd will be automatically stopped by upstart
Note that as long as upstart files are present in `/etc/init/`, the daemons will
automatically start after the reboot. To permanently stop `nfd` and `nrd` daemons, delete
the upstart files:
sudo rm /etc/init/nfd.conf
sudo rm /etc/init/nrd.conf
sudo rm /etc/init/nfd-watcher.conf
-13
View File
@@ -1,13 +0,0 @@
# nfd-watcher.conf
#
# Restarting NDN Forwarding Daemon on network connectivity changes
start on (net-device-up or
net-device-removed or
net-device-changed)
task
script
status nfd | grep -q start/ || stop
restart nfd
end script
-17
View File
@@ -1,17 +0,0 @@
# nfd.conf
#
# NDN Forwarding Daemon
description "NDN forwarding daemon"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
respawn
respawn limit unlimited
env HOME=/usr/local/var/lib/ndn/nfd
export HOME
exec /usr/local/bin/nfd --config /usr/local/etc/ndn/nfd.conf 2>> /usr/local/var/log/ndn/nfd.log
post-stop exec sleep 2
-22
View File
@@ -1,22 +0,0 @@
# nrd.conf
#
# NDN RIB Manager Daemon
description "NDN RIB Manager Daemon"
start on started nfd
stop on stopping nfd
respawn
respawn limit unlimited
setuid ndn
setgid ndn
pre-start exec sleep 2
script
export HOME=/usr/local/var/lib/ndn/nrd
/usr/local/bin/nrd --config /usr/local/etc/ndn/nfd.conf 2>> /usr/local/var/log/ndn/nrd.log
end script
post-stop exec sleep 2
+123
View File
@@ -0,0 +1,123 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_CORE_COMMON_HPP
#define NFD_CORE_COMMON_HPP
#include "core/config.hpp"
#ifdef NFD_WITH_TESTS
#define NFD_VIRTUAL_WITH_TESTS virtual
#define NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED public
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE public
#define NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE protected
#define NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL override
#define NFD_FINAL_UNLESS_WITH_TESTS
#else
#define NFD_VIRTUAL_WITH_TESTS
#define NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED protected
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE private
#define NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE private
#define NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL final
#define NFD_FINAL_UNLESS_WITH_TESTS final
#endif
#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/lp/nack.hpp>
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/util/backports.hpp>
#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/scheduler.hpp>
#include <ndn-cxx/util/signal.hpp>
#include <ndn-cxx/util/span.hpp>
#include <ndn-cxx/util/time.hpp>
#include <boost/assert.hpp>
#include <boost/core/noncopyable.hpp>
namespace nfd {
using std::size_t;
using std::shared_ptr;
using std::unique_ptr;
using std::weak_ptr;
using std::make_shared;
using std::make_unique;
using std::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::const_pointer_cast;
using std::to_string;
using namespace std::string_literals;
using namespace std::string_view_literals;
using boost::noncopyable;
using ndn::span;
using ndn::Block;
using ndn::Data;
using ndn::FaceUri;
using ndn::Interest;
using ndn::Name;
using ndn::PartialName;
using ndn::Scheduler;
// Not using a namespace alias (namespace tlv = ndn::tlv), because
// it doesn't allow NFD to add other members to the namespace
namespace tlv {
using namespace ndn::tlv;
} // namespace tlv
namespace lp = ndn::lp;
namespace name = ndn::name;
namespace scheduler = ndn::scheduler;
namespace signal = ndn::signal;
namespace time = ndn::time;
using namespace ndn::block_literals;
using namespace ndn::time_literals;
} // namespace nfd
#endif // NFD_CORE_COMMON_HPP
-143
View File
@@ -1,143 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "config-file.hpp"
#include "logger.hpp"
#include <boost/property_tree/info_parser.hpp>
#include <fstream>
namespace nfd {
NFD_LOG_INIT("ConfigFile");
void
ConfigFile::throwErrorOnUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun)
{
std::string msg = "Error processing configuration file ";
msg += filename;
msg += ": no module subscribed for section \"" + sectionName + "\"";
throw ConfigFile::Error(msg);
}
void
ConfigFile::ignoreUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun)
{
// do nothing
}
ConfigFile::ConfigFile(UnknownConfigSectionHandler unknownSectionCallback)
: m_unknownSectionCallback(unknownSectionCallback)
{
}
void
ConfigFile::addSectionHandler(const std::string& sectionName,
ConfigSectionHandler subscriber)
{
m_subscriptions[sectionName] = subscriber;
}
void
ConfigFile::parse(const std::string& filename, bool isDryRun)
{
std::ifstream inputFile;
inputFile.open(filename.c_str());
if (!inputFile.good() || !inputFile.is_open())
{
std::string msg = "Failed to read configuration file: ";
msg += filename;
throw Error(msg);
}
parse(inputFile, isDryRun, filename);
inputFile.close();
}
void
ConfigFile::parse(const std::string& input, bool isDryRun, const std::string& filename)
{
std::istringstream inputStream(input);
parse(inputStream, isDryRun, filename);
}
void
ConfigFile::parse(std::istream& input, bool isDryRun, const std::string& filename)
{
try
{
boost::property_tree::read_info(input, m_global);
}
catch (const boost::property_tree::info_parser_error& error)
{
std::stringstream msg;
msg << "Failed to parse configuration file";
msg << " " << filename;
msg << " " << error.message() << " line " << error.line();
throw Error(msg.str());
}
process(isDryRun, filename);
}
void
ConfigFile::process(bool isDryRun, const std::string& filename)
{
BOOST_ASSERT(!filename.empty());
// NFD_LOG_DEBUG("processing..." << ((isDryRun)?("dry run"):("")));
if (m_global.begin() == m_global.end())
{
std::string msg = "Error processing configuration file: ";
msg += filename;
msg += " no data";
throw Error(msg);
}
for (ConfigSection::const_iterator i = m_global.begin(); i != m_global.end(); ++i)
{
const std::string& sectionName = i->first;
const ConfigSection& section = i->second;
SubscriptionTable::iterator subscriberIt = m_subscriptions.find(sectionName);
if (subscriberIt != m_subscriptions.end())
{
ConfigSectionHandler subscriber = subscriberIt->second;
subscriber(section, isDryRun, filename);
}
else
{
m_unknownSectionCallback(filename, sectionName, section, isDryRun);
}
}
}
}
-128
View File
@@ -1,128 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_CONFIG_FILE_HPP
#define NFD_CORE_CONFIG_FILE_HPP
#include "common.hpp"
#include <boost/property_tree/ptree.hpp>
namespace nfd {
typedef boost::property_tree::ptree ConfigSection;
/// \brief callback for config file sections
typedef function<void(const ConfigSection& /*section*/,
bool /*isDryRun*/,
const std::string& /*filename*/)> ConfigSectionHandler;
/// \brief callback for config file sections without a subscribed handler
typedef function<void(const std::string& /*filename*/,
const std::string& /*sectionName*/,
const ConfigSection& /*section*/,
bool /*isDryRun*/)> UnknownConfigSectionHandler;
class ConfigFile : noncopyable
{
public:
class Error : public std::runtime_error
{
public:
explicit
Error(const std::string& what)
: std::runtime_error(what)
{
}
};
ConfigFile(UnknownConfigSectionHandler unknownSectionCallback = throwErrorOnUnknownSection);
static void
throwErrorOnUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun);
static void
ignoreUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun);
/// \brief setup notification of configuration file sections
void
addSectionHandler(const std::string& sectionName,
ConfigSectionHandler subscriber);
/**
* \param filename file to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \throws ConfigFile::Error if file not found
* \throws ConfigFile::Error if parse error
*/
void
parse(const std::string& filename, bool isDryRun);
/**
* \param input configuration (as a string) to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \param filename optional convenience argument to provide more detailed error messages
* \throws ConfigFile::Error if file not found
* \throws ConfigFile::Error if parse error
*/
void
parse(const std::string& input, bool isDryRun, const std::string& filename);
/**
* \param input stream to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \param filename optional convenience argument to provide more detailed error messages
* \throws ConfigFile::Error if parse error
*/
void
parse(std::istream& input, bool isDryRun, const std::string& filename);
private:
void
process(bool isDryRun, const std::string& filename);
private:
UnknownConfigSectionHandler m_unknownSectionCallback;
typedef std::map<std::string, ConfigSectionHandler> SubscriptionTable;
SubscriptionTable m_subscriptions;
ConfigSection m_global;
};
} // namespace nfd
#endif // NFD_CORE_CONFIG_FILE_HPP
-82
View File
@@ -1,82 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "ethernet.hpp"
#include <stdio.h>
namespace nfd {
namespace ethernet {
std::string
Address::toString(char sep) const
{
char s[18]; // 12 digits + 5 separators + null terminator
::snprintf(s, sizeof(s), "%02x%c%02x%c%02x%c%02x%c%02x%c%02x",
elems[0], sep, elems[1], sep, elems[2], sep,
elems[3], sep, elems[4], sep, elems[5]);
return std::string(s);
}
Address
Address::fromString(const std::string& str)
{
unsigned short temp[ADDR_LEN];
char sep[5][2]; // 5 * (1 separator char + 1 null terminator)
int n = 0; // num of chars read from the input string
// ISO C++98 does not support the 'hh' type modifier
/// \todo use SCNx8 (cinttypes) when we enable C++11
int ret = ::sscanf(str.c_str(), "%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%n",
&temp[0], &sep[0][0], &temp[1], &sep[1][0], &temp[2], &sep[2][0],
&temp[3], &sep[3][0], &temp[4], &sep[4][0], &temp[5], &n);
if (ret < 11 || static_cast<size_t>(n) != str.length())
return Address();
Address a;
for (size_t i = 0; i < ADDR_LEN; ++i)
{
// check that all separators are actually the same char (: or -)
if (i < 5 && sep[i][0] != sep[0][0])
return Address();
// check that each value fits into a uint8_t
if (temp[i] > 0xFF)
return Address();
a[i] = static_cast<uint8_t>(temp[i]);
}
return a;
}
std::ostream&
operator<<(std::ostream& o, const Address& a)
{
return o << a.toString();
}
} // namespace ethernet
} // namespace nfd
-167
View File
@@ -1,167 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_ETHERNET_HPP
#define NFD_CORE_ETHERNET_HPP
#include "common.hpp"
#include <boost/array.hpp>
#define ETHERTYPE_NDN 0x8624
namespace nfd {
namespace ethernet {
const size_t ADDR_LEN = 6; ///< Octets in one Ethernet address
const size_t TYPE_LEN = 2; ///< Octets in Ethertype field
const size_t HDR_LEN = 14; ///< Total octets in Ethernet header (without 802.1Q tag)
const size_t TAG_LEN = 4; ///< Octets in 802.1Q tag (TPID + priority + VLAN)
const size_t MIN_DATA_LEN = 46; ///< Min octets in Ethernet payload (assuming no 802.1Q tag)
const size_t MAX_DATA_LEN = 1500; ///< Max octets in Ethernet payload
const size_t CRC_LEN = 4; ///< Octets in Ethernet frame check sequence
class Address : public boost::array<uint8_t, ADDR_LEN>
{
public:
/// Constructs a null Ethernet address (00:00:00:00:00:00)
Address();
/// Constructs a new Ethernet address with the given octets
Address(uint8_t a1, uint8_t a2, uint8_t a3,
uint8_t a4, uint8_t a5, uint8_t a6);
/// Constructs a new Ethernet address with the given octets
explicit
Address(const uint8_t octets[ADDR_LEN]);
/// Copy constructor
Address(const Address& address);
/// True if this is a broadcast address (ff:ff:ff:ff:ff:ff)
bool
isBroadcast() const;
/// True if this is a multicast address
bool
isMulticast() const;
/// True if this is a null address (00:00:00:00:00:00)
bool
isNull() const;
/**
* @brief Converts the address to a human-readable string
*
* @param sep A character used to visually separate the octets,
* usually ':' (the default value) or '-'
*/
std::string
toString(char sep = ':') const;
/**
* @brief Creates an Address from a string containing an Ethernet address
* in hexadecimal notation, with colons or hyphens as separators
*
* @param str The string to be parsed
* @return Always an instance of Address, which will be null
* if the parsing fails
*/
static Address
fromString(const std::string& str);
};
/// Returns the Ethernet broadcast address (ff:ff:ff:ff:ff:ff)
inline Address
getBroadcastAddress()
{
static Address bcast(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
return bcast;
}
/// Returns the default Ethernet multicast address for NDN
inline Address
getDefaultMulticastAddress()
{
static Address mcast(0x01, 0x00, 0x5E, 0x00, 0x17, 0xAA);
return mcast;
}
inline
Address::Address()
{
assign(0);
}
inline
Address::Address(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6)
{
elems[0] = a1;
elems[1] = a2;
elems[2] = a3;
elems[3] = a4;
elems[4] = a5;
elems[5] = a6;
}
inline
Address::Address(const uint8_t octets[])
{
std::copy(octets, octets + size(), begin());
}
inline
Address::Address(const Address& address)
{
std::copy(address.begin(), address.end(), begin());
}
inline bool
Address::isBroadcast() const
{
return elems[0] == 0xFF && elems[1] == 0xFF && elems[2] == 0xFF &&
elems[3] == 0xFF && elems[4] == 0xFF && elems[5] == 0xFF;
}
inline bool
Address::isMulticast() const
{
return (elems[0] & 1) != 0;
}
inline bool
Address::isNull() const
{
return elems[0] == 0x0 && elems[1] == 0x0 && elems[2] == 0x0 &&
elems[3] == 0x0 && elems[4] == 0x0 && elems[5] == 0x0;
}
std::ostream&
operator<<(std::ostream& o, const Address& a);
} // namespace ethernet
} // namespace nfd
#endif // NFD_FACE_ETHERNET_HPP
-343
View File
@@ -1,343 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_EVENT_EMITTER_HPP
#define NFD_CORE_EVENT_EMITTER_HPP
#include "common.hpp"
namespace nfd {
struct empty {};
/** \class EventEmitter
* \brief provides a lightweight event system
*
* To declare an event:
* EventEmitter<TArgs> m_eventName;
* To subscribe to an event:
* eventSource->m_eventName += eventHandler;
* Multiple functions can subscribe to the same event.
* To trigger an event:
* m_eventName(args);
* To clear event subscriptions:
* m_eventName.clear();
*/
// four arguments
template<typename T1 = empty, typename T2 = empty,
typename T3 = empty, typename T4 = empty>
class EventEmitter : noncopyable
{
public:
/// represents a handler that can subscribe to the event
typedef function<void(const T1&, const T2&,
const T3&, const T4&)> Handler;
/// adds an subscription
void
operator+=(Handler handler);
/// returns true if there is no subscription,
/// otherwise returns false
bool
isEmpty();
/// clears all subscriptions
void
clear();
/// triggers the event
void
operator()(const T1& a1, const T2& a2, const T3& a3, const T4& a4);
private:
/// stores all subscribed handlers
std::vector<Handler> m_handlers;
};
// zero argument
template<>
class EventEmitter<empty, empty, empty, empty> : noncopyable
{
public:
typedef function<void()> Handler;
void
operator+=(Handler handler);
bool
isEmpty();
void
clear();
void
operator()();
private:
std::vector<Handler> m_handlers;
};
// one argument
template<typename T1>
class EventEmitter<T1, empty, empty, empty> : noncopyable
{
public:
typedef function<void(const T1&)> Handler;
void
operator+=(Handler handler);
bool
isEmpty();
void
clear();
void
operator()(const T1& a1);
private:
std::vector<Handler> m_handlers;
};
// two arguments
template<typename T1, typename T2>
class EventEmitter<T1, T2, empty, empty> : noncopyable
{
public:
typedef function<void(const T1&, const T2&)> Handler;
void
operator+=(Handler handler);
bool
isEmpty();
void
clear();
void
operator()(const T1& a1, const T2& a2);
private:
std::vector<Handler> m_handlers;
};
// three arguments
template<typename T1, typename T2, typename T3>
class EventEmitter<T1, T2, T3, empty> : noncopyable
{
public:
typedef function<void(const T1&, const T2&, const T3&)> Handler;
void
operator+=(Handler handler);
bool
isEmpty();
void
clear();
void
operator()(const T1& a1, const T2& a2, const T3& a3);
private:
std::vector<Handler> m_handlers;
};
// zero argument
inline void
EventEmitter<empty, empty, empty, empty>::operator+=(Handler handler)
{
m_handlers.push_back(handler);
}
inline bool
EventEmitter<empty, empty, empty, empty>::isEmpty()
{
return m_handlers.empty();
}
inline void
EventEmitter<empty, empty, empty, empty>::clear()
{
return m_handlers.clear();
}
inline void
EventEmitter<empty, empty, empty, empty>::operator()()
{
std::vector<Handler>::iterator it;
for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
(*it)();
}
}
// one argument
template<typename T1>
inline void
EventEmitter<T1, empty, empty, empty>::operator+=(Handler handler)
{
m_handlers.push_back(handler);
}
template<typename T1>
inline bool
EventEmitter<T1, empty, empty, empty>::isEmpty()
{
return m_handlers.empty();
}
template<typename T1>
inline void
EventEmitter<T1, empty, empty, empty>::clear()
{
return m_handlers.clear();
}
template<typename T1>
inline void
EventEmitter<T1, empty, empty, empty>::operator()(const T1& a1)
{
typename std::vector<Handler>::iterator it;
for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
(*it)(a1);
}
}
// two arguments
template<typename T1, typename T2>
inline void
EventEmitter<T1, T2, empty, empty>::operator+=(Handler handler)
{
m_handlers.push_back(handler);
}
template<typename T1, typename T2>
inline bool
EventEmitter<T1, T2, empty, empty>::isEmpty()
{
return m_handlers.empty();
}
template<typename T1, typename T2>
inline void
EventEmitter<T1, T2, empty, empty>::clear()
{
return m_handlers.clear();
}
template<typename T1, typename T2>
inline void
EventEmitter<T1, T2, empty, empty>::operator()
(const T1& a1, const T2& a2)
{
typename std::vector<Handler>::iterator it;
for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
(*it)(a1, a2);
}
}
// three arguments
template<typename T1, typename T2, typename T3>
inline void
EventEmitter<T1, T2, T3, empty>::operator+=(Handler handler)
{
m_handlers.push_back(handler);
}
template<typename T1, typename T2, typename T3>
inline bool
EventEmitter<T1, T2, T3, empty>::isEmpty()
{
return m_handlers.empty();
}
template<typename T1, typename T2, typename T3>
inline void
EventEmitter<T1, T2, T3, empty>::clear()
{
return m_handlers.clear();
}
template<typename T1, typename T2, typename T3>
inline void
EventEmitter<T1, T2, T3, empty>::operator()
(const T1& a1, const T2& a2, const T3& a3)
{
typename std::vector<Handler>::iterator it;
for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
(*it)(a1, a2, a3);
}
}
// four arguments
template<typename T1, typename T2, typename T3, typename T4>
inline void
EventEmitter<T1, T2, T3, T4>::operator+=(Handler handler)
{
m_handlers.push_back(handler);
}
template<typename T1, typename T2, typename T3, typename T4>
inline bool
EventEmitter<T1, T2, T3, T4>::isEmpty()
{
return m_handlers.empty();
}
template<typename T1, typename T2, typename T3, typename T4>
inline void
EventEmitter<T1, T2, T3, T4>::clear()
{
return m_handlers.clear();
}
template<typename T1, typename T2, typename T3, typename T4>
inline void
EventEmitter<T1, T2, T3, T4>::operator()
(const T1& a1, const T2& a2, const T3& a3, const T4& a4)
{
typename std::vector<Handler>::iterator it;
for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
(*it)(a1, a2, a3, a4);
}
}
} // namespace nfd
#endif // NFD_CORE_EVENT_EMITTER_HPP
-165
View File
@@ -1,165 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "face-monitor.hpp"
#include "core/logger.hpp"
#include <ndn-cxx/face.hpp>
namespace nfd {
NFD_LOG_INIT("FaceMonitor");
FaceMonitor::FaceMonitor(ndn::Face& face)
: m_face(face)
, m_isStopped(true)
{
}
FaceMonitor::~FaceMonitor()
{
}
void
FaceMonitor::removeAllSubscribers()
{
m_notificationCallbacks.clear();
m_timeoutCallbacks.clear();
stopNotifications();
}
void
FaceMonitor::stopNotifications()
{
if (static_cast<bool>(m_lastInterestId))
m_face.removePendingInterest(m_lastInterestId);
m_isStopped = true;
}
void
FaceMonitor::startNotifications()
{
if (m_isStopped == false)
return; // Notifications cycle has been started.
m_isStopped = false;
Interest interest("/localhost/nfd/faces/events");
interest
.setMustBeFresh(true)
.setChildSelector(1)
.setInterestLifetime(time::seconds(60))
;
NFD_LOG_DEBUG("startNotification: Interest Sent: " << interest);
m_lastInterestId = m_face.expressInterest(interest,
bind(&FaceMonitor::onNotification, this, _2),
bind(&FaceMonitor::onTimeout, this));
}
void
FaceMonitor::addSubscriber(const NotificationCallback& notificationCallback)
{
addSubscriber(notificationCallback, TimeoutCallback());
}
void
FaceMonitor::addSubscriber(const NotificationCallback& notificationCallback,
const TimeoutCallback& timeoutCallback)
{
if (static_cast<bool>(notificationCallback))
m_notificationCallbacks.push_back(notificationCallback);
if (static_cast<bool>(timeoutCallback))
m_timeoutCallbacks.push_back(timeoutCallback);
}
void
FaceMonitor::onTimeout()
{
if (m_isStopped)
return;
std::vector<TimeoutCallback>::iterator it;
for (it = m_timeoutCallbacks.begin();
it != m_timeoutCallbacks.end(); ++it) {
(*it)();
//One of the registered callbacks has cleared the vector,
//return now as the iterator has been invalidated and
//the vector is empty.
if (m_timeoutCallbacks.empty()) {
return;
}
}
Interest newInterest("/localhost/nfd/faces/events");
newInterest
.setMustBeFresh(true)
.setChildSelector(1)
.setInterestLifetime(time::seconds(60))
;
NFD_LOG_DEBUG("In onTimeout, sending interest: " << newInterest);
m_lastInterestId = m_face.expressInterest(newInterest,
bind(&FaceMonitor::onNotification, this, _2),
bind(&FaceMonitor::onTimeout, this));
}
void
FaceMonitor::onNotification(const Data& data)
{
if (m_isStopped)
return;
m_lastSequence = data.getName().get(-1).toSegment();
ndn::nfd::FaceEventNotification notification(data.getContent().blockFromValue());
std::vector<NotificationCallback>::iterator it;
for (it = m_notificationCallbacks.begin();
it != m_notificationCallbacks.end(); ++it) {
(*it)(notification);
if (m_notificationCallbacks.empty()) {
//One of the registered callbacks has cleared the vector.
//return back, as no one is interested in notifications anymore.
return;
}
}
//Setting up next notification
Name nextNotification("/localhost/nfd/faces/events");
nextNotification.appendSegment(m_lastSequence + 1);
Interest interest(nextNotification);
interest.setInterestLifetime(time::seconds(60));
NFD_LOG_DEBUG("onNotification: Interest sent: " << interest);
m_lastInterestId = m_face.expressInterest(interest,
bind(&FaceMonitor::onNotification, this, _2),
bind(&FaceMonitor::onTimeout, this));
}
} // namespace nfd
-105
View File
@@ -1,105 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_FACE_MONITOR_HPP
#define NFD_CORE_FACE_MONITOR_HPP
#include "common.hpp"
#include <ndn-cxx/management/nfd-face-event-notification.hpp>
namespace ndn {
class Face;
class PendingInterestId;
}
namespace nfd {
using ndn::nfd::FaceEventNotification;
/**
* \brief Helper class to subscribe to face notification events
*
* \todo Write test cases
*/
class FaceMonitor : noncopyable
{
public:
typedef function<void(const ndn::nfd::FaceEventNotification&)> NotificationCallback;
typedef function<void()> TimeoutCallback;
typedef std::vector<NotificationCallback> NotificationCallbacks;
typedef std::vector<TimeoutCallback> TimeoutCallbacks;
explicit
FaceMonitor(ndn::Face& face);
~FaceMonitor();
/** \brief Stops all notifications. This method doesn't remove registered callbacks.
*/
void
stopNotifications();
/** \brief Resumes notifications for added subscribers.
*/
void
startNotifications();
/** \brief Removes all notification subscribers.
*/
void
removeAllSubscribers();
/** \brief Adds a notification subscriber. This method doesn't return on timeouts.
*/
void
addSubscriber(const NotificationCallback& notificationCallback);
/** \brief Adds a notification subscriber.
*/
void
addSubscriber(const NotificationCallback& notificationCallback,
const TimeoutCallback& timeoutCallback);
private:
void
onTimeout();
void
onNotification(const Data& data);
private:
ndn::Face& m_face;
uint64_t m_lastSequence;
bool m_isStopped;
NotificationCallbacks m_notificationCallbacks;
TimeoutCallbacks m_timeoutCallbacks;
const ndn::PendingInterestId* m_lastInterestId;
};
} // namespace nfd
#endif // NFD_CORE_FACE_MONITOR_HPP
-163
View File
@@ -1,163 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "face-uri.hpp"
#include "core/logger.hpp"
#ifdef HAVE_LIBPCAP
#include "ethernet.hpp"
#endif // HAVE_LIBPCAP
#include <boost/regex.hpp>
NFD_LOG_INIT("FaceUri");
namespace nfd {
FaceUri::FaceUri(const std::string& uri)
{
if (!parse(uri)) {
throw Error("Malformed URI: " + uri);
}
}
FaceUri::FaceUri(const char* uri)
{
if (!parse(uri)) {
throw Error("Malformed URI: " + std::string(uri));
}
}
bool
FaceUri::parse(const std::string& uri)
{
m_scheme.clear();
m_host.clear();
m_isV6 = false;
m_port.clear();
m_path.clear();
static const boost::regex protocolExp("(\\w+\\d?)://([^/]*)(\\/[^?]*)?");
boost::smatch protocolMatch;
if (!boost::regex_match(uri, protocolMatch, protocolExp)) {
return false;
}
m_scheme = protocolMatch[1];
const std::string& authority = protocolMatch[2];
m_path = protocolMatch[3];
// pattern for IPv6 address enclosed in [ ], with optional port number
static const boost::regex v6Exp("^\\[([a-fA-F0-9:]+)\\](?:\\:(\\d+))?$");
// pattern for Ethernet address in standard hex-digits-and-colons notation
static const boost::regex etherExp("^\\[((?:[a-fA-F0-9]{1,2}\\:){5}(?:[a-fA-F0-9]{1,2}))\\]$");
// pattern for IPv4-mapped IPv6 address, with optional port number
static const boost::regex v4MappedV6Exp("^\\[::ffff:(\\d+(?:\\.\\d+){3})\\](?:\\:(\\d+))?$");
// pattern for IPv4/hostname/fd/ifname, with optional port number
static const boost::regex v4HostExp("^([^:]+)(?:\\:(\\d+))?$");
if (authority.empty()) {
// UNIX, internal
}
else {
boost::smatch match;
m_isV6 = boost::regex_match(authority, match, v6Exp);
if (m_isV6 ||
boost::regex_match(authority, match, etherExp) ||
boost::regex_match(authority, match, v4MappedV6Exp) ||
boost::regex_match(authority, match, v4HostExp)) {
m_host = match[1];
m_port = match[2];
}
else {
return false;
}
}
NFD_LOG_DEBUG("URI [" << uri << "] parsed into: " <<
m_scheme << ", " << m_host << ", " << m_port << ", " << m_path);
return true;
}
FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint)
{
m_isV6 = endpoint.address().is_v6();
m_scheme = m_isV6 ? "tcp6" : "tcp4";
m_host = endpoint.address().to_string();
m_port = boost::lexical_cast<std::string>(endpoint.port());
}
FaceUri::FaceUri(const boost::asio::ip::udp::endpoint& endpoint)
{
m_isV6 = endpoint.address().is_v6();
m_scheme = m_isV6 ? "udp6" : "udp4";
m_host = endpoint.address().to_string();
m_port = boost::lexical_cast<std::string>(endpoint.port());
}
FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint, const std::string& scheme)
: m_scheme(scheme)
{
m_isV6 = endpoint.address().is_v6();
m_host = endpoint.address().to_string();
m_port = boost::lexical_cast<std::string>(endpoint.port());
}
#ifdef HAVE_UNIX_SOCKETS
FaceUri::FaceUri(const boost::asio::local::stream_protocol::endpoint& endpoint)
: m_isV6(false)
{
m_scheme = "unix";
m_path = endpoint.path();
}
#endif // HAVE_UNIX_SOCKETS
FaceUri
FaceUri::fromFd(int fd)
{
FaceUri uri;
uri.m_scheme = "fd";
uri.m_host = boost::lexical_cast<std::string>(fd);
return uri;
}
#ifdef HAVE_LIBPCAP
FaceUri::FaceUri(const ethernet::Address& address)
: m_isV6(true)
{
m_scheme = "ether";
m_host = address.toString();
}
#endif // HAVE_LIBPCAP
FaceUri
FaceUri::fromDev(const std::string& ifname)
{
FaceUri uri;
uri.m_scheme = "dev";
uri.m_host = ifname;
return uri;
}
} // namespace nfd
-219
View File
@@ -1,219 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_FACE_URI_H
#define NFD_CORE_FACE_URI_H
#include "common.hpp"
namespace nfd {
#ifdef HAVE_LIBPCAP
namespace ethernet {
class Address;
} // namespace ethernet
#endif // HAVE_LIBPCAP
/** \brief represents the underlying protocol and address used by a Face
* \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#FaceUri
*/
class FaceUri
{
public:
class Error : public std::invalid_argument
{
public:
explicit
Error(const std::string& what)
: std::invalid_argument(what)
{
}
};
FaceUri();
/** \brief construct by parsing
*
* \param uri scheme://host[:port]/path
* \throw FaceUri::Error if URI cannot be parsed
*/
explicit
FaceUri(const std::string& uri);
// This overload is needed so that calls with string literal won't be
// resolved to boost::asio::local::stream_protocol::endpoint overload.
explicit
FaceUri(const char* uri);
/// exception-safe parsing
bool
parse(const std::string& uri);
public: // scheme-specific construction
/// construct tcp4 or tcp6 canonical FaceUri
explicit
FaceUri(const boost::asio::ip::tcp::endpoint& endpoint);
/// construct udp4 or udp6 canonical FaceUri
explicit
FaceUri(const boost::asio::ip::udp::endpoint& endpoint);
/// construct tcp canonical FaceUri with customized scheme
FaceUri(const boost::asio::ip::tcp::endpoint& endpoint, const std::string& scheme);
#ifdef HAVE_UNIX_SOCKETS
/// construct unix canonical FaceUri
explicit
FaceUri(const boost::asio::local::stream_protocol::endpoint& endpoint);
#endif // HAVE_UNIX_SOCKETS
/// create fd FaceUri from file descriptor
static FaceUri
fromFd(int fd);
#ifdef HAVE_LIBPCAP
/// construct ether canonical FaceUri
explicit
FaceUri(const ethernet::Address& address);
#endif // HAVE_LIBPCAP
/// create dev FaceUri from network device name
static FaceUri
fromDev(const std::string& ifname);
public: // getters
/// get scheme (protocol)
const std::string&
getScheme() const;
/// get host (domain)
const std::string&
getHost() const;
/// get port
const std::string&
getPort() const;
/// get path
const std::string&
getPath() const;
/// write as a string
std::string
toString() const;
public: // EqualityComparable concept
/// equality operator
bool
operator==(const FaceUri& rhs) const;
/// inequality operator
bool
operator!=(const FaceUri& rhs) const;
private:
std::string m_scheme;
std::string m_host;
/// whether to add [] around host when writing string
bool m_isV6;
std::string m_port;
std::string m_path;
friend std::ostream& operator<<(std::ostream& os, const FaceUri& uri);
};
inline
FaceUri::FaceUri()
: m_isV6(false)
{
}
inline const std::string&
FaceUri::getScheme() const
{
return m_scheme;
}
inline const std::string&
FaceUri::getHost() const
{
return m_host;
}
inline const std::string&
FaceUri::getPort() const
{
return m_port;
}
inline const std::string&
FaceUri::getPath() const
{
return m_path;
}
inline std::string
FaceUri::toString() const
{
std::ostringstream os;
os << *this;
return os.str();
}
inline bool
FaceUri::operator==(const FaceUri& rhs) const
{
return (m_scheme == rhs.m_scheme &&
m_host == rhs.m_host &&
m_isV6 == rhs.m_isV6 &&
m_port == rhs.m_port &&
m_path == rhs.m_path);
}
inline bool
FaceUri::operator!=(const FaceUri& rhs) const
{
return !(*this == rhs);
}
inline std::ostream&
operator<<(std::ostream& os, const FaceUri& uri)
{
os << uri.m_scheme << "://";
if (uri.m_isV6) {
os << "[" << uri.m_host << "]";
}
else {
os << uri.m_host;
}
if (!uri.m_port.empty()) {
os << ":" << uri.m_port;
}
os << uri.m_path;
return os;
}
} // namespace nfd
#endif // NFD_CORE_FACE_URI_H
-213
View File
@@ -1,213 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "logger-factory.hpp"
namespace nfd {
NFD_LOG_INIT("LoggerFactory");
LoggerFactory&
LoggerFactory::getInstance()
{
static LoggerFactory globalLoggerFactory;
return globalLoggerFactory;
}
LoggerFactory::LoggerFactory()
: m_defaultLevel(LOG_INFO)
{
m_levelNames["NONE"] = LOG_NONE;
m_levelNames["ERROR"] = LOG_ERROR;
m_levelNames["WARN"] = LOG_WARN;
m_levelNames["INFO"] = LOG_INFO;
m_levelNames["DEBUG"] = LOG_DEBUG;
m_levelNames["TRACE"] = LOG_TRACE;
m_levelNames["ALL"] = LOG_ALL;
}
void
LoggerFactory::setConfigFile(ConfigFile& config)
{
config.addSectionHandler("log", bind(&LoggerFactory::onConfig, this, _1, _2, _3));
}
LogLevel
LoggerFactory::parseLevel(const std::string& level)
{
std::string upperLevel = level;
boost::to_upper(upperLevel);
// std::cerr << "parsing level: " << upperLevel << std::endl;;
// std::cerr << "# levels: " << m_levelNames.size() << std::endl;
// std::cerr << m_levelNames.begin()->first << std::endl;
LevelMap::const_iterator levelIt = m_levelNames.find(upperLevel);
if (levelIt != m_levelNames.end())
{
return levelIt->second;
}
try
{
uint32_t levelNo = boost::lexical_cast<uint32_t>(level);
if ((boost::lexical_cast<uint32_t>(LOG_NONE) <= levelNo &&
levelNo <= boost::lexical_cast<uint32_t>(LOG_TRACE)) ||
levelNo == LOG_ALL)
{
return static_cast<LogLevel>(levelNo);
}
}
catch (const boost::bad_lexical_cast& error)
{
}
throw LoggerFactory::Error("Unsupported logging level \"" +
level + "\"");
}
LogLevel
LoggerFactory::extractLevel(const ConfigSection& item, const std::string& key)
{
std::string levelString;
try
{
levelString = item.get_value<std::string>();
}
catch (const boost::property_tree::ptree_error& error)
{
}
if (levelString.empty())
{
throw LoggerFactory::Error("No logging level found for option \"" + key + "\"");
}
return parseLevel(levelString);
}
void
LoggerFactory::onConfig(const ConfigSection& section,
bool isDryRun,
const std::string& filename)
{
// log
// {
// ; default_level specifies the logging level for modules
// ; that are not explicitly named. All debugging levels
// ; listed above the selected value are enabled.
//
// default_level INFO
//
// ; You may also override the default for specific modules:
//
// FibManager DEBUG
// Forwarder WARN
// }
if (!isDryRun)
{
ConfigSection::const_assoc_iterator item = section.find("default_level");
if (item != section.not_found())
{
LogLevel level = extractLevel(item->second, "default_level");
setDefaultLevel(level);
}
else
{
setDefaultLevel(LOG_INFO);
}
}
for (ConfigSection::const_iterator item = section.begin();
item != section.end();
++item)
{
LogLevel level = extractLevel(item->second, item->first);
if (item->first == "default_level")
{
// do nothing
}
else
{
LoggerMap::iterator loggerIt = m_loggers.find(item->first);
if (loggerIt == m_loggers.end())
{
NFD_LOG_DEBUG("Failed to configure logging level for module \"" <<
item->first << "\" (module not found)");
}
else if (!isDryRun)
{
// std::cerr << "changing level for module " << item->first << " to " << level << std::endl;
loggerIt->second.setLogLevel(level);
}
}
}
}
void
LoggerFactory::setDefaultLevel(LogLevel level)
{
// std::cerr << "changing to default_level " << level << std::endl;
m_defaultLevel = level;
for (LoggerMap::iterator i = m_loggers.begin(); i != m_loggers.end(); ++i)
{
// std::cerr << "changing " << i->first << " to default " << m_defaultLevel << std::endl;
i->second.setLogLevel(m_defaultLevel);
}
}
Logger&
LoggerFactory::create(const std::string& moduleName)
{
return LoggerFactory::getInstance().createLogger(moduleName);
}
Logger&
LoggerFactory::createLogger(const std::string& moduleName)
{
// std::cerr << "creating logger for " << moduleName
// << " with level " << m_defaultLevel << std::endl;
std::pair<LoggerMap::iterator, bool> loggerIt =
m_loggers.insert(NameAndLogger(moduleName, Logger(moduleName, m_defaultLevel)));
return loggerIt.first->second;
}
std::list<std::string>
LoggerFactory::getModules() const
{
std::list<std::string> modules;
for (LoggerMap::const_iterator i = m_loggers.begin(); i != m_loggers.end(); ++i)
{
modules.push_back(i->first);
}
return modules;
}
} // namespace nfd
-110
View File
@@ -1,110 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_LOGGER_FACTORY_HPP
#define NFD_CORE_LOGGER_FACTORY_HPP
#include "common.hpp"
#include "config-file.hpp"
#include "logger.hpp"
namespace nfd {
class LoggerFactory : noncopyable
{
public:
class Error : public std::runtime_error
{
public:
explicit
Error(const std::string& error)
: std::runtime_error(error)
{
}
};
static LoggerFactory&
getInstance();
void
setConfigFile(ConfigFile& config);
void
onConfig(const ConfigSection& section, bool isDryRun, const std::string& filename);
std::list<std::string>
getModules() const;
static Logger&
create(const std::string& moduleName);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
// these methods are used during unit-testing
LogLevel
getDefaultLevel() const;
void
setDefaultLevel(LogLevel level);
private:
LoggerFactory();
Logger&
createLogger(const std::string& moduleName);
LogLevel
parseLevel(const std::string& level);
LogLevel
extractLevel(const ConfigSection& item, const std::string& key);
private:
typedef std::map<std::string, LogLevel> LevelMap;
typedef std::pair<std::string, LogLevel> NameAndLevel;
LevelMap m_levelNames;
typedef std::map<std::string, Logger> LoggerMap;
typedef std::pair<std::string, Logger> NameAndLogger;
LoggerMap m_loggers;
LogLevel m_defaultLevel;
};
inline LogLevel
LoggerFactory::getDefaultLevel() const
{
return m_defaultLevel;
}
} // namespace nfd
#endif // NFD_CORE_LOGGER_FACTORY_HPP
-176
View File
@@ -1,176 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_LOGGER_HPP
#define NFD_CORE_LOGGER_HPP
#include "common.hpp"
#include <ndn-cxx/util/time.hpp>
/// \todo use when we enable C++11 (see todo in now())
// #include <cinttypes>
namespace nfd {
enum LogLevel {
LOG_NONE = 0, // no messages
LOG_ERROR = 1, // serious error messages
LOG_WARN = 2, // warning messages
LOG_INFO = 3, // informational messages
LOG_DEBUG = 4, // debug messages
LOG_TRACE = 5, // trace messages (most verbose)
// LOG_FATAL is not a level and is logged unconditionally
LOG_ALL = 255 // all messages
};
class Logger
{
public:
Logger(const std::string& name, LogLevel level)
: m_moduleName(name)
, m_enabledLogLevel(level)
{
}
bool
isEnabled(LogLevel level) const
{
// std::cerr << m_moduleName <<
// " enabled = " << m_enabledLogLevel
// << " level = " << level << std::endl;
return (m_enabledLogLevel >= level);
}
void
setLogLevel(LogLevel level)
{
m_enabledLogLevel = level;
}
const std::string&
getName() const
{
return m_moduleName;
}
void
setName(const std::string& name)
{
m_moduleName = name;
}
/// \brief return a string representation of time since epoch: seconds.microseconds
static std::string
now()
{
using namespace ndn::time;
static const microseconds::rep ONE_SECOND = 1000000;
microseconds::rep microseconds_since_epoch =
duration_cast<microseconds>(system_clock::now().time_since_epoch()).count();
// 10 (whole seconds) + '.' + 6 (fraction) + 1 (\0)
char buffer[10 + 1 + 6 + 1];
::snprintf(buffer, sizeof(buffer), "%lld.%06lld",
static_cast<long long int>(microseconds_since_epoch / ONE_SECOND),
static_cast<long long int>(microseconds_since_epoch % ONE_SECOND));
/// \todo use this version when we enable C++11 to avoid casting
// ::snprintf(buffer, sizeof(buffer), "%" PRIdLEAST64 ".%06" PRIdLEAST64,
// microseconds_since_epoch / ONE_SECOND,
// microseconds_since_epoch % ONE_SECOND);
return std::string(buffer);
}
private:
std::string m_moduleName;
LogLevel m_enabledLogLevel;
};
inline std::ostream&
operator<<(std::ostream& output, const Logger& logger)
{
output << logger.getName();
return output;
}
} // namespace nfd
#include "core/logger-factory.hpp"
namespace nfd {
#define NFD_LOG_INIT(name) \
static nfd::Logger& g_logger = nfd::LoggerFactory::create(name)
#define NFD_LOG_INCLASS_DECLARE() \
static nfd::Logger& g_logger
#define NFD_LOG_INCLASS_DEFINE(cls, name) \
nfd::Logger& cls::g_logger = nfd::LoggerFactory::create(name)
#define NFD_LOG_INCLASS_TEMPLATE_DEFINE(cls, name) \
template<class T> \
nfd::Logger& cls<T>::g_logger = nfd::LoggerFactory::create(name)
#define NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(cls, specialization, name) \
template<> \
nfd::Logger& cls<specialization>::g_logger = nfd::LoggerFactory::create(name)
#define NFD_LOG_INCLASS_2TEMPLATE_SPECIALIZATION_DEFINE(cls, s1, s2, name) \
template<> \
nfd::Logger& cls<s1, s2>::g_logger = nfd::LoggerFactory::create(name)
#define NFD_LOG(level, expression) \
do { \
if (g_logger.isEnabled(::nfd::LOG_##level)) \
std::clog << ::nfd::Logger::now() << " "#level": " \
<< "[" << g_logger << "] " << expression << "\n"; \
} while (false)
#define NFD_LOG_TRACE(expression) NFD_LOG(TRACE, expression)
#define NFD_LOG_DEBUG(expression) NFD_LOG(DEBUG, expression)
#define NFD_LOG_INFO(expression) NFD_LOG(INFO, expression)
#define NFD_LOG_ERROR(expression) NFD_LOG(ERROR, expression)
// specialize WARN because the message is "WARNING" instead of "WARN"
#define NFD_LOG_WARN(expression) \
do { \
if (g_logger.isEnabled(::nfd::LOG_WARN)) \
std::clog << ::nfd::Logger::now() << " WARNING: " \
<< "[" << g_logger << "] " << expression << "\n"; \
} while (false)
#define NFD_LOG_FATAL(expression) \
do { \
std::clog << ::nfd::Logger::now() << " FATAL: " \
<< "[" << g_logger << "] " << expression << "\n"; \
} while (false)
} //namespace nfd
#endif
-87
View File
@@ -1,87 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_MAP_VALUE_ITERATOR_H
#define NFD_CORE_MAP_VALUE_ITERATOR_H
#include "common.hpp"
#include <boost/iterator/transform_iterator.hpp>
namespace nfd {
/** \class MapValueIterator
* \brief ForwardIterator to iterator over map values
*/
template<typename Map>
class MapValueIterator
: public boost::transform_iterator<
function<const typename Map::mapped_type&(const typename Map::value_type&)>,
typename Map::const_iterator>
{
public:
explicit
MapValueIterator(typename Map::const_iterator it)
: boost::transform_iterator<
function<const typename Map::mapped_type&(const typename Map::value_type&)>,
typename Map::const_iterator>(it, &takeSecond)
{
}
private:
static const typename Map::mapped_type&
takeSecond(const typename Map::value_type& pair)
{
return pair.second;
}
};
/** \class MapValueReverseIterator
* \brief ReverseIterator to iterator over map values
*/
template<typename Map>
class MapValueReverseIterator
: public boost::transform_iterator<
function<const typename Map::mapped_type&(const typename Map::value_type&)>,
typename Map::const_reverse_iterator>
{
public:
explicit
MapValueReverseIterator(typename Map::const_reverse_iterator it)
: boost::transform_iterator<
function<const typename Map::mapped_type&(const typename Map::value_type&)>,
typename Map::const_reverse_iterator>(it, &takeSecond)
{
}
private:
static const typename Map::mapped_type&
takeSecond(const typename Map::value_type& pair)
{
return pair.second;
}
};
} // namespace nfd
#endif // NFD_CORE_MAP_VALUE_ITERATOR_H
-139
View File
@@ -1,139 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "network-interface.hpp"
#include "core/logger.hpp"
#include <boost/foreach.hpp>
#include <arpa/inet.h> // for inet_ntop()
#include <netinet/in.h> // for struct sockaddr_in{,6}
#include <ifaddrs.h> // for getifaddrs()
#if defined(__linux__)
#include <net/if_arp.h> // for ARPHRD_* constants
#include <netpacket/packet.h> // for struct sockaddr_ll
#elif defined(__APPLE__) || defined(__FreeBSD__)
#include <net/if_dl.h> // for struct sockaddr_dl
#else
#error Platform not supported
#endif
NFD_LOG_INIT("NetworkInterfaceInfo");
namespace nfd {
std::list< shared_ptr<NetworkInterfaceInfo> >
listNetworkInterfaces()
{
typedef std::map< std::string, shared_ptr<NetworkInterfaceInfo> > InterfacesMap;
InterfacesMap ifmap;
ifaddrs* ifa_list;
if (::getifaddrs(&ifa_list) < 0)
throw std::runtime_error("getifaddrs() failed");
for (ifaddrs* ifa = ifa_list; ifa != 0; ifa = ifa->ifa_next)
{
shared_ptr<NetworkInterfaceInfo> netif;
std::string ifname(ifa->ifa_name);
InterfacesMap::iterator i = ifmap.find(ifname);
if (i == ifmap.end())
{
netif = make_shared<NetworkInterfaceInfo>();
netif->name = ifname;
netif->flags = ifa->ifa_flags;
ifmap[ifname] = netif;
}
else
{
netif = i->second;
}
if (!ifa->ifa_addr)
continue;
switch (ifa->ifa_addr->sa_family)
{
case AF_INET: {
const sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(ifa->ifa_addr);
char address[INET_ADDRSTRLEN];
if (::inet_ntop(AF_INET, &sin->sin_addr, address, sizeof(address)))
netif->ipv4Addresses.push_back(boost::asio::ip::address_v4::from_string(address));
else
NFD_LOG_WARN("inet_ntop() failed on " << ifname);
}
break;
case AF_INET6: {
const sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(ifa->ifa_addr);
char address[INET6_ADDRSTRLEN];
if (::inet_ntop(AF_INET6, &sin6->sin6_addr, address, sizeof(address)))
netif->ipv6Addresses.push_back(boost::asio::ip::address_v6::from_string(address));
else
NFD_LOG_WARN("inet_ntop() failed on " << ifname);
}
break;
#if defined(__linux__)
case AF_PACKET: {
const sockaddr_ll* sll = reinterpret_cast<sockaddr_ll*>(ifa->ifa_addr);
netif->index = sll->sll_ifindex;
if (sll->sll_hatype == ARPHRD_ETHER && sll->sll_halen == ethernet::ADDR_LEN)
netif->etherAddress = ethernet::Address(sll->sll_addr);
else if (sll->sll_hatype != ARPHRD_LOOPBACK)
NFD_LOG_WARN("Unrecognized hardware address on " << ifname);
}
break;
#elif defined(__APPLE__) || defined(__FreeBSD__)
case AF_LINK: {
const sockaddr_dl* sdl = reinterpret_cast<sockaddr_dl*>(ifa->ifa_addr);
netif->index = sdl->sdl_index;
netif->etherAddress = ethernet::Address(reinterpret_cast<uint8_t*>(LLADDR(sdl)));
}
break;
#endif
}
if (netif->isBroadcastCapable() && ifa->ifa_broadaddr != 0)
{
const sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(ifa->ifa_broadaddr);
char address[INET_ADDRSTRLEN];
if (::inet_ntop(AF_INET, &sin->sin_addr, address, sizeof(address)))
netif->broadcastAddress = boost::asio::ip::address_v4::from_string(address);
else
NFD_LOG_WARN("inet_ntop() failed on " << ifname);
}
}
::freeifaddrs(ifa_list);
std::list< shared_ptr<NetworkInterfaceInfo> > list;
BOOST_FOREACH(InterfacesMap::value_type elem, ifmap) {
list.push_back(elem.second);
}
return list;
}
} // namespace nfd
-90
View File
@@ -1,90 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_NETWORK_INTERFACE_HPP
#define NFD_CORE_NETWORK_INTERFACE_HPP
#include "common.hpp"
#include "ethernet.hpp"
#include <net/if.h>
namespace nfd {
class NetworkInterfaceInfo
{
public:
int index;
std::string name;
ethernet::Address etherAddress;
std::vector<boost::asio::ip::address_v4> ipv4Addresses;
std::vector<boost::asio::ip::address_v6> ipv6Addresses;
boost::asio::ip::address_v4 broadcastAddress;
unsigned int flags;
bool
isLoopback() const;
bool
isMulticastCapable() const;
bool
isBroadcastCapable() const;
bool
isUp() const;
};
inline bool
NetworkInterfaceInfo::isLoopback() const
{
return (flags & IFF_LOOPBACK) != 0;
}
inline bool
NetworkInterfaceInfo::isMulticastCapable() const
{
return (flags & IFF_MULTICAST) != 0;
}
inline bool
NetworkInterfaceInfo::isBroadcastCapable() const
{
return (flags & IFF_BROADCAST) != 0;
}
inline bool
NetworkInterfaceInfo::isUp() const
{
return (flags & IFF_UP) != 0;
}
std::list< shared_ptr<NetworkInterfaceInfo> >
listNetworkInterfaces();
} // namespace nfd
#endif // NFD_CORE_NETWORK_INTERFACE_HPP
+185
View File
@@ -0,0 +1,185 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "network.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/utility/value_init.hpp>
#include <algorithm>
#include <cctype>
#include <istream>
#include <ostream>
namespace nfd {
Network::Network() = default;
Network::Network(const boost::asio::ip::address& minAddress,
const boost::asio::ip::address& maxAddress)
: m_minAddress(minAddress)
, m_maxAddress(maxAddress)
{
}
const Network&
Network::getMaxRangeV4()
{
using boost::asio::ip::address_v4;
static const Network range{address_v4{}, address_v4{0xffffffff}};
return range;
}
const Network&
Network::getMaxRangeV6()
{
using boost::asio::ip::address_v6;
static const address_v6::bytes_type maxV6 = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
static const Network range{address_v6{}, address_v6{maxV6}};
return range;
}
bool
Network::isValidCidr(std::string_view cidr) noexcept
{
auto pos = cidr.find('/');
if (pos == std::string::npos) {
return false;
}
try {
boost::lexical_cast<Network>(cidr);
return true;
}
catch (const boost::bad_lexical_cast&) {
return false;
}
}
std::ostream&
operator<<(std::ostream& os, const Network& network)
{
return os << network.m_minAddress << " <-> " << network.m_maxAddress;
}
std::istream&
operator>>(std::istream& is, Network& network)
{
namespace ip = boost::asio::ip;
std::string networkStr;
is >> networkStr;
size_t position = networkStr.find('/');
if (position == std::string::npos) {
try {
network.m_minAddress = ip::make_address(networkStr);
network.m_maxAddress = ip::make_address(networkStr);
}
catch (const boost::system::system_error&) {
is.setstate(std::ios::failbit);
return is;
}
}
else {
boost::system::error_code ec;
auto address = ip::make_address(networkStr.substr(0, position), ec);
if (ec) {
is.setstate(std::ios::failbit);
return is;
}
auto prefixLenStr = networkStr.substr(position + 1);
if (!std::all_of(prefixLenStr.begin(), prefixLenStr.end(),
[] (unsigned char c) { return std::isdigit(c); })) {
is.setstate(std::ios::failbit);
return is;
}
size_t mask;
try {
mask = boost::lexical_cast<size_t>(prefixLenStr);
}
catch (const boost::bad_lexical_cast&) {
is.setstate(std::ios::failbit);
return is;
}
if (address.is_v4()) {
if (mask > 32) {
is.setstate(std::ios::failbit);
return is;
}
ip::address_v4::bytes_type maskBytes = boost::initialized_value;
for (size_t i = 0; i < mask; i++) {
size_t byteId = i / 8;
size_t bitIndex = 7 - i % 8;
maskBytes[byteId] |= (1 << bitIndex);
}
ip::address_v4::bytes_type addressBytes = address.to_v4().to_bytes();
ip::address_v4::bytes_type min;
ip::address_v4::bytes_type max;
for (size_t i = 0; i < addressBytes.size(); i++) {
min[i] = addressBytes[i] & maskBytes[i];
max[i] = addressBytes[i] | ~(maskBytes[i]);
}
network.m_minAddress = ip::address_v4(min);
network.m_maxAddress = ip::address_v4(max);
}
else {
if (mask > 128) {
is.setstate(std::ios::failbit);
return is;
}
ip::address_v6::bytes_type maskBytes = boost::initialized_value;
for (size_t i = 0; i < mask; i++) {
size_t byteId = i / 8;
size_t bitIndex = 7 - i % 8;
maskBytes[byteId] |= (1 << bitIndex);
}
ip::address_v6::bytes_type addressBytes = address.to_v6().to_bytes();
ip::address_v6::bytes_type min;
ip::address_v6::bytes_type max;
for (size_t i = 0; i < addressBytes.size(); i++) {
min[i] = addressBytes[i] & maskBytes[i];
max[i] = addressBytes[i] | ~(maskBytes[i]);
}
network.m_minAddress = ip::address_v6(min);
network.m_maxAddress = ip::address_v6(max);
}
}
return is;
}
} // namespace nfd
+86
View File
@@ -0,0 +1,86 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_NETWORK_HPP
#define NFD_CORE_NETWORK_HPP
#include <boost/asio/ip/address.hpp>
#include <boost/operators.hpp>
#include <string_view>
namespace nfd {
class Network : private boost::equality_comparable<Network>
{
public:
Network();
Network(const boost::asio::ip::address& minAddress,
const boost::asio::ip::address& maxAddress);
bool
doesContain(const boost::asio::ip::address& address) const noexcept
{
return m_minAddress <= address && address <= m_maxAddress;
}
static const Network&
getMaxRangeV4();
static const Network&
getMaxRangeV6();
static bool
isValidCidr(std::string_view cidr) noexcept;
private: // non-member operators
friend bool
operator==(const Network& lhs, const Network& rhs) noexcept
{
return lhs.m_minAddress == rhs.m_minAddress &&
lhs.m_maxAddress == rhs.m_maxAddress;
}
friend std::ostream&
operator<<(std::ostream& os, const Network& network);
friend std::istream&
operator>>(std::istream& is, Network& network);
private:
boost::asio::ip::address m_minAddress;
boost::asio::ip::address m_maxAddress;
};
std::ostream&
operator<<(std::ostream& os, const Network& network);
std::istream&
operator>>(std::istream& is, Network& network);
} // namespace nfd
#endif // NFD_CORE_NETWORK_HPP
-195
View File
@@ -1,195 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "privilege-helper.hpp"
#include "core/logger.hpp"
#include <pwd.h>
#include <grp.h>
namespace nfd {
NFD_LOG_INIT("PrivilegeHelper");
uid_t PrivilegeHelper::s_normalUid = ::geteuid();
gid_t PrivilegeHelper::s_normalGid = ::getegid();
uid_t PrivilegeHelper::s_privilegedUid = ::geteuid();
gid_t PrivilegeHelper::s_privilegedGid = ::getegid();
void
PrivilegeHelper::initialize(const std::string& userName, const std::string& groupName)
{
static const size_t MAX_GROUP_BUFFER_SIZE = 16384; // 16kB
static const size_t MAX_PASSWD_BUFFER_SIZE = 16384;
static const size_t FALLBACK_GROUP_BUFFER_SIZE = 1024;
static const size_t FALLBACK_PASSWD_BUFFER_SIZE = 1024;
NFD_LOG_TRACE("initializing privilege helper with user \"" << userName << "\""
<< " group \"" << groupName << "\"");
// workflow from man getpwnam_r
if (!groupName.empty())
{
static int groupSize = ::sysconf(_SC_GETGR_R_SIZE_MAX);
if (groupSize == -1)
{
groupSize = FALLBACK_GROUP_BUFFER_SIZE;
}
std::vector<char> groupBuffer(groupSize);
struct group group;
struct group* groupResult = 0;
int errorCode = getgrnam_r(groupName.c_str(), &group,
&groupBuffer[0], groupSize, &groupResult);
while (errorCode == ERANGE)
{
if (groupBuffer.size() * 2 > MAX_GROUP_BUFFER_SIZE)
{
throw PrivilegeHelper::Error("Cannot allocate large enough buffer for struct group");
}
groupBuffer.resize(groupBuffer.size() * 2);
errorCode = getgrnam_r(groupName.c_str(), &group,
&groupBuffer[0], groupBuffer.size(), &groupResult);
}
if (errorCode != 0 || !groupResult)
{
throw PrivilegeHelper::Error("Failed to get gid for \"" + groupName + "\"");
}
s_normalGid = group.gr_gid;
}
if (!userName.empty())
{
static int passwdSize = ::sysconf(_SC_GETPW_R_SIZE_MAX);
if (passwdSize == -1)
{
passwdSize = FALLBACK_PASSWD_BUFFER_SIZE;
}
std::vector<char> passwdBuffer(passwdSize);
struct passwd passwd;
struct passwd* passwdResult = 0;
int errorCode =
getpwnam_r(userName.c_str(), &passwd,
&passwdBuffer[0], passwdBuffer.size(), &passwdResult);
while (errorCode == ERANGE)
{
if (passwdBuffer.size() * 2 > MAX_PASSWD_BUFFER_SIZE)
{
throw PrivilegeHelper::Error("Cannot allocate large enough buffer for struct passwd");
}
passwdBuffer.resize(passwdBuffer.size() * 2);
errorCode = getpwnam_r(userName.c_str(), &passwd,
&passwdBuffer[0], passwdBuffer.size(), &passwdResult);
}
if (errorCode != 0 || !passwdResult)
{
throw PrivilegeHelper::Error("Failed to get uid for \"" + userName + "\"");
}
s_normalUid = passwd.pw_uid;
}
}
void
PrivilegeHelper::drop()
{
NFD_LOG_TRACE("dropping to effective gid=" << s_normalGid);
if (::setegid(s_normalGid) != 0)
{
std::stringstream error;
error << "Failed to drop to effective gid=" << s_normalGid;
throw PrivilegeHelper::Error(error.str());
}
NFD_LOG_TRACE("dropping to effective uid=" << s_normalUid);
if (::seteuid(s_normalUid) != 0)
{
std::stringstream error;
error << "Failed to drop to effective uid=" << s_normalUid;
throw PrivilegeHelper::Error(error.str());
}
NFD_LOG_INFO("dropped to effective uid=" << ::geteuid() << " gid=" << ::getegid());
}
void
PrivilegeHelper::raise()
{
NFD_LOG_TRACE("elevating to effective uid=" << s_privilegedUid);
if (::seteuid(s_privilegedUid) != 0)
{
std::stringstream error;
error << "Failed to elevate to effective uid=" << s_privilegedUid;
throw PrivilegeHelper::Error(error.str());
}
NFD_LOG_TRACE("elevating to effective gid=" << s_privilegedGid);
if (::setegid(s_privilegedGid) != 0)
{
std::stringstream error;
error << "Failed to elevate to effective gid=" << s_privilegedGid;
throw PrivilegeHelper::Error(error.str());
}
NFD_LOG_INFO("elevated to effective uid=" << ::geteuid() << " gid=" << ::getegid());
}
void
PrivilegeHelper::runElevated(function<void()> f)
{
raise();
try
{
f();
}
catch (...)
{
drop();
throw;
}
drop();
}
} // namespace nfd
-49
View File
@@ -1,49 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* This file declares the global random number generator
* All random numbers in NFD should use this global random number generator,
* so that the generator can be properly seeded when necessary.
*
* This random number generator is not suitable for security purposes;
* security-critical code should use CryptoPP random number generator instead.
*/
#ifndef NFD_CORE_RANDOM_HPP
#define NFD_CORE_RANDOM_HPP
#include <boost/random/mersenne_twister.hpp>
namespace nfd {
/** \return the global random number generator instance
*/
boost::random::mt19937&
getGlobalRng();
} // namespace nfd
#endif // NFD_CORE_RANDOM_HPP
-214
View File
@@ -1,214 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_RESOLVER_H
#define NFD_CORE_RESOLVER_H
#include "common.hpp"
#include "core/global-io.hpp"
#include "core/scheduler.hpp"
namespace nfd {
namespace resolver {
typedef function<bool (const boost::asio::ip::address& address)> AddressSelector;
struct AnyAddress {
bool
operator()(const boost::asio::ip::address& address)
{
return true;
}
};
struct Ipv4Address {
bool
operator()(const boost::asio::ip::address& address)
{
return address.is_v4();
}
};
struct Ipv6Address {
bool
operator()(const boost::asio::ip::address& address)
{
return address.is_v6();
}
};
} // namespace resolver
template<class Protocol>
class Resolver
{
public:
struct Error : public std::runtime_error
{
Error(const std::string& what) : std::runtime_error(what) {}
};
typedef function<void (const typename Protocol::endpoint& endpoint)> SuccessCallback;
typedef function<void (const std::string& reason)> ErrorCallback;
typedef boost::asio::ip::basic_resolver< Protocol > resolver;
/** \brief Asynchronously resolve host and port
*
* If an address selector predicate is specified, then each resolved IP address
* is checked against the predicate.
*
* Available address selector predicates:
*
* - resolver::AnyAddress()
* - resolver::Ipv4Address()
* - resolver::Ipv6Address()
*/
static void
asyncResolve(const std::string& host, const std::string& port,
const SuccessCallback& onSuccess,
const ErrorCallback& onError,
const nfd::resolver::AddressSelector& addressSelector = nfd::resolver::AnyAddress(),
const time::seconds& timeout = time::seconds(4))
{
shared_ptr<Resolver> resolver =
shared_ptr<Resolver>(new Resolver(onSuccess, onError,
addressSelector));
resolver->asyncResolve(host, port, timeout, resolver);
// resolver will be destroyed when async operation finishes or global IO service stops
}
/** \brief Synchronously resolve host and port
*
* If an address selector predicate is specified, then each resolved IP address
* is checked against the predicate.
*
* Available address selector predicates:
*
* - resolver::AnyAddress()
* - resolver::Ipv4Address()
* - resolver::Ipv6Address()
*/
static typename Protocol::endpoint
syncResolve(const std::string& host, const std::string& port,
const nfd::resolver::AddressSelector& addressSelector = nfd::resolver::AnyAddress())
{
Resolver resolver(SuccessCallback(), ErrorCallback(), addressSelector);
typename resolver::query query(host, port
#if not defined(__FreeBSD__)
, resolver::query::all_matching
#endif
);
typename resolver::iterator remoteEndpoint = resolver.m_resolver.resolve(query);
typename resolver::iterator end;
for (; remoteEndpoint != end; ++remoteEndpoint)
{
if (addressSelector(typename Protocol::endpoint(*remoteEndpoint).address()))
return *remoteEndpoint;
}
throw Error("No endpoint matching the specified address selector found");
}
private:
Resolver(const SuccessCallback& onSuccess,
const ErrorCallback& onError,
const nfd::resolver::AddressSelector& addressSelector)
: m_resolver(getGlobalIoService())
, m_addressSelector(addressSelector)
, m_onSuccess(onSuccess)
, m_onError(onError)
{
}
void
asyncResolve(const std::string& host, const std::string& port,
const time::seconds& timeout,
const shared_ptr<Resolver>& self)
{
typename resolver::query query(host, port
#if not defined(__FreeBSD__)
, resolver::query::all_matching
#endif
);
m_resolver.async_resolve(query,
bind(&Resolver::onResolveSuccess, this, _1, _2, self));
m_resolveTimeout = scheduler::schedule(timeout,
bind(&Resolver::onResolveError, this,
"Timeout", self));
}
void
onResolveSuccess(const boost::system::error_code& error,
typename resolver::iterator remoteEndpoint,
const shared_ptr<Resolver>& self)
{
scheduler::cancel(m_resolveTimeout);
if (error)
{
if (error == boost::system::errc::operation_canceled)
return;
return m_onError("Remote endpoint hostname or port cannot be resolved: " +
error.category().message(error.value()));
}
typename resolver::iterator end;
for (; remoteEndpoint != end; ++remoteEndpoint)
{
if (m_addressSelector(typename Protocol::endpoint(*remoteEndpoint).address()))
return m_onSuccess(*remoteEndpoint);
}
m_onError("No endpoint matching the specified address selector found");
}
void
onResolveError(const std::string& errorInfo,
const shared_ptr<Resolver>& self)
{
m_resolver.cancel();
m_onError(errorInfo);
}
private:
resolver m_resolver;
EventId m_resolveTimeout;
nfd::resolver::AddressSelector m_addressSelector;
SuccessCallback m_onSuccess;
ErrorCallback m_onError;
};
typedef Resolver<boost::asio::ip::tcp> TcpResolver;
typedef Resolver<boost::asio::ip::udp> UdpResolver;
} // namespace nfd
#endif // NFD_CORE_RESOLVER_H
-61
View File
@@ -1,61 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "scheduler.hpp"
#include "global-io.hpp"
namespace nfd {
namespace scheduler {
static shared_ptr<Scheduler> g_scheduler;
inline Scheduler&
getGlobalScheduler()
{
if (!static_cast<bool>(g_scheduler)) {
g_scheduler = make_shared<Scheduler>(ref(getGlobalIoService()));
}
return *g_scheduler;
}
EventId
schedule(const time::nanoseconds& after, const Scheduler::Event& event)
{
return getGlobalScheduler().scheduleEvent(after, event);
}
void
cancel(const EventId& eventId)
{
getGlobalScheduler().cancelEvent(eventId);
}
void
resetGlobalScheduler()
{
g_scheduler.reset();
}
} // namespace scheduler
} // namespace nfd
-57
View File
@@ -1,57 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_CORE_SCHEDULER_HPP
#define NFD_CORE_SCHEDULER_HPP
#include "common.hpp"
#include <ndn-cxx/util/scheduler.hpp>
namespace nfd {
namespace scheduler {
using ndn::Scheduler;
/** \class EventId
* \brief Opaque type (shared_ptr) representing ID of a scheduled event
*/
using ndn::EventId;
/** \brief schedule an event
*/
EventId
schedule(const time::nanoseconds& after, const Scheduler::Event& event);
/** \brief cancel a scheduled event
*/
void
cancel(const EventId& eventId);
} // namespace scheduler
using scheduler::EventId;
} // namespace nfd
#endif // NFD_CORE_SCHEDULER_HPP
-121
View File
@@ -1,121 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_CORE_SEGMENT_PUBLISHER_HPP
#define NFD_CORE_SEGMENT_PUBLISHER_HPP
#include "common.hpp"
#include <ndn-cxx/encoding/encoding-buffer.hpp>
#include <ndn-cxx/security/key-chain.hpp>
namespace nfd {
template <class FaceBase>
class SegmentPublisher : noncopyable
{
public:
SegmentPublisher(FaceBase& face, const Name& prefix, ndn::KeyChain& keyChain)
: m_face(face)
, m_prefix(prefix)
, m_keyChain(keyChain)
{
}
virtual
~SegmentPublisher()
{
}
static size_t
getMaxSegmentSize()
{
static const size_t MAX_SEGMENT_SIZE = ndn::MAX_NDN_PACKET_SIZE >> 1;
return MAX_SEGMENT_SIZE;
}
void
publish()
{
Name segmentPrefix(m_prefix);
segmentPrefix.appendVersion();
ndn::EncodingBuffer buffer;
generate(buffer);
const uint8_t* rawBuffer = buffer.buf();
const uint8_t* segmentBegin = rawBuffer;
const uint8_t* end = rawBuffer + buffer.size();
uint64_t segmentNo = 0;
do
{
const uint8_t* segmentEnd = segmentBegin + getMaxSegmentSize();
if (segmentEnd > end)
{
segmentEnd = end;
}
Name segmentName(segmentPrefix);
segmentName.appendSegment(segmentNo);
shared_ptr<Data> data(make_shared<Data>(segmentName));
data->setContent(segmentBegin, segmentEnd - segmentBegin);
segmentBegin = segmentEnd;
if (segmentBegin >= end)
{
data->setFinalBlockId(segmentName[-1]);
}
publishSegment(data);
segmentNo++;
}
while (segmentBegin < end);
}
protected:
virtual size_t
generate(ndn::EncodingBuffer& outBuffer) =0;
private:
void
publishSegment(shared_ptr<Data>& data)
{
m_keyChain.sign(*data);
m_face.put(*data);
}
private:
FaceBase& m_face;
const Name m_prefix;
ndn::KeyChain& m_keyChain;
};
} // namespace nfd
#endif // NFD_CORE_SEGMENT_PUBLISHER_HPP
+11 -20
View File
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
/*
* Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -23,16 +23,7 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "random.hpp"
#include "core/version.hpp"
namespace nfd {
static boost::random::mt19937 g_rng;
boost::random::mt19937&
getGlobalRng()
{
return g_rng;
}
} // namespace nfd
const char NFD_VERSION_STRING[] = "@VERSION_STRING@";
const char NFD_VERSION_BUILD_STRING[] = "@VERSION_BUILD@";
+77
View File
@@ -0,0 +1,77 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_CORE_VERSION_HPP
#define NFD_CORE_VERSION_HPP
// The NFD version follows the approach of Calendar Versioning (https://calver.org/)
// based on the year and month of the release, followed by an optional "patch" number,
// i.e., `YY.0M[.MICRO]` using CalVer notation.
//
// To change version number, modify the VERSION variable in the top-level wscript.
/**
* \brief NFD version represented as an integer.
*
* Equivalent to: #NFD_VERSION_MAJOR*1000000 + #NFD_VERSION_MINOR*1000 + #NFD_VERSION_PATCH
*/
#define NFD_VERSION @VERSION@
/// The major version of NFD
#define NFD_VERSION_MAJOR @VERSION_MAJOR@
/// The minor version of NFD
#define NFD_VERSION_MINOR @VERSION_MINOR@
/// The patch version of NFD
#define NFD_VERSION_PATCH @VERSION_PATCH@
/**
* \brief NFD version represented as a string.
*
* Format:
* @code
* MAJOR.MINOR.PATCH
* @endcode
*/
extern const char NFD_VERSION_STRING[];
/**
* \brief NFD version string, including git commit information if NFD is build from a
* specific git commit.
*
* #NFD_VERSION_BUILD_STRING is obtained using the following command (`NFD-` prefix is
* afterwards removed): ``git describe --match 'NFD-*'``
*
* When NFD is not built from git, #NFD_VERSION_BUILD_STRING equals #NFD_VERSION_STRING.
*
* Format:
* @code
* MAJOR.MINOR(.PATCH)(-release-candidate-tag)(-(number-of-commits-since-tag)-COMMIT-HASH)
* @endcode
*
* Example: 2022.02-1-g5c86570
*/
extern const char NFD_VERSION_BUILD_STRING[];
#endif // NFD_CORE_VERSION_HPP
File renamed without changes.
File renamed without changes.
+138
View File
@@ -0,0 +1,138 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/config-file.hpp"
#include <boost/property_tree/info_parser.hpp>
#include <fstream>
#include <sstream>
namespace nfd {
ConfigFile::ConfigFile(UnknownConfigSectionHandler callback)
: m_unknownSectionCallback(std::move(callback))
{
}
void
ConfigFile::throwErrorOnUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun)
{
NDN_THROW(Error("Error processing configuration file " + filename +
": no module subscribed for section '" + sectionName + "'"));
}
void
ConfigFile::ignoreUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun)
{
// do nothing
}
bool
ConfigFile::parseYesNo(const ConfigSection& node, const std::string& key,
const std::string& sectionName)
{
auto value = node.get_value<std::string>();
if (value == "yes") {
return true;
}
else if (value == "no") {
return false;
}
NDN_THROW(Error("Invalid value '" + value + "' for option '" +
key + "' in section '" + sectionName + "'"));
}
void
ConfigFile::addSectionHandler(const std::string& sectionName,
ConfigSectionHandler subscriber)
{
m_subscriptions[sectionName] = std::move(subscriber);
}
void
ConfigFile::parse(const std::string& filename, bool isDryRun)
{
std::ifstream inputFile(filename);
if (!inputFile.good() || !inputFile.is_open()) {
NDN_THROW(Error("Failed to read configuration file " + filename));
}
parse(inputFile, isDryRun, filename);
inputFile.close();
}
void
ConfigFile::parse(const std::string& input, bool isDryRun, const std::string& filename)
{
std::istringstream inputStream(input);
parse(inputStream, isDryRun, filename);
}
void
ConfigFile::parse(std::istream& input, bool isDryRun, const std::string& filename)
{
try {
boost::property_tree::read_info(input, m_global);
}
catch (const boost::property_tree::info_parser_error& error) {
NDN_THROW(Error("Failed to parse configuration file " + filename +
": " + error.message() + " on line " + to_string(error.line())));
}
process(isDryRun, filename);
}
void
ConfigFile::parse(const ConfigSection& config, bool isDryRun, const std::string& filename)
{
m_global = config;
process(isDryRun, filename);
}
void
ConfigFile::process(bool isDryRun, const std::string& filename) const
{
BOOST_ASSERT(!filename.empty());
for (const auto& i : m_global) {
try {
const ConfigSectionHandler& subscriber = m_subscriptions.at(i.first);
subscriber(i.second, isDryRun, filename);
}
catch (const std::out_of_range&) {
m_unknownSectionCallback(filename, i.first, i.second, isDryRun);
}
}
}
} // namespace nfd
+204
View File
@@ -0,0 +1,204 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_COMMON_CONFIG_FILE_HPP
#define NFD_DAEMON_COMMON_CONFIG_FILE_HPP
#include "core/common.hpp"
#include <boost/property_tree/ptree.hpp>
namespace nfd {
/**
* \brief A configuration file section.
*/
using ConfigSection = boost::property_tree::ptree;
/**
* \brief An optional configuration file section.
*/
using OptionalConfigSection = boost::optional<const ConfigSection&>;
/**
* \brief Callback to process a configuration file section.
*/
using ConfigSectionHandler = std::function<void(const ConfigSection& section, bool isDryRun,
const std::string& filename)>;
/**
* \brief Callback to process a configuration file section without a #ConfigSectionHandler.
*/
using UnknownConfigSectionHandler = std::function<void(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun)>;
/**
* \brief Configuration file parsing utility.
*/
class ConfigFile : noncopyable
{
public:
class Error : public std::runtime_error
{
public:
using std::runtime_error::runtime_error;
};
explicit
ConfigFile(UnknownConfigSectionHandler unknownSectionCallback = throwErrorOnUnknownSection);
public: // unknown section handlers
static void
throwErrorOnUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun);
static void
ignoreUnknownSection(const std::string& filename,
const std::string& sectionName,
const ConfigSection& section,
bool isDryRun);
public: // parse helpers
/** \brief Parse a config option that can be either "yes" or "no".
* \retval true "yes"
* \retval false "no"
* \throw Error the value is neither "yes" nor "no"
*/
static bool
parseYesNo(const ConfigSection& node, const std::string& key, const std::string& sectionName);
static bool
parseYesNo(const ConfigSection::value_type& option, const std::string& sectionName)
{
return parseYesNo(option.second, option.first, sectionName);
}
/**
* \brief Parse a numeric (integral or floating point) config option.
* \tparam T an arithmetic type
*
* \return the numeric value of the parsed option
* \throw Error the value cannot be converted to the specified type
*/
template<typename T>
static T
parseNumber(const ConfigSection& node, const std::string& key, const std::string& sectionName)
{
static_assert(std::is_arithmetic_v<T>);
auto value = node.get_value_optional<T>();
// Unsigned logic is workaround for https://redmine.named-data.net/issues/4489
if (value &&
(std::is_signed_v<T> || node.get_value<std::string>().find("-") == std::string::npos)) {
return *value;
}
NDN_THROW(Error("Invalid value '" + node.get_value<std::string>() +
"' for option '" + key + "' in section '" + sectionName + "'"));
}
template<typename T>
static T
parseNumber(const ConfigSection::value_type& option, const std::string& sectionName)
{
return parseNumber<T>(option.second, option.first, sectionName);
}
/**
* \brief Check that a value is within the inclusive range [min, max].
* \throw Error the value is out of the acceptable range
*/
template<typename T>
static void
checkRange(T value, T min, T max, const std::string& key, const std::string& sectionName)
{
static_assert(std::is_integral_v<T>);
if (value < min || value > max) {
NDN_THROW(Error("Invalid value '" + to_string(value) + "' for option '" + key +
"' in section '" + sectionName + "': out of acceptable range [" +
to_string(min) + ", " + to_string(max) + "]"));
}
}
public: // setup and parsing
/// \brief Setup notification of configuration file sections.
void
addSectionHandler(const std::string& sectionName,
ConfigSectionHandler subscriber);
/**
* \param filename file to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \throws ConfigFile::Error if file not found
* \throws ConfigFile::Error if parse error
*/
void
parse(const std::string& filename, bool isDryRun);
/**
* \param input configuration (as a string) to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \param filename logical filename of the config file, can appear in error messages
* \throws ConfigFile::Error if file not found
* \throws ConfigFile::Error if parse error
*/
void
parse(const std::string& input, bool isDryRun, const std::string& filename);
/**
* \param input stream to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \param filename logical filename of the config file, can appear in error messages
* \throws ConfigFile::Error if parse error
*/
void
parse(std::istream& input, bool isDryRun, const std::string& filename);
/**
* \param config ConfigSection that needs to be processed
* \param isDryRun true if performing a dry run of configuration, false otherwise
* \param filename logical filename of the config file, can appear in error messages
* \throws ConfigFile::Error if parse error
*/
void
parse(const ConfigSection& config, bool isDryRun, const std::string& filename);
private:
void
process(bool isDryRun, const std::string& filename) const;
private:
UnknownConfigSectionHandler m_unknownSectionCallback;
std::map<std::string, ConfigSectionHandler> m_subscriptions;
ConfigSection m_global;
};
} // namespace nfd
#endif // NFD_DAEMON_COMMON_CONFIG_FILE_HPP
+142
View File
@@ -0,0 +1,142 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_COMMON_COUNTER_HPP
#define NFD_DAEMON_COMMON_COUNTER_HPP
#include "core/common.hpp"
namespace nfd {
/**
* \brief Represents a counter that encloses an integer value.
*
* SimpleCounter is noncopyable, because increment should be called on the counter,
* not a copy of it. It's implicitly convertible to an integral type to be observed.
*/
class SimpleCounter : noncopyable
{
public:
using rep = uint64_t;
/**
* \brief Return the counter's value.
*/
operator rep() const noexcept
{
return m_value;
}
/**
* \brief Replace the counter's value.
*/
void
set(rep value) noexcept
{
m_value = value;
}
protected:
rep m_value = 0;
};
/**
* \brief Represents a counter of number of packets.
*
* \warning The counter value may wrap after exceeding the range of the underlying integer type.
*/
class PacketCounter : public SimpleCounter
{
public:
/**
* \brief Increment the counter by one.
*/
PacketCounter&
operator++() noexcept
{
++m_value;
return *this;
}
};
/**
* \brief Represents a counter of number of bytes.
*
* \warning The counter value may wrap after exceeding the range of the underlying integer type.
*/
class ByteCounter : public SimpleCounter
{
public:
/**
* \brief Increase the counter.
*/
ByteCounter&
operator+=(rep n) noexcept
{
m_value += n;
return *this;
}
};
/**
* \brief Provides a counter that observes the size of a table.
* \tparam T a type that provides a `size()` const member function
*
* If the table is not specified in the constructor, it can be added later by calling observe().
*/
template<typename T>
class SizeCounter : noncopyable
{
public:
using rep = size_t;
explicit constexpr
SizeCounter(const T* table = nullptr) noexcept
: m_table(table)
{
}
void
observe(const T* table) noexcept
{
m_table = table;
}
/**
* \brief Return the counter's value, i.e., the current size of the table being observed.
*/
operator rep() const
{
BOOST_ASSERT(m_table != nullptr);
return m_table->size();
}
private:
const T* m_table = nullptr;
};
} // namespace nfd
#endif // NFD_DAEMON_COMMON_COUNTER_HPP
+88
View File
@@ -0,0 +1,88 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/global.hpp"
namespace nfd {
static thread_local unique_ptr<boost::asio::io_context> g_ioCtx;
static thread_local unique_ptr<Scheduler> g_scheduler;
static boost::asio::io_context* g_mainIoCtx = nullptr;
static boost::asio::io_context* g_ribIoCtx = nullptr;
boost::asio::io_context&
getGlobalIoService()
{
if (g_ioCtx == nullptr) {
g_ioCtx = make_unique<boost::asio::io_context>();
}
return *g_ioCtx;
}
Scheduler&
getScheduler()
{
if (g_scheduler == nullptr) {
g_scheduler = make_unique<Scheduler>(getGlobalIoService());
}
return *g_scheduler;
}
#ifdef NFD_WITH_TESTS
void
resetGlobalIoService()
{
g_scheduler.reset();
g_ioCtx.reset();
}
#endif
boost::asio::io_context&
getMainIoService()
{
BOOST_ASSERT(g_mainIoCtx != nullptr);
return *g_mainIoCtx;
}
boost::asio::io_context&
getRibIoService()
{
BOOST_ASSERT(g_ribIoCtx != nullptr);
return *g_ribIoCtx;
}
void
setMainIoService(boost::asio::io_context* mainIo)
{
g_mainIoCtx = mainIo;
}
void
setRibIoService(boost::asio::io_context* ribIo)
{
g_ribIoCtx = ribIo;
}
} // namespace nfd
+70
View File
@@ -0,0 +1,70 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_DAEMON_COMMON_GLOBAL_HPP
#define NFD_DAEMON_COMMON_GLOBAL_HPP
#include "core/common.hpp"
#include <boost/asio/io_context.hpp>
namespace nfd {
/**
* \brief Returns the global io_context instance for the calling thread.
*/
boost::asio::io_context&
getGlobalIoService();
/**
* \brief Returns the global Scheduler instance for the calling thread.
*/
Scheduler&
getScheduler();
boost::asio::io_context&
getMainIoService();
boost::asio::io_context&
getRibIoService();
void
setMainIoService(boost::asio::io_context* mainIo);
void
setRibIoService(boost::asio::io_context* ribIo);
#ifdef NFD_WITH_TESTS
/**
* \brief Destroy the global io_context instance.
*
* It will be recreated at the next invocation of getGlobalIoService().
*/
void
resetGlobalIoService();
#endif
} // namespace nfd
#endif // NFD_DAEMON_COMMON_GLOBAL_HPP
+44
View File
@@ -0,0 +1,44 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_COMMON_LOGGER_HPP
#define NFD_DAEMON_COMMON_LOGGER_HPP
#include <ndn-cxx/util/logger.hpp>
#define NFD_LOG_INIT(name) NDN_LOG_INIT(nfd.name)
#define NFD_LOG_MEMBER_DECL() NDN_LOG_MEMBER_DECL()
#define NFD_LOG_MEMBER_DECL_SPECIALIZED(cls) NDN_LOG_MEMBER_DECL_SPECIALIZED(cls)
#define NFD_LOG_MEMBER_INIT(cls, name) NDN_LOG_MEMBER_INIT(cls, nfd.name)
#define NFD_LOG_MEMBER_INIT_SPECIALIZED(cls, name) NDN_LOG_MEMBER_INIT_SPECIALIZED(cls, nfd.name)
#define NFD_LOG_TRACE NDN_LOG_TRACE
#define NFD_LOG_DEBUG NDN_LOG_DEBUG
#define NFD_LOG_INFO NDN_LOG_INFO
#define NFD_LOG_WARN NDN_LOG_WARN
#define NFD_LOG_ERROR NDN_LOG_ERROR
#define NFD_LOG_FATAL NDN_LOG_FATAL
#endif // NFD_DAEMON_COMMON_LOGGER_HPP
+159
View File
@@ -0,0 +1,159 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/privilege-helper.hpp"
#include "common/logger.hpp"
#include <pwd.h>
#include <grp.h>
namespace nfd {
NFD_LOG_INIT(PrivilegeHelper);
#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
uid_t PrivilegeHelper::s_normalUid = ::geteuid();
gid_t PrivilegeHelper::s_normalGid = ::getegid();
uid_t PrivilegeHelper::s_privilegedUid = ::geteuid();
gid_t PrivilegeHelper::s_privilegedGid = ::getegid();
#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
void
PrivilegeHelper::initialize(const std::string& userName, const std::string& groupName)
{
#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
static const size_t MAX_GROUP_BUFFER_SIZE = 16384; // 16 KiB
static const size_t MAX_PASSWD_BUFFER_SIZE = 16384;
static const size_t FALLBACK_GROUP_BUFFER_SIZE = 1024;
static const size_t FALLBACK_PASSWD_BUFFER_SIZE = 1024;
NFD_LOG_TRACE("initializing with user \"" << userName << "\""
<< " group \"" << groupName << "\"");
// workflow from man getpwnam_r
if (!groupName.empty()) {
static long groupSize = ::sysconf(_SC_GETGR_R_SIZE_MAX);
if (groupSize == -1)
groupSize = FALLBACK_GROUP_BUFFER_SIZE;
std::vector<char> groupBuffer(static_cast<size_t>(groupSize));
group gr;
group* grResult = nullptr;
int errorCode = getgrnam_r(groupName.data(), &gr, groupBuffer.data(), groupBuffer.size(), &grResult);
while (errorCode == ERANGE) {
if (groupBuffer.size() * 2 > MAX_GROUP_BUFFER_SIZE)
throw Error("Cannot allocate large enough buffer for struct group");
groupBuffer.resize(groupBuffer.size() * 2);
errorCode = getgrnam_r(groupName.data(), &gr, groupBuffer.data(), groupBuffer.size(), &grResult);
}
if (errorCode != 0 || !grResult)
throw Error("Failed to get gid for \"" + groupName + "\"");
s_normalGid = gr.gr_gid;
}
if (!userName.empty()) {
static long passwdSize = ::sysconf(_SC_GETPW_R_SIZE_MAX);
if (passwdSize == -1)
passwdSize = FALLBACK_PASSWD_BUFFER_SIZE;
std::vector<char> passwdBuffer(static_cast<size_t>(passwdSize));
passwd pw;
passwd* pwResult = nullptr;
int errorCode = getpwnam_r(userName.data(), &pw, passwdBuffer.data(), passwdBuffer.size(), &pwResult);
while (errorCode == ERANGE) {
if (passwdBuffer.size() * 2 > MAX_PASSWD_BUFFER_SIZE)
throw Error("Cannot allocate large enough buffer for struct passwd");
passwdBuffer.resize(passwdBuffer.size() * 2);
errorCode = getpwnam_r(userName.data(), &pw, passwdBuffer.data(), passwdBuffer.size(), &pwResult);
}
if (errorCode != 0 || !pwResult)
throw Error("Failed to get uid for \"" + userName + "\"");
s_normalUid = pw.pw_uid;
}
#else
if (!userName.empty() || !groupName.empty()) {
throw Error("Dropping and raising privileges is not supported on this platform");
}
#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
}
void
PrivilegeHelper::drop()
{
#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
if (::geteuid() == s_normalUid && ::getegid() == s_normalGid)
return;
NFD_LOG_TRACE("dropping to effective gid=" << s_normalGid);
if (::setegid(s_normalGid) != 0)
throw Error("Failed to drop to effective gid=" + to_string(s_normalGid));
NFD_LOG_TRACE("dropping to effective uid=" << s_normalUid);
if (::seteuid(s_normalUid) != 0)
throw Error("Failed to drop to effective uid=" + to_string(s_normalUid));
NFD_LOG_INFO("dropped to effective uid=" << ::geteuid() << " gid=" << ::getegid());
#else
NFD_LOG_WARN("Dropping privileges is not supported on this platform");
#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
}
void
PrivilegeHelper::raise()
{
#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
if (::geteuid() == s_privilegedUid && ::getegid() == s_privilegedGid)
return;
NFD_LOG_TRACE("elevating to effective uid=" << s_privilegedUid);
if (::seteuid(s_privilegedUid) != 0)
throw Error("Failed to elevate to effective uid=" + to_string(s_privilegedUid));
NFD_LOG_TRACE("elevating to effective gid=" << s_privilegedGid);
if (::setegid(s_privilegedGid) != 0)
throw Error("Failed to elevate to effective gid=" + to_string(s_privilegedGid));
NFD_LOG_INFO("elevated to effective uid=" << ::geteuid() << " gid=" << ::getegid());
#else
NFD_LOG_WARN("Elevating privileges is not supported on this platform");
#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
}
} // namespace nfd
@@ -1,11 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,12 +21,12 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NFD_CORE_PRIVILEGE_HELPER_HPP
#define NFD_CORE_PRIVILEGE_HELPER_HPP
#ifndef NFD_DAEMON_COMMON_PRIVILEGE_HELPER_HPP
#define NFD_DAEMON_COMMON_PRIVILEGE_HELPER_HPP
#include "common.hpp"
#include "core/common.hpp"
#include <unistd.h>
@@ -34,9 +35,13 @@ namespace nfd {
class PrivilegeHelper
{
public:
/// \brief PrivilegeHelper::Error represents a serious seteuid/gid failure and
/// should only be caught by main in as part of a graceful program termination.
/**
* \brief Indicates a serious seteuid/setegid failure.
*
* This should only be caught by main as part of a graceful program termination.
*
* \note This is not an std::exception and NDN_THROW should not be used.
*/
class Error
{
public:
@@ -49,7 +54,7 @@ public:
const char*
what() const
{
return m_whatMessage.c_str();
return m_whatMessage.data();
}
private:
@@ -62,23 +67,35 @@ public:
static void
drop();
template<class F>
static void
runElevated(function<void()> f);
private:
runElevated(F&& f)
{
raise();
try {
std::invoke(std::forward<F>(f));
}
catch (...) {
drop();
throw;
}
drop();
}
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
static void
raise();
private:
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
static uid_t s_normalUid;
static gid_t s_normalGid;
static uid_t s_privilegedUid;
static gid_t s_privilegedGid;
#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
};
} // namespace nfd
#endif // NFD_CORE_PRIVILEGE_HELPER_HPP
#endif // NFD_DAEMON_COMMON_PRIVILEGE_HELPER_HPP
+42
View File
@@ -0,0 +1,42 @@
#include "TokenBucket.hpp"
#include "common/global.hpp"
#include "common/logger.hpp"
#include <functional>
namespace nfd {
namespace face {
NFD_LOG_INIT(QSCCPTokenBucket);
TokenBucket::TokenBucket(uint64_t rateLimit, uint64_t bucketSize, const std::string& name): rateLimit(rateLimit), bucketSize(bucketSize), name(name) {
this->eachStep = this->rateLimit / 250.0;
this->currentTokenSize = 0;
this->isStart = false;
// NFD_LOG_DEBUG("Create tokenBucket: " << name << ", eachStep: " << this->eachStep << ", rateLimit: " << this->rateLimit);
}
void TokenBucket::start() {
if (this->isStart) {
return;
}
// 每 4ms 增加一次令牌
getScheduler().schedule(time::milliseconds(4), std::bind(&TokenBucket::generateToken, this));
}
void TokenBucket::generateToken() {
// NFD_LOG_DEBUG(this->name << "=> do generateToken => " << this->currentTokenSize);
if (this->currentTokenSize + this->eachStep > this->bucketSize) {
this->currentTokenSize = this->bucketSize;
} else {
this->currentTokenSize += this->eachStep;
}
getScheduler().schedule(time::milliseconds(4), std::bind(&TokenBucket::generateToken, this));
}
bool TokenBucket::use(uint64_t tokenNum) {
if(this->currentTokenSize > tokenNum) {
this->currentTokenSize -= tokenNum;
// NFD_LOG_DEBUG(this->name << "=> use success => " << this->currentTokenSize);
return true;
} else {
// NFD_LOG_DEBUG(this->name << "=> use failed => " << this->currentTokenSize);
return false;
}
}
}
}
+34
View File
@@ -0,0 +1,34 @@
//
// Created by gdcni21 on 3/25/22.
//
#ifndef NS_TOKENBUCKET_H
#define NS_TOKENBUCKET_H
#include <memory>
#include <string>
namespace nfd {
namespace face {
class TokenBucket {
public:
explicit TokenBucket(uint64_t rateLimit, uint64_t bucketSize, const std::string& name);
void start();
/**
* 周期性增加token
**/
void generateToken();
/**
* 尝试消费n个token
* @param tokenNum
* @return
*/
bool use(uint64_t tokenNum);
public:
double eachStep; // 每个周期增加的令牌
double currentTokenSize; // 当前令牌数
uint64_t rateLimit; // 令牌生成速率
uint64_t bucketSize; // 令牌桶容量
std::string name;
bool isStart; // 标识是否启动
};
}
}
#endif //NS_TOKENBUCKET_H
+62
View File
@@ -0,0 +1,62 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_CHANNEL_LOG_HPP
#define NFD_DAEMON_FACE_CHANNEL_LOG_HPP
#include "common/logger.hpp"
/** \defgroup ChannelLogging Channel logging macros
*
* These macros augment the log message with some channel-specific information,
* such as the local URI, that are useful to distinguish which channel produced
* the message. It is strongly recommended to use these macros instead of the
* generic ones for all logging inside Channel subclasses.
* @{
*/
/** \cond */
#define NFD_LOG_CHAN(level, msg) NFD_LOG_##level( \
"[" << this->getUri() << "] " << msg)
/** \endcond */
/** \brief Log a message at TRACE level */
#define NFD_LOG_CHAN_TRACE(msg) NFD_LOG_CHAN(TRACE, msg)
/** \brief Log a message at DEBUG level */
#define NFD_LOG_CHAN_DEBUG(msg) NFD_LOG_CHAN(DEBUG, msg)
/** \brief Log a message at INFO level */
#define NFD_LOG_CHAN_INFO(msg) NFD_LOG_CHAN(INFO, msg)
/** \brief Log a message at WARN level */
#define NFD_LOG_CHAN_WARN(msg) NFD_LOG_CHAN(WARN, msg)
/** \brief Log a message at ERROR level */
#define NFD_LOG_CHAN_ERROR(msg) NFD_LOG_CHAN(ERROR, msg)
/** @} */
#endif // NFD_DAEMON_FACE_CHANNEL_LOG_HPP
+30 -14
View File
@@ -1,11 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,20 +21,35 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "channel.hpp"
#include "face.hpp"
namespace nfd {
namespace nfd::face {
Channel::~Channel()
{
}
Channel::~Channel() = default;
void
Channel::setUri(const FaceUri& uri)
Channel::setUri(const FaceUri& uri) noexcept
{
m_uri = uri;
}
} // namespace nfd
void
Channel::setDefaultMtu(size_t mtu) noexcept
{
m_defaultMtu = mtu;
}
void
connectFaceClosedSignal(Face& face, std::function<void()> f)
{
face.afterStateChange.connect([f = std::move(f)] (auto, FaceState newState) {
if (newState == FaceState::CLOSED) {
f();
}
});
}
} // namespace nfd::face
+68 -30
View File
@@ -1,11 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,49 +21,86 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NFD_DAEMON_FACE_CHANNEL_HPP
#define NFD_DAEMON_FACE_CHANNEL_HPP
#include "face.hpp"
#include "channel-log.hpp"
#include "face-common.hpp"
namespace nfd {
namespace nfd::face {
class Channel : noncopyable
/** \brief Represents a channel that listens on a local endpoint.
* \sa FaceSystem
*
* A channel can listen on a local endpoint and initiate outgoing connection from a local endpoint.
* A channel creates Face objects and retains shared ownership of them.
*/
class Channel : public std::enable_shared_from_this<Channel>, noncopyable
{
public:
/** \brief Prototype for the callback called when face is created
* (as a response to incoming connection or after connection
* is established)
*/
typedef function<void(const shared_ptr<Face>& newFace)> FaceCreatedCallback;
/** \brief Prototype for the callback that is called when face is failed to
* get created
*/
typedef function<void(const std::string& reason)> ConnectFailedCallback;
virtual
~Channel();
const FaceUri&
getUri() const;
getUri() const noexcept
{
return m_uri;
}
/**
* \brief Returns the default MTU for all faces created by this channel.
*/
size_t
getDefaultMtu() const noexcept
{
return m_defaultMtu;
}
/**
* \brief Returns whether the channel is listening.
*/
virtual bool
isListening() const = 0;
/**
* \brief Returns the number of faces in the channel.
*/
virtual size_t
size() const = 0;
protected:
void
setUri(const FaceUri& uri);
setUri(const FaceUri& uri) noexcept;
void
setDefaultMtu(size_t mtu) noexcept;
private:
FaceUri m_uri;
size_t m_defaultMtu = ndn::MAX_NDN_PACKET_SIZE;
};
inline const FaceUri&
Channel::getUri() const
{
return m_uri;
}
/** \brief Prototype for the callback that is invoked when a face is created
* (in response to an incoming connection or after a connection is established).
*/
using FaceCreatedCallback = std::function<void(const shared_ptr<Face>&)>;
} // namespace nfd
/** \brief Prototype for the callback that is invoked when a face fails to be created.
*/
using FaceCreationFailedCallback = std::function<void(uint32_t status, const std::string& reason)>;
/** \brief Invokes a callback when a face is closed.
* \param face the face
* \param f the callback to be invoked when the face enters CLOSED state
*
* This function connects a callback to the afterStateChange signal of \p face,
* and invokes \p f when the state becomes CLOSED.
*/
void
connectFaceClosedSignal(Face& face, std::function<void()> f);
} // namespace nfd::face
#endif // NFD_DAEMON_FACE_CHANNEL_HPP
-342
View File
@@ -1,342 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_DATAGRAM_FACE_HPP
#define NFD_DAEMON_FACE_DATAGRAM_FACE_HPP
#include "face.hpp"
#include "core/logger.hpp"
namespace nfd {
class Unicast {};
class Multicast {};
template<class Protocol, class Type = Unicast>
class DatagramFace : public Face
{
public:
typedef Protocol protocol;
/** \brief Construct datagram face
*
* \param socket Protocol-specific socket for the created face
* \param isOnDemand If true, the face can be closed after it remains
* unused for a certain amount of time
*/
DatagramFace(const FaceUri& remoteUri, const FaceUri& localUri,
const shared_ptr<typename protocol::socket>& socket,
bool isOnDemand);
virtual
~DatagramFace();
// from Face
virtual void
sendInterest(const Interest& interest);
virtual void
sendData(const Data& data);
virtual void
close();
void
receiveDatagram(const uint8_t* buffer,
size_t nBytesReceived,
const boost::system::error_code& error);
/**
* \brief Set m_hasBeenUsedRecently to false
*/
void
resetRecentUsage();
bool
hasBeenUsedRecently() const;
void
setOnDemand(bool isOnDemand);
protected:
void
handleSend(const boost::system::error_code& error,
size_t nBytesSent,
const Block& payload);
void
handleReceive(const boost::system::error_code& error,
size_t nBytesReceived);
void
keepFaceAliveUntilAllHandlersExecuted(const shared_ptr<Face>& face);
void
closeSocket();
protected:
shared_ptr<typename protocol::socket> m_socket;
uint8_t m_inputBuffer[MAX_NDN_PACKET_SIZE];
bool m_hasBeenUsedRecently;
NFD_LOG_INCLASS_DECLARE();
};
template<class T, class U>
inline
DatagramFace<T, U>::DatagramFace(const FaceUri& remoteUri, const FaceUri& localUri,
const shared_ptr<typename DatagramFace::protocol::socket>& socket,
bool isOnDemand)
: Face(remoteUri, localUri)
, m_socket(socket)
{
setOnDemand(isOnDemand);
m_socket->async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0,
bind(&DatagramFace<T, U>::handleReceive, this, _1, _2));
}
template<class T, class U>
inline
DatagramFace<T, U>::~DatagramFace()
{
}
template<class T, class U>
inline void
DatagramFace<T, U>::sendInterest(const Interest& interest)
{
this->onSendInterest(interest);
const Block& payload = interest.wireEncode();
m_socket->async_send(boost::asio::buffer(payload.wire(), payload.size()),
bind(&DatagramFace<T, U>::handleSend, this, _1, _2, payload));
// anything else should be done here?
}
template<class T, class U>
inline void
DatagramFace<T, U>::sendData(const Data& data)
{
this->onSendData(data);
const Block& payload = data.wireEncode();
m_socket->async_send(boost::asio::buffer(payload.wire(), payload.size()),
bind(&DatagramFace<T, U>::handleSend, this, _1, _2, payload));
// anything else should be done here?
}
template<class T, class U>
inline void
DatagramFace<T, U>::handleSend(const boost::system::error_code& error,
size_t nBytesSent,
const Block& payload)
// 'payload' is unused; it's needed to retain the underlying Buffer
{
if (error != 0) {
if (error == boost::system::errc::operation_canceled) // when socket is closed by someone
return;
if (!m_socket->is_open()) {
fail("Tunnel closed");
return;
}
NFD_LOG_WARN("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Send operation failed, closing socket: "
<< error.category().message(error.value()));
closeSocket();
if (error == boost::asio::error::eof) {
fail("Tunnel closed");
}
else {
fail("Send operation failed, closing socket: " +
error.category().message(error.value()));
}
return;
}
NFD_LOG_TRACE("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Successfully sent: " << nBytesSent << " bytes");
this->getMutableCounters().getNOutBytes() += nBytesSent;
}
template<class T, class U>
inline void
DatagramFace<T, U>::close()
{
if (!m_socket->is_open())
return;
NFD_LOG_INFO("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Close tunnel");
closeSocket();
fail("Close tunnel");
}
template<class T, class U>
inline void
DatagramFace<T, U>::handleReceive(const boost::system::error_code& error,
size_t nBytesReceived)
{
NFD_LOG_DEBUG("handleReceive: " << nBytesReceived);
receiveDatagram(m_inputBuffer, nBytesReceived, error);
if (m_socket->is_open())
m_socket->async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0,
bind(&DatagramFace<T, U>::handleReceive, this, _1, _2));
}
template<class T, class U>
inline void
DatagramFace<T, U>::receiveDatagram(const uint8_t* buffer,
size_t nBytesReceived,
const boost::system::error_code& error)
{
if (error != 0 || nBytesReceived == 0) {
if (error == boost::system::errc::operation_canceled) // when socket is closed by someone
return;
// this should be unnecessary, but just in case
if (!m_socket->is_open()) {
fail("Tunnel closed");
return;
}
NFD_LOG_WARN("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Receive operation failed: "
<< error.category().message(error.value()));
closeSocket();
if (error == boost::asio::error::eof) {
fail("Tunnel closed");
}
else {
fail("Receive operation failed, closing socket: " +
error.category().message(error.value()));
}
return;
}
NFD_LOG_TRACE("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Received: " << nBytesReceived << " bytes");
this->getMutableCounters().getNInBytes() += nBytesReceived;
Block element;
bool isOk = Block::fromBuffer(buffer, nBytesReceived, element);
if (!isOk)
{
NFD_LOG_WARN("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Failed to parse incoming packet");
// This message won't extend the face lifetime
return;
}
if (element.size() != nBytesReceived)
{
NFD_LOG_WARN("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Received datagram size and decoded "
<< "element size don't match");
// This message won't extend the face lifetime
return;
}
if (!this->decodeAndDispatchInput(element))
{
NFD_LOG_WARN("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] Received unrecognized block of type ["
<< element.type() << "]");
// This message won't extend the face lifetime
return;
}
m_hasBeenUsedRecently = true;
}
template<class T, class U>
inline void
DatagramFace<T, U>::keepFaceAliveUntilAllHandlersExecuted(const shared_ptr<Face>& face)
{
}
template<class T, class U>
inline void
DatagramFace<T, U>::closeSocket()
{
NFD_LOG_DEBUG("[id:" << this->getId()
<< ",uri:" << this->getRemoteUri()
<< "] closeSocket");
boost::asio::io_service& io = m_socket->get_io_service();
// use the non-throwing variants and ignore errors, if any
boost::system::error_code error;
m_socket->shutdown(protocol::socket::shutdown_both, error);
m_socket->close(error);
// after this, handlers will be called with an error code
// ensure that the Face object is alive at least until all pending
// handlers are dispatched
io.post(bind(&DatagramFace<T, U>::keepFaceAliveUntilAllHandlersExecuted,
this, this->shared_from_this()));
}
template<class T, class U>
inline void
DatagramFace<T, U>::setOnDemand(bool isOnDemand)
{
Face::setOnDemand(isOnDemand);
}
template<class T, class U>
inline void
DatagramFace<T, U>::resetRecentUsage()
{
m_hasBeenUsedRecently = false;
}
template<class T, class U>
inline bool
DatagramFace<T, U>::hasBeenUsedRecently() const
{
return m_hasBeenUsedRecently;
}
} // namespace nfd
#endif // NFD_DAEMON_FACE_DATAGRAM_FACE_HPP
+265
View File
@@ -0,0 +1,265 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_DATAGRAM_TRANSPORT_HPP
#define NFD_DAEMON_FACE_DATAGRAM_TRANSPORT_HPP
#include "transport.hpp"
#include "socket-utils.hpp"
#include "common/global.hpp"
#include <array>
#include <boost/asio/defer.hpp>
namespace nfd::face {
struct Unicast {};
struct Multicast {};
/**
* \brief Implements a Transport for datagram-based protocols.
*
* \tparam Protocol A datagram-based protocol in Boost.Asio
* \tparam Addressing The addressing mode, either Unicast or Multicast
*/
template<class Protocol, class Addressing>
class DatagramTransport : public Transport
{
public:
using protocol = Protocol;
using addressing = Addressing;
/**
* \brief Construct datagram transport.
*
* \param socket Protocol-specific socket for the created transport
*/
explicit
DatagramTransport(typename protocol::socket&& socket);
ssize_t
getSendQueueLength() override;
/**
* \brief Receive datagram, translate buffer into packet, deliver to parent class.
*/
void
receiveDatagram(span<const uint8_t> buffer, const boost::system::error_code& error);
protected:
void
doClose() override;
void
doSend(const Block& packet) override;
void
handleSend(const boost::system::error_code& error, size_t nBytesSent);
void
handleReceive(const boost::system::error_code& error, size_t nBytesReceived);
void
processErrorCode(const boost::system::error_code& error);
bool
hasRecentlyReceived() const;
void
resetRecentlyReceived();
protected:
typename protocol::socket m_socket;
typename protocol::endpoint m_sender;
NFD_LOG_MEMBER_DECL();
private:
std::array<uint8_t, ndn::MAX_NDN_PACKET_SIZE> m_receiveBuffer;
bool m_hasRecentlyReceived;
};
template<class T, class U>
DatagramTransport<T, U>::DatagramTransport(typename DatagramTransport::protocol::socket&& socket)
: m_socket(std::move(socket))
, m_hasRecentlyReceived(false)
{
boost::asio::socket_base::send_buffer_size sendBufferSizeOption;
boost::system::error_code error;
m_socket.get_option(sendBufferSizeOption, error);
if (error) {
NFD_LOG_FACE_WARN("Failed to obtain send queue capacity from socket: " << error.message());
this->setSendQueueCapacity(QUEUE_ERROR);
}
else {
this->setSendQueueCapacity(sendBufferSizeOption.value());
}
m_socket.async_receive_from(boost::asio::buffer(m_receiveBuffer), m_sender,
[this] (auto&&... args) {
this->handleReceive(std::forward<decltype(args)>(args)...);
});
}
template<class T, class U>
ssize_t
DatagramTransport<T, U>::getSendQueueLength()
{
ssize_t queueLength = getTxQueueLength(m_socket.native_handle());
if (queueLength == QUEUE_ERROR) {
NFD_LOG_FACE_WARN("Failed to obtain send queue length from socket: " << std::strerror(errno));
}
return queueLength;
}
template<class T, class U>
void
DatagramTransport<T, U>::doClose()
{
NFD_LOG_FACE_TRACE(__func__);
if (m_socket.is_open()) {
// Cancel all outstanding operations and close the socket.
// Use the non-throwing variants and ignore errors, if any.
boost::system::error_code error;
m_socket.cancel(error);
m_socket.close(error);
}
// Ensure that the Transport stays alive at least until
// all pending handlers are dispatched
boost::asio::defer(getGlobalIoService(), [this] {
this->setState(TransportState::CLOSED);
});
}
template<class T, class U>
void
DatagramTransport<T, U>::doSend(const Block& packet)
{
NFD_LOG_FACE_TRACE(__func__);
m_socket.async_send(boost::asio::buffer(packet),
// 'packet' is copied into the lambda to retain the underlying Buffer
[this, packet] (auto&&... args) {
this->handleSend(std::forward<decltype(args)>(args)...);
});
}
template<class T, class U>
void
DatagramTransport<T, U>::receiveDatagram(span<const uint8_t> buffer,
const boost::system::error_code& error)
{
if (error)
return processErrorCode(error);
NFD_LOG_FACE_TRACE("Received: " << buffer.size() << " bytes from " << m_sender);
auto [isOk, element] = Block::fromBuffer(buffer);
if (!isOk) {
NFD_LOG_FACE_WARN("Failed to parse incoming packet from " << m_sender);
// This packet won't extend the face lifetime
return;
}
if (element.size() != buffer.size()) {
NFD_LOG_FACE_WARN("Received datagram size and decoded element size don't match");
// This packet won't extend the face lifetime
return;
}
m_hasRecentlyReceived = true;
if constexpr (std::is_same_v<addressing, Multicast>)
this->receive(element, m_sender);
else
this->receive(element);
}
template<class T, class U>
void
DatagramTransport<T, U>::handleReceive(const boost::system::error_code& error, size_t nBytesReceived)
{
receiveDatagram(ndn::make_span(m_receiveBuffer).first(nBytesReceived), error);
if (m_socket.is_open())
m_socket.async_receive_from(boost::asio::buffer(m_receiveBuffer), m_sender,
[this] (auto&&... args) {
this->handleReceive(std::forward<decltype(args)>(args)...);
});
}
template<class T, class U>
void
DatagramTransport<T, U>::handleSend(const boost::system::error_code& error, size_t nBytesSent)
{
if (error)
return processErrorCode(error);
NFD_LOG_FACE_TRACE("Successfully sent: " << nBytesSent << " bytes");
}
template<class T, class U>
void
DatagramTransport<T, U>::processErrorCode(const boost::system::error_code& error)
{
NFD_LOG_FACE_TRACE(__func__);
if (getState() == TransportState::CLOSING ||
getState() == TransportState::FAILED ||
getState() == TransportState::CLOSED ||
error == boost::asio::error::operation_aborted) {
// transport is shutting down, ignore any errors
return;
}
if (getPersistency() == ndn::nfd::FACE_PERSISTENCY_PERMANENT) {
NFD_LOG_FACE_DEBUG("Permanent face ignores error: " << error.message());
return;
}
NFD_LOG_FACE_ERROR("Send or receive operation failed: " << error.message());
this->setState(TransportState::FAILED);
doClose();
}
template<class T, class U>
bool
DatagramTransport<T, U>::hasRecentlyReceived() const
{
return m_hasRecentlyReceived;
}
template<class T, class U>
void
DatagramTransport<T, U>::resetRecentlyReceived()
{
m_hasRecentlyReceived = false;
}
} // namespace nfd::face
#endif // NFD_DAEMON_FACE_DATAGRAM_TRANSPORT_HPP
+237
View File
@@ -0,0 +1,237 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ethernet-channel.hpp"
#include "ethernet-protocol.hpp"
#include "face.hpp"
#include "generic-link-service.hpp"
#include "unicast-ethernet-transport.hpp"
#include "common/global.hpp"
#include <boost/range/adaptor/map.hpp>
#include <pcap/pcap.h>
namespace nfd::face {
NFD_LOG_INIT(EthernetChannel);
EthernetChannel::EthernetChannel(shared_ptr<const ndn::net::NetworkInterface> localEndpoint,
time::nanoseconds idleTimeout)
: m_localEndpoint(std::move(localEndpoint))
, m_isListening(false)
, m_socket(getGlobalIoService())
, m_pcap(m_localEndpoint->getName())
, m_idleFaceTimeout(idleTimeout)
#ifdef _DEBUG
, m_nDropped(0)
#endif
{
setUri(FaceUri::fromDev(m_localEndpoint->getName()));
NFD_LOG_CHAN_INFO("Creating channel");
}
void
EthernetChannel::connect(const ethernet::Address& remoteEndpoint,
const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed)
{
shared_ptr<Face> face;
try {
face = createFace(remoteEndpoint, params).second;
}
catch (const boost::system::system_error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << remoteEndpoint << " failed: " << e.what());
if (onConnectFailed)
onConnectFailed(504, "Face creation failed: "s + e.what());
return;
}
// Need to invoke the callback regardless of whether or not we had already
// created the face so that control responses and such can be sent
onFaceCreated(face);
}
void
EthernetChannel::listen(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onFaceCreationFailed)
{
if (isListening()) {
NFD_LOG_CHAN_WARN("Already listening");
return;
}
m_isListening = true;
try {
m_pcap.activate(DLT_EN10MB);
m_socket.assign(m_pcap.getFd());
}
catch (const PcapHelper::Error& e) {
NDN_THROW_NESTED(Error(e.what()));
}
updateFilter();
asyncRead(onFaceCreated, onFaceCreationFailed);
NFD_LOG_CHAN_DEBUG("Started listening");
}
void
EthernetChannel::asyncRead(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onReceiveFailed)
{
m_socket.async_wait(boost::asio::posix::stream_descriptor::wait_read, [=] (const auto& e) {
handleRead(e, onFaceCreated, onReceiveFailed);
});
}
void
EthernetChannel::handleRead(const boost::system::error_code& error,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onReceiveFailed)
{
if (error) {
if (error != boost::asio::error::operation_aborted) {
NFD_LOG_CHAN_DEBUG("Receive failed: " << error.message());
if (onReceiveFailed)
onReceiveFailed(500, "Receive failed: " + error.message());
}
return;
}
auto [pkt, readErr] = m_pcap.readNextPacket();
if (pkt.empty()) {
NFD_LOG_CHAN_WARN("Read error: " << readErr);
}
else {
auto [eh, frameErr] = ethernet::checkFrameHeader(pkt, m_localEndpoint->getEthernetAddress(),
m_localEndpoint->getEthernetAddress());
if (eh == nullptr) {
NFD_LOG_CHAN_DEBUG(frameErr);
}
else {
ethernet::Address sender(eh->ether_shost);
pkt = pkt.subspan(ethernet::HDR_LEN);
processIncomingPacket(pkt, sender, onFaceCreated, onReceiveFailed);
}
}
#ifdef _DEBUG
size_t nDropped = m_pcap.getNDropped();
if (nDropped - m_nDropped > 0)
NFD_LOG_CHAN_DEBUG("Detected " << nDropped - m_nDropped << " dropped frame(s)");
m_nDropped = nDropped;
#endif
asyncRead(onFaceCreated, onReceiveFailed);
}
void
EthernetChannel::processIncomingPacket(span<const uint8_t> packet,
const ethernet::Address& sender,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onReceiveFailed)
{
NFD_LOG_CHAN_TRACE("New peer " << sender);
bool isCreated = false;
shared_ptr<Face> face;
try {
FaceParams params;
params.persistency = ndn::nfd::FACE_PERSISTENCY_ON_DEMAND;
std::tie(isCreated, face) = createFace(sender, params);
}
catch (const EthernetTransport::Error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << sender << " failed: " << e.what());
if (onReceiveFailed)
onReceiveFailed(504, "Face creation failed: "s + e.what());
return;
}
if (isCreated)
onFaceCreated(face);
else
NFD_LOG_CHAN_DEBUG("Received frame for existing face");
// dispatch the packet to the face for processing
auto* transport = static_cast<UnicastEthernetTransport*>(face->getTransport());
transport->receivePayload(packet, sender);
}
std::pair<bool, shared_ptr<Face>>
EthernetChannel::createFace(const ethernet::Address& remoteEndpoint,
const FaceParams& params)
{
auto it = m_channelFaces.find(remoteEndpoint);
if (it != m_channelFaces.end()) {
// we already have a face for this endpoint, so reuse it
NFD_LOG_CHAN_TRACE("Reusing existing face for " << remoteEndpoint);
return {false, it->second};
}
// else, create a new face
GenericLinkService::Options options;
options.allowFragmentation = true;
options.allowReassembly = true;
options.reliabilityOptions.isEnabled = params.wantLpReliability;
if (params.mtu) {
options.overrideMtu = *params.mtu;
}
auto linkService = make_unique<GenericLinkService>(options);
auto transport = make_unique<UnicastEthernetTransport>(*m_localEndpoint, remoteEndpoint,
params.persistency, m_idleFaceTimeout);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
face->setChannel(weak_from_this());
m_channelFaces[remoteEndpoint] = face;
connectFaceClosedSignal(*face, [this, remoteEndpoint] {
m_channelFaces.erase(remoteEndpoint);
updateFilter();
});
updateFilter();
return {true, face};
}
void
EthernetChannel::updateFilter()
{
if (!isListening())
return;
std::string filter = "(ether proto " + to_string(ethernet::ETHERTYPE_NDN) +
") && (ether dst " + m_localEndpoint->getEthernetAddress().toString() + ")";
for (const auto& addr : m_channelFaces | boost::adaptors::map_keys) {
filter += " && (not ether src " + addr.toString() + ")";
}
// "not vlan" must appear last in the filter expression, or the
// rest of the filter won't work as intended, see pcap-filter(7)
filter += " && (not vlan)";
NFD_LOG_CHAN_TRACE("Updating filter: " << filter);
m_pcap.setPacketFilter(filter.data());
}
} // namespace nfd::face
+138
View File
@@ -0,0 +1,138 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_ETHERNET_CHANNEL_HPP
#define NFD_DAEMON_FACE_ETHERNET_CHANNEL_HPP
#include "channel.hpp"
#include "ethernet-protocol.hpp"
#include "pcap-helper.hpp"
#include <boost/asio/posix/stream_descriptor.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
/**
* \brief Class implementing an Ethernet-based channel to create faces.
*/
class EthernetChannel final : public Channel
{
public:
/**
* \brief EthernetChannel-related error.
*/
class Error : public std::runtime_error
{
public:
using std::runtime_error::runtime_error;
};
/**
* \brief Create an Ethernet channel on the given \p localEndpoint (network interface).
*
* To enable the creation of faces upon incoming connections, one needs to
* explicitly call listen().
*/
EthernetChannel(shared_ptr<const ndn::net::NetworkInterface> localEndpoint,
time::nanoseconds idleTimeout);
bool
isListening() const final
{
return m_isListening;
}
size_t
size() const final
{
return m_channelFaces.size();
}
/**
* \brief Create a unicast Ethernet face toward \p remoteEndpoint.
*/
void
connect(const ethernet::Address& remoteEndpoint,
const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed);
/**
* \brief Start listening.
*
* Enable listening on the local endpoint, waiting for incoming frames,
* and creating a face when a frame is received from a new remote host.
*
* Faces created in this way will have on-demand persistency.
*
* \param onFaceCreated Callback to notify successful creation of a face
* \param onFaceCreationFailed Callback to notify errors
* \throw Error
*/
void
listen(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onFaceCreationFailed);
private:
void
asyncRead(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onReceiveFailed);
void
handleRead(const boost::system::error_code& error,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onReceiveFailed);
void
processIncomingPacket(span<const uint8_t> packet,
const ethernet::Address& sender,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onReceiveFailed);
std::pair<bool, shared_ptr<Face>>
createFace(const ethernet::Address& remoteEndpoint,
const FaceParams& params);
void
updateFilter();
private:
shared_ptr<const ndn::net::NetworkInterface> m_localEndpoint;
bool m_isListening;
boost::asio::posix::stream_descriptor m_socket;
PcapHelper m_pcap;
std::map<ethernet::Address, shared_ptr<Face>> m_channelFaces;
const time::nanoseconds m_idleFaceTimeout; ///< Timeout for automatic closure of idle on-demand faces
#ifdef _DEBUG
/// number of frames dropped by the kernel, as reported by libpcap
size_t m_nDropped;
#endif
};
} // namespace nfd::face
#endif // NFD_DAEMON_FACE_ETHERNET_CHANNEL_HPP
-333
View File
@@ -1,333 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "ethernet-face.hpp"
#include "core/logger.hpp"
#include "core/network-interface.hpp"
#include <pcap/pcap.h>
#include <cstring> // for std::strncpy()
#include <arpa/inet.h> // for htons() and ntohs()
#include <net/ethernet.h> // for struct ether_header
#include <net/if.h> // for struct ifreq
#include <stdio.h> // for snprintf()
#include <sys/ioctl.h> // for ioctl()
#include <unistd.h> // for dup()
#if !defined(PCAP_NETMASK_UNKNOWN)
/*
* Value to pass to pcap_compile() as the netmask if you don't know what
* the netmask is.
*/
#define PCAP_NETMASK_UNKNOWN 0xffffffff
#endif
namespace nfd {
NFD_LOG_INIT("EthernetFace");
EthernetFace::EthernetFace(const shared_ptr<boost::asio::posix::stream_descriptor>& socket,
const shared_ptr<NetworkInterfaceInfo>& interface,
const ethernet::Address& address)
: Face(FaceUri(address), FaceUri::fromDev(interface->name))
, m_socket(socket)
, m_interfaceName(interface->name)
, m_srcAddress(interface->etherAddress)
, m_destAddress(address)
{
NFD_LOG_INFO("Creating ethernet face on " << m_interfaceName << ": "
<< m_srcAddress << " <--> " << m_destAddress);
pcapInit();
int fd = pcap_get_selectable_fd(m_pcap);
if (fd < 0)
throw Error("pcap_get_selectable_fd() failed");
// need to duplicate the fd, otherwise both pcap_close()
// and stream_descriptor::close() will try to close the
// same fd and one of them will fail
m_socket->assign(::dup(fd));
m_interfaceMtu = getInterfaceMtu();
NFD_LOG_DEBUG("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Interface MTU is: " << m_interfaceMtu);
char filter[100];
::snprintf(filter, sizeof(filter),
"(ether proto 0x%x) && (ether dst %s) && (not ether src %s)",
ETHERTYPE_NDN,
m_destAddress.toString().c_str(),
m_srcAddress.toString().c_str());
setPacketFilter(filter);
m_socket->async_read_some(boost::asio::null_buffers(),
bind(&EthernetFace::handleRead, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
EthernetFace::~EthernetFace()
{
onFail.clear(); // no reason to call onFail anymore
close();
}
void
EthernetFace::sendInterest(const Interest& interest)
{
onSendInterest(interest);
sendPacket(interest.wireEncode());
}
void
EthernetFace::sendData(const Data& data)
{
onSendData(data);
sendPacket(data.wireEncode());
}
void
EthernetFace::close()
{
if (m_pcap)
{
boost::system::error_code error;
m_socket->close(error); // ignore errors
pcap_close(m_pcap);
m_pcap = 0;
fail("Face closed");
}
}
void
EthernetFace::pcapInit()
{
char errbuf[PCAP_ERRBUF_SIZE];
errbuf[0] = '\0';
m_pcap = pcap_create(m_interfaceName.c_str(), errbuf);
if (!m_pcap)
throw Error("pcap_create(): " + std::string(errbuf));
#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
// Enable "immediate mode", effectively disabling any read buffering in the kernel.
// This corresponds to the BIOCIMMEDIATE ioctl on BSD-like systems (including OS X)
// where libpcap uses a BPF device. On Linux this forces libpcap not to use TPACKET_V3,
// even if the kernel supports it, thus preventing bug #1511.
pcap_set_immediate_mode(m_pcap, 1);
#endif
/// \todo Do not rely on promisc mode, see task #1278
if (!m_destAddress.isBroadcast())
pcap_set_promisc(m_pcap, 1);
if (pcap_activate(m_pcap) < 0)
throw Error("pcap_activate() failed");
if (pcap_set_datalink(m_pcap, DLT_EN10MB) < 0)
throw Error("pcap_set_datalink(): " + std::string(pcap_geterr(m_pcap)));
if (pcap_setdirection(m_pcap, PCAP_D_IN) < 0)
// no need to throw on failure, BPF will filter unwanted packets anyway
NFD_LOG_WARN("pcap_setdirection(): " << pcap_geterr(m_pcap));
}
void
EthernetFace::setPacketFilter(const char* filterString)
{
bpf_program filter;
if (pcap_compile(m_pcap, &filter, filterString, 1, PCAP_NETMASK_UNKNOWN) < 0)
throw Error("pcap_compile(): " + std::string(pcap_geterr(m_pcap)));
int ret = pcap_setfilter(m_pcap, &filter);
pcap_freecode(&filter);
if (ret < 0)
throw Error("pcap_setfilter(): " + std::string(pcap_geterr(m_pcap)));
}
void
EthernetFace::sendPacket(const ndn::Block& block)
{
if (!m_pcap)
{
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Trying to send on closed face");
fail("Face closed");
return;
}
/// \todo Fragmentation
if (block.size() > m_interfaceMtu)
{
NFD_LOG_ERROR("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Fragmentation not implemented: dropping packet larger than MTU");
return;
}
/// \todo Right now there is no reserve when packet is received, but
/// we should reserve some space at the beginning and at the end
ndn::EncodingBuffer buffer(block);
// pad with zeroes if the payload is too short
if (block.size() < ethernet::MIN_DATA_LEN)
{
static const uint8_t padding[ethernet::MIN_DATA_LEN] = {0};
buffer.appendByteArray(padding, ethernet::MIN_DATA_LEN - block.size());
}
// construct and prepend the ethernet header
static uint16_t ethertype = htons(ETHERTYPE_NDN);
buffer.prependByteArray(reinterpret_cast<const uint8_t*>(&ethertype), ethernet::TYPE_LEN);
buffer.prependByteArray(m_srcAddress.data(), m_srcAddress.size());
buffer.prependByteArray(m_destAddress.data(), m_destAddress.size());
// send the packet
int sent = pcap_inject(m_pcap, buffer.buf(), buffer.size());
if (sent < 0)
{
throw Error("pcap_inject(): " + std::string(pcap_geterr(m_pcap)));
}
else if (static_cast<size_t>(sent) < buffer.size())
{
throw Error("Failed to send packet");
}
NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Successfully sent: " << buffer.size() << " bytes");
}
void
EthernetFace::handleRead(const boost::system::error_code& error, size_t)
{
if (error)
return processErrorCode(error);
pcap_pkthdr* pktHeader;
const uint8_t* packet;
int ret = pcap_next_ex(m_pcap, &pktHeader, &packet);
if (ret < 0)
{
throw Error("pcap_next_ex(): " + std::string(pcap_geterr(m_pcap)));
}
else if (ret == 0)
{
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] pcap_next_ex() timed out");
}
else
{
size_t length = pktHeader->caplen;
if (length < ethernet::HDR_LEN + ethernet::MIN_DATA_LEN)
throw Error("Received packet is too short");
const ether_header* eh = reinterpret_cast<const ether_header*>(packet);
if (ntohs(eh->ether_type) != ETHERTYPE_NDN)
throw Error("Unrecognized ethertype");
packet += ethernet::HDR_LEN;
length -= ethernet::HDR_LEN;
NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Received: " << length << " bytes");
/// \todo Reserve space in front and at the back
/// of the underlying buffer
Block element;
bool isOk = Block::fromBuffer(packet, length, element);
if (isOk)
{
if (!decodeAndDispatchInput(element))
{
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Received unrecognized block of type " << element.type());
// ignore unknown packet
}
}
else
{
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Received block is invalid or too large to process");
}
}
m_socket->async_read_some(boost::asio::null_buffers(),
bind(&EthernetFace::handleRead, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
void
EthernetFace::processErrorCode(const boost::system::error_code& error)
{
if (error == boost::system::errc::operation_canceled)
// when socket is closed by someone
return;
if (!m_pcap)
{
fail("Face closed");
return;
}
std::string msg;
if (error == boost::asio::error::eof)
{
msg = "Face closed";
NFD_LOG_INFO("[id:" << getId() << ",endpoint:" << m_interfaceName << "] " << msg);
}
else
{
msg = "Receive operation failed, closing face: " + error.category().message(error.value());
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName << "] " << msg);
}
close();
fail(msg);
}
size_t
EthernetFace::getInterfaceMtu() const
{
size_t mtu = ethernet::MAX_DATA_LEN;
#ifdef SIOCGIFMTU
ifreq ifr = boost::initialized_value;
std::strncpy(ifr.ifr_name, m_interfaceName.c_str(), sizeof(ifr.ifr_name) - 1);
if (::ioctl(m_socket->native_handle(), SIOCGIFMTU, &ifr) < 0)
{
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
<< "] Failed to get interface MTU, assuming " << mtu);
}
else
{
mtu = std::min(mtu, static_cast<size_t>(ifr.ifr_mtu));
}
#endif
return mtu;
}
} // namespace nfd
-115
View File
@@ -1,115 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_ETHERNET_FACE_HPP
#define NFD_DAEMON_FACE_ETHERNET_FACE_HPP
#include "config.hpp"
#include "ethernet.hpp"
#include "face.hpp"
#ifndef HAVE_LIBPCAP
#error "Cannot include this file when libpcap is not available"
#endif
// forward declarations
struct pcap;
typedef pcap pcap_t;
namespace nfd {
class NetworkInterfaceInfo;
/**
* \brief Implementation of Face abstraction that uses raw
* Ethernet frames as underlying transport mechanism
*/
class EthernetFace : public Face
{
public:
/**
* \brief EthernetFace-related error
*/
struct Error : public Face::Error
{
Error(const std::string& what) : Face::Error(what) {}
};
EthernetFace(const shared_ptr<boost::asio::posix::stream_descriptor>& socket,
const shared_ptr<NetworkInterfaceInfo>& interface,
const ethernet::Address& address);
virtual
~EthernetFace();
/// send an Interest
virtual void
sendInterest(const Interest& interest);
/// send a Data
virtual void
sendData(const Data& data);
/**
* \brief Close the face
*
* This terminates all communication on the face and cause
* onFail() method event to be invoked
*/
virtual void
close();
private:
void
pcapInit();
void
setPacketFilter(const char* filterString);
void
sendPacket(const ndn::Block& block);
void
handleRead(const boost::system::error_code& error,
size_t nBytesRead);
void
processErrorCode(const boost::system::error_code& error);
size_t
getInterfaceMtu() const;
private:
shared_ptr<boost::asio::posix::stream_descriptor> m_socket;
std::string m_interfaceName;
ethernet::Address m_srcAddress;
ethernet::Address m_destAddress;
size_t m_interfaceMtu;
pcap_t* m_pcap;
};
} // namespace nfd
#endif // NFD_DAEMON_FACE_ETHERNET_FACE_HPP
+348 -61
View File
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -24,72 +24,359 @@
*/
#include "ethernet-factory.hpp"
#include "core/logger.hpp"
#include "core/global-io.hpp"
#include "core/network-interface.hpp"
#include "generic-link-service.hpp"
#include "multicast-ethernet-transport.hpp"
#include <boost/algorithm/string/predicate.hpp>
#include <pcap/pcap.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm/copy.hpp>
namespace nfd {
namespace nfd::face {
NFD_LOG_INIT("EthernetFactory");
NFD_LOG_INIT(EthernetFactory);
NFD_REGISTER_PROTOCOL_FACTORY(EthernetFactory);
shared_ptr<EthernetFace>
EthernetFactory::createMulticastFace(const shared_ptr<NetworkInterfaceInfo> &interface,
const ethernet::Address &address)
const std::string&
EthernetFactory::getId() noexcept
{
if (!address.isMulticast())
throw Error(address.toString() + " is not a multicast address");
static std::string id("ether");
return id;
}
const std::string& name = interface->name;
shared_ptr<EthernetFace> face = findMulticastFace(name, address);
if (face)
return face;
EthernetFactory::EthernetFactory(const CtorParams& params)
: ProtocolFactory(params)
{
m_netifAddConn = netmon->onInterfaceAdded.connect([this] (const auto& netif) {
applyUnicastConfigToNetif(netif);
applyMcastConfigToNetif(*netif);
});
}
shared_ptr<boost::asio::posix::stream_descriptor> socket =
make_shared<boost::asio::posix::stream_descriptor>(ref(getGlobalIoService()));
void
EthernetFactory::doProcessConfig(OptionalConfigSection configSection,
FaceSystem::ConfigContext& context)
{
// ether
// {
// listen yes
// idle_timeout 600
// mcast yes
// mcast_group 01:00:5E:00:17:AA
// mcast_ad_hoc no
// whitelist
// {
// *
// }
// blacklist
// {
// }
// }
face = make_shared<EthernetFace>(socket, interface, address);
face->onFail += bind(&EthernetFactory::afterFaceFailed,
this, name, address);
m_multicastFaces[std::make_pair(name, address)] = face;
UnicastConfig unicastConfig;
MulticastConfig mcastConfig;
if (configSection) {
// listen and mcast default to 'yes' but only if face_system.ether section is present
unicastConfig.isEnabled = unicastConfig.wantListen = mcastConfig.isEnabled = true;
for (const auto& pair : *configSection) {
const std::string& key = pair.first;
const ConfigSection& value = pair.second;
if (key == "listen") {
unicastConfig.wantListen = ConfigFile::parseYesNo(pair, "face_system.ether");
}
else if (key == "idle_timeout") {
unicastConfig.idleTimeout = time::seconds(ConfigFile::parseNumber<uint32_t>(pair, "face_system.ether"));
}
else if (key == "mcast") {
mcastConfig.isEnabled = ConfigFile::parseYesNo(pair, "face_system.ether");
}
else if (key == "mcast_group") {
const std::string& valueStr = value.get_value<std::string>();
mcastConfig.group = ethernet::Address::fromString(valueStr);
if (mcastConfig.group.isNull()) {
NDN_THROW(ConfigFile::Error("face_system.ether.mcast_group: '" +
valueStr + "' cannot be parsed as an Ethernet address"));
}
else if (!mcastConfig.group.isMulticast()) {
NDN_THROW(ConfigFile::Error("face_system.ether.mcast_group: '" +
valueStr + "' is not a multicast address"));
}
}
else if (key == "mcast_ad_hoc") {
bool wantAdHoc = ConfigFile::parseYesNo(pair, "face_system.ether");
mcastConfig.linkType = wantAdHoc ? ndn::nfd::LINK_TYPE_AD_HOC : ndn::nfd::LINK_TYPE_MULTI_ACCESS;
}
else if (key == "whitelist") {
mcastConfig.netifPredicate.parseWhitelist(value);
}
else if (key == "blacklist") {
mcastConfig.netifPredicate.parseBlacklist(value);
}
else {
NDN_THROW(ConfigFile::Error("Unrecognized option face_system.ether." + key));
}
}
}
if (context.isDryRun) {
return;
}
if (unicastConfig.isEnabled) {
if (m_unicastConfig.wantListen && !unicastConfig.wantListen && !m_channels.empty()) {
NFD_LOG_WARN("Cannot stop listening on Ethernet channels");
}
if (m_unicastConfig.idleTimeout != unicastConfig.idleTimeout && !m_channels.empty()) {
NFD_LOG_WARN("Idle timeout setting applies to new Ethernet channels only");
}
}
else if (m_unicastConfig.isEnabled && !m_channels.empty()) {
NFD_LOG_WARN("Cannot disable Ethernet channels after initialization");
}
if (m_mcastConfig.isEnabled != mcastConfig.isEnabled) {
if (mcastConfig.isEnabled) {
NFD_LOG_INFO("enabling multicast on " << mcastConfig.group);
}
else {
NFD_LOG_INFO("disabling multicast");
}
}
else if (mcastConfig.isEnabled) {
if (m_mcastConfig.linkType != mcastConfig.linkType && !m_mcastFaces.empty()) {
NFD_LOG_WARN("Cannot change ad hoc setting on existing faces");
}
if (m_mcastConfig.group != mcastConfig.group) {
NFD_LOG_INFO("changing multicast group from " << m_mcastConfig.group <<
" to " << mcastConfig.group);
}
if (m_mcastConfig.netifPredicate != mcastConfig.netifPredicate) {
NFD_LOG_INFO("changing whitelist/blacklist");
}
}
// Even if there are no configuration changes, we still need to re-apply
// the configuration because netifs may have changed.
m_unicastConfig = std::move(unicastConfig);
m_mcastConfig = std::move(mcastConfig);
applyConfig(context);
}
void
EthernetFactory::doCreateFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure)
{
if (!req.localUri || req.localUri->getScheme() != "dev") {
NFD_LOG_TRACE("createFace: dev:// LocalUri required");
onFailure(406, "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme");
return;
}
if (req.params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
NFD_LOG_TRACE("createFace: unsupported FacePersistency");
onFailure(406, "Outgoing Ethernet faces do not support on-demand persistency");
return;
}
ethernet::Address remoteEndpoint(ethernet::Address::fromString(req.remoteUri.getHost()));
std::string localEndpoint(req.localUri->getHost());
if (remoteEndpoint.isMulticast()) {
NFD_LOG_TRACE("createFace: unsupported multicast endpoint");
onFailure(406, "Cannot create multicast Ethernet faces");
return;
}
if (req.params.wantLocalFields) {
// Ethernet faces are never local
NFD_LOG_TRACE("createFace: cannot create non-local face with local fields enabled");
onFailure(406, "Local fields can only be enabled on faces with local scope");
return;
}
if (req.params.mtu && *req.params.mtu < MIN_MTU) {
// The specified MTU must be greater than the minimum possible
NFD_LOG_TRACE("createFace: override MTU cannot be less than " << MIN_MTU);
onFailure(406, "Override MTU cannot be less than " + to_string(MIN_MTU));
return;
}
for (const auto& i : m_channels) {
if (i.first == localEndpoint) {
i.second->connect(remoteEndpoint, req.params, onCreated, onFailure);
return;
}
}
NFD_LOG_TRACE("No channels available to connect to " << remoteEndpoint);
onFailure(504, "No channels available to connect");
}
shared_ptr<EthernetChannel>
EthernetFactory::createChannel(const shared_ptr<const ndn::net::NetworkInterface>& localEndpoint,
time::nanoseconds idleTimeout)
{
auto it = m_channels.find(localEndpoint->getName());
if (it != m_channels.end())
return it->second;
auto channel = std::make_shared<EthernetChannel>(localEndpoint, idleTimeout);
m_channels[localEndpoint->getName()] = channel;
return channel;
}
std::vector<shared_ptr<const Channel>>
EthernetFactory::doGetChannels() const
{
return getChannelsFromMap(m_channels);
}
shared_ptr<Face>
EthernetFactory::createMulticastFace(const ndn::net::NetworkInterface& netif,
const ethernet::Address& address)
{
BOOST_ASSERT(address.isMulticast());
std::pair key(netif.getName(), address);
auto found = m_mcastFaces.find(key);
if (found != m_mcastFaces.end()) {
return found->second;
}
GenericLinkService::Options opts;
opts.allowFragmentation = true;
opts.allowReassembly = true;
auto linkService = make_unique<GenericLinkService>(opts);
auto transport = make_unique<MulticastEthernetTransport>(netif, address, m_mcastConfig.linkType);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
m_mcastFaces[key] = face;
connectFaceClosedSignal(*face, [this, key] { m_mcastFaces.erase(key); });
auto channelIt = m_channels.find(netif.getName());
if (channelIt != m_channels.end()) {
face->setChannel(channelIt->second);
}
return face;
}
shared_ptr<EthernetChannel>
EthernetFactory::applyUnicastConfigToNetif(const shared_ptr<const ndn::net::NetworkInterface>& netif)
{
if (!m_unicastConfig.isEnabled) {
return nullptr;
}
if (!netif->isUp()) {
NFD_LOG_DEBUG("Not creating channel on " << netif->getName() << ": netif is down");
return nullptr;
}
if (netif->getType() != ndn::net::InterfaceType::ETHERNET) {
NFD_LOG_DEBUG("Not creating channel on " << netif->getName() << ": incompatible netif type");
return nullptr;
}
if (netif->getEthernetAddress().isNull()) {
NFD_LOG_DEBUG("Not creating channel on " << netif->getName() << ": invalid Ethernet address");
return nullptr;
}
auto channel = this->createChannel(netif, m_unicastConfig.idleTimeout);
if (m_unicastConfig.wantListen && !channel->isListening()) {
try {
channel->listen(this->addFace, nullptr);
}
catch (const EthernetChannel::Error& e) {
NFD_LOG_WARN("Cannot listen on " << netif->getName() << ": " << e.what());
}
}
return channel;
}
shared_ptr<Face>
EthernetFactory::applyMcastConfigToNetif(const ndn::net::NetworkInterface& netif)
{
if (!m_mcastConfig.isEnabled) {
return nullptr;
}
if (!netif.isUp()) {
NFD_LOG_DEBUG("Not creating multicast face on " << netif.getName() << ": netif is down");
return nullptr;
}
if (netif.getType() != ndn::net::InterfaceType::ETHERNET) {
NFD_LOG_DEBUG("Not creating multicast face on " << netif.getName() << ": incompatible netif type");
return nullptr;
}
if (netif.getEthernetAddress().isNull()) {
NFD_LOG_DEBUG("Not creating multicast face on " << netif.getName() << ": invalid Ethernet address");
return nullptr;
}
if (!netif.canMulticast()) {
NFD_LOG_DEBUG("Not creating multicast face on " << netif.getName() << ": netif cannot multicast");
return nullptr;
}
if (!m_mcastConfig.netifPredicate(netif)) {
NFD_LOG_DEBUG("Not creating multicast face on " << netif.getName() << ": rejected by whitelist/blacklist");
return nullptr;
}
NFD_LOG_DEBUG("Creating multicast face on " << netif.getName());
shared_ptr<Face> face;
try {
face = createMulticastFace(netif, m_mcastConfig.group);
}
catch (const std::runtime_error& e) {
NFD_LOG_WARN("Cannot create multicast face on " << netif.getName() << ": " << e.what());
return nullptr; // not a fatal error
}
if (face->getId() == INVALID_FACEID) {
// new face: register with forwarding
this->addFace(face);
}
return face;
}
void
EthernetFactory::afterFaceFailed(const std::string& interfaceName,
const ethernet::Address& address)
EthernetFactory::applyConfig(const FaceSystem::ConfigContext&)
{
NFD_LOG_DEBUG("afterFaceFailed: " << interfaceName << "/" << address);
m_multicastFaces.erase(std::make_pair(interfaceName, address));
if (m_unicastConfig.isEnabled) {
providedSchemes.insert("ether");
}
else {
providedSchemes.erase("ether");
}
// collect old multicast faces
std::set<shared_ptr<Face>> oldFaces;
boost::copy(m_mcastFaces | boost::adaptors::map_values, std::inserter(oldFaces, oldFaces.end()));
// create channels and multicast faces if requested by config
for (const auto& netif : netmon->listNetworkInterfaces()) {
applyUnicastConfigToNetif(netif);
auto face = applyMcastConfigToNetif(*netif);
if (face != nullptr) {
// don't destroy face
oldFaces.erase(face);
}
}
// destroy old multicast faces that are not needed in new configuration
for (const auto& face : oldFaces) {
face->close();
}
}
shared_ptr<EthernetFace>
EthernetFactory::findMulticastFace(const std::string& interfaceName,
const ethernet::Address& address) const
{
MulticastFaceMap::const_iterator i =
m_multicastFaces.find(std::make_pair(interfaceName, address));
if (i != m_multicastFaces.end())
return i->second;
else
return shared_ptr<EthernetFace>();
}
void
EthernetFactory::createFace(const FaceUri& uri,
const FaceCreatedCallback& onCreated,
const FaceConnectFailedCallback& onConnectFailed)
{
throw Error("EthernetFactory does not support 'createFace' operation");
}
std::list<shared_ptr<const Channel> >
EthernetFactory::getChannels() const
{
return std::list<shared_ptr<const Channel> >();
}
} // namespace nfd
} // namespace nfd::face
+90 -75
View File
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -21,100 +21,115 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NFD_DAEMON_FACE_ETHERNET_FACTORY_HPP
#define NFD_DAEMON_FACE_ETHERNET_FACTORY_HPP
#include "ethernet-face.hpp"
#include "protocol-factory.hpp"
#include "ethernet-channel.hpp"
#include "network-predicate.hpp"
namespace nfd {
namespace nfd::face {
class NetworkInterfaceInfo;
class EthernetFactory : public ProtocolFactory
/**
* \brief Protocol factory for Ethernet.
*/
class EthernetFactory final : public ProtocolFactory
{
public:
/**
* \brief Exception of EthernetFactory
*/
class Error : public ProtocolFactory::Error
{
public:
explicit
Error(const std::string& what)
: ProtocolFactory::Error(what)
{
}
};
static const std::string&
getId() noexcept;
typedef std::map< std::pair<std::string, ethernet::Address>,
shared_ptr<EthernetFace> > MulticastFaceMap;
// from ProtocolFactory
virtual void
createFace(const FaceUri& uri,
const FaceCreatedCallback& onCreated,
const FaceConnectFailedCallback& onConnectFailed);
explicit
EthernetFactory(const CtorParams& params);
/**
* \brief Create an EthernetFace to communicate with the given multicast group
* \brief Create Ethernet-based channel on the specified network interface.
*
* If this method is called twice with the same interface and group, only
* one face will be created. Instead, the second call will just retrieve
* the existing face.
* If this method is called twice with the same endpoint, only one channel
* will be created. The second call will just return the existing channel.
*
* \param interface Local network interface
* \param address Ethernet broadcast/multicast destination address
*
* \returns always a valid shared pointer to an EthernetFace object,
* an exception will be thrown if the creation fails
*
* \throws EthernetFactory::Error or EthernetFace::Error
* \return Always a valid pointer to a EthernetChannel object, an exception
* is thrown if it cannot be created.
* \throw PcapHelper::Error channel creation failed
*/
shared_ptr<EthernetFace>
createMulticastFace(const shared_ptr<NetworkInterfaceInfo>& interface,
const ethernet::Address& address);
shared_ptr<EthernetChannel>
createChannel(const shared_ptr<const ndn::net::NetworkInterface>& localEndpoint,
time::nanoseconds idleTimeout);
/**
* \brief Get map of configured multicast faces
* \brief Create a face to communicate on the given Ethernet multicast group.
*
* If this method is called twice with the same arguments, only one face
* will be created. The second call will just return the existing face.
*
* \param localEndpoint local network interface
* \param group multicast group address
*
* \throw std::runtime_error %Face creation failed
*/
const MulticastFaceMap&
getMulticastFaces() const;
virtual std::list<shared_ptr<const Channel> >
getChannels() const;
shared_ptr<Face>
createMulticastFace(const ndn::net::NetworkInterface& localEndpoint,
const ethernet::Address& group);
private:
void
afterFaceFailed(const std::string& interfaceName,
const ethernet::Address& address);
doProcessConfig(OptionalConfigSection configSection,
FaceSystem::ConfigContext& context) final;
void
doCreateFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) final;
std::vector<shared_ptr<const Channel>>
doGetChannels() const final;
/**
* \brief Look up EthernetFace using specified interface and address
*
* \returns shared pointer to the existing EthernetFace object or
* empty shared pointer when such face does not exist
*
* \throws never
* \brief Create EthernetChannel on \p netif if requested by \p m_unicastConfig.
* \return New or existing channel, or nullptr if no channel should be created.
*/
shared_ptr<EthernetFace>
findMulticastFace(const std::string& interfaceName,
const ethernet::Address& address) const;
shared_ptr<EthernetChannel>
applyUnicastConfigToNetif(const shared_ptr<const ndn::net::NetworkInterface>& netif);
/**
* \brief Create Ethernet multicast face on \p netif if requested by \p m_mcastConfig.
* \return New or existing face, or nullptr if no face should be created.
*/
shared_ptr<Face>
applyMcastConfigToNetif(const ndn::net::NetworkInterface& netif);
void
applyConfig(const FaceSystem::ConfigContext& context);
private:
MulticastFaceMap m_multicastFaces;
// ifname => channel
std::map<std::string, shared_ptr<EthernetChannel>> m_channels;
struct UnicastConfig
{
bool isEnabled = false;
bool wantListen = false;
time::nanoseconds idleTimeout = 10_min;
};
UnicastConfig m_unicastConfig;
struct MulticastConfig
{
bool isEnabled = false;
ethernet::Address group = ethernet::getDefaultMulticastAddress();
ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS;
NetworkInterfacePredicate netifPredicate;
};
MulticastConfig m_mcastConfig;
// [ifname, group] => face
std::map<std::pair<std::string, ethernet::Address>, shared_ptr<Face>> m_mcastFaces;
signal::ScopedConnection m_netifAddConn;
};
inline const EthernetFactory::MulticastFaceMap&
EthernetFactory::getMulticastFaces() const
{
return m_multicastFaces;
}
} // namespace nfd
} // namespace nfd::face
#endif // NFD_DAEMON_FACE_ETHERNET_FACTORY_HPP
+59
View File
@@ -0,0 +1,59 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ethernet-protocol.hpp"
#include <boost/endian/conversion.hpp>
namespace nfd::ethernet {
std::tuple<const ether_header*, std::string>
checkFrameHeader(span<const uint8_t> packet, const Address& localAddr, const Address& destAddr)
{
if (packet.size() < HDR_LEN + MIN_DATA_LEN)
return {nullptr, "Received frame too short: " + to_string(packet.size()) + " bytes"};
const ether_header* eh = reinterpret_cast<const ether_header*>(packet.data());
// in some cases VLAN-tagged frames may survive the BPF filter,
// make sure we do not process those frames (see #3348)
uint16_t ethertype = boost::endian::big_to_native(eh->ether_type);
if (ethertype != ETHERTYPE_NDN)
return {nullptr, "Received frame with wrong ethertype: " + to_string(ethertype)};
#ifdef _DEBUG
Address shost(eh->ether_shost);
if (shost == localAddr)
return {nullptr, "Received frame sent by this host"};
Address dhost(eh->ether_dhost);
if (dhost != destAddr)
return {nullptr, "Received frame addressed to another host or multicast group: " + dhost.toString()};
#endif
return {eh, ""};
}
} // namespace nfd::ethernet
+43
View File
@@ -0,0 +1,43 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_ETHERNET_PROTOCOL_HPP
#define NFD_DAEMON_FACE_ETHERNET_PROTOCOL_HPP
#include "core/common.hpp"
#include <ndn-cxx/net/ethernet.hpp>
#include <net/ethernet.h>
namespace nfd::ethernet {
using namespace ndn::ethernet;
std::tuple<const ether_header*, std::string>
checkFrameHeader(span<const uint8_t> packet, const Address& localAddr, const Address& destAddr);
} // namespace nfd::ethernet
#endif // NFD_DAEMON_FACE_ETHERNET_PROTOCOL_HPP
+225
View File
@@ -0,0 +1,225 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ethernet-transport.hpp"
#include "ethernet-protocol.hpp"
#include "common/global.hpp"
#include <pcap/pcap.h>
#include <boost/asio/defer.hpp>
#include <boost/endian/conversion.hpp>
namespace nfd::face {
NFD_LOG_INIT(EthernetTransport);
EthernetTransport::EthernetTransport(const ndn::net::NetworkInterface& localEndpoint,
const ethernet::Address& remoteEndpoint)
: m_socket(getGlobalIoService())
, m_pcap(localEndpoint.getName())
, m_srcAddress(localEndpoint.getEthernetAddress())
, m_destAddress(remoteEndpoint)
, m_interfaceName(localEndpoint.getName())
, m_hasRecentlyReceived(false)
#ifdef _DEBUG
, m_nDropped(0)
#endif
{
try {
m_pcap.activate(DLT_EN10MB);
m_socket.assign(m_pcap.getFd());
}
catch (const PcapHelper::Error& e) {
NDN_THROW_NESTED(Error(e.what()));
}
// Set initial transport state based upon the state of the underlying NetworkInterface
handleNetifStateChange(localEndpoint.getState());
m_netifStateChangedConn = localEndpoint.onStateChanged.connect(
[this] (ndn::net::InterfaceState, ndn::net::InterfaceState newState) {
handleNetifStateChange(newState);
});
m_netifMtuChangedConn = localEndpoint.onMtuChanged.connect(
[this] (uint32_t, uint32_t mtu) {
setMtu(mtu);
});
asyncRead();
}
void
EthernetTransport::doClose()
{
NFD_LOG_FACE_TRACE(__func__);
if (m_socket.is_open()) {
// Cancel all outstanding operations and close the socket.
// Use the non-throwing variants and ignore errors, if any.
boost::system::error_code error;
m_socket.cancel(error);
m_socket.close(error);
}
m_pcap.close();
// Ensure that the Transport stays alive at least
// until all pending handlers are dispatched
boost::asio::defer(getGlobalIoService(), [this] {
this->setState(TransportState::CLOSED);
});
}
void
EthernetTransport::handleNetifStateChange(ndn::net::InterfaceState netifState)
{
NFD_LOG_FACE_TRACE("netif is " << netifState);
if (netifState == ndn::net::InterfaceState::RUNNING) {
if (getState() == TransportState::DOWN) {
this->setState(TransportState::UP);
}
}
else if (getState() == TransportState::UP) {
this->setState(TransportState::DOWN);
}
}
void
EthernetTransport::doSend(const Block& packet)
{
NFD_LOG_FACE_TRACE(__func__);
sendPacket(packet);
}
void
EthernetTransport::sendPacket(const ndn::Block& block)
{
ndn::EncodingBuffer buffer(block);
// pad with zeroes if the payload is too short
if (block.size() < ethernet::MIN_DATA_LEN) {
static const uint8_t padding[ethernet::MIN_DATA_LEN] = {};
buffer.appendBytes(ndn::make_span(padding).subspan(block.size()));
}
// construct and prepend the ethernet header
uint16_t ethertype = boost::endian::native_to_big(ethernet::ETHERTYPE_NDN);
buffer.prependBytes({reinterpret_cast<const uint8_t*>(&ethertype), ethernet::TYPE_LEN});
buffer.prependBytes(m_srcAddress);
buffer.prependBytes(m_destAddress);
// send the frame
int sent = pcap_inject(m_pcap, buffer.data(), buffer.size());
if (sent < 0)
handleError("Send operation failed: " + m_pcap.getLastError());
else if (static_cast<size_t>(sent) < buffer.size())
handleError("Failed to send the full frame: size=" + to_string(buffer.size()) +
" sent=" + to_string(sent));
else
// print block size because we don't want to count the padding in buffer
NFD_LOG_FACE_TRACE("Successfully sent: " << block.size() << " bytes");
}
void
EthernetTransport::asyncRead()
{
m_socket.async_wait(boost::asio::posix::stream_descriptor::wait_read,
[this] (const auto& e) { this->handleRead(e); });
}
void
EthernetTransport::handleRead(const boost::system::error_code& error)
{
if (error) {
// boost::asio::error::operation_aborted must be checked first: in that case, the Transport
// may already have been destructed, therefore it's unsafe to call getState() or do logging.
if (error != boost::asio::error::operation_aborted &&
getState() != TransportState::CLOSING &&
getState() != TransportState::FAILED &&
getState() != TransportState::CLOSED) {
handleError("Receive operation failed: " + error.message());
}
return;
}
auto [pkt, readErr] = m_pcap.readNextPacket();
if (pkt.empty()) {
NFD_LOG_FACE_DEBUG("Read error: " << readErr);
}
else {
auto [eh, frameErr] = ethernet::checkFrameHeader(pkt, m_srcAddress,
m_destAddress.isMulticast() ? m_destAddress : m_srcAddress);
if (eh == nullptr) {
NFD_LOG_FACE_WARN(frameErr);
}
else {
ethernet::Address sender(eh->ether_shost);
pkt = pkt.subspan(ethernet::HDR_LEN);
receivePayload(pkt, sender);
}
}
#ifdef _DEBUG
size_t nDropped = m_pcap.getNDropped();
if (nDropped - m_nDropped > 0)
NFD_LOG_FACE_DEBUG("Detected " << nDropped - m_nDropped << " dropped frame(s)");
m_nDropped = nDropped;
#endif
asyncRead();
}
void
EthernetTransport::receivePayload(span<const uint8_t> payload, const ethernet::Address& sender)
{
NFD_LOG_FACE_TRACE("Received: " << payload.size() << " bytes from " << sender);
auto [isOk, element] = Block::fromBuffer(payload);
if (!isOk) {
NFD_LOG_FACE_WARN("Failed to parse incoming packet from " << sender);
// This packet won't extend the face lifetime
return;
}
m_hasRecentlyReceived = true;
this->receive(element, m_destAddress.isMulticast() ? sender : EndpointId{});
}
void
EthernetTransport::handleError(const std::string& errorMessage)
{
if (getPersistency() == ndn::nfd::FACE_PERSISTENCY_PERMANENT) {
NFD_LOG_FACE_DEBUG("Permanent face ignores error: " << errorMessage);
return;
}
NFD_LOG_FACE_ERROR(errorMessage);
this->setState(TransportState::FAILED);
doClose();
}
} // namespace nfd::face
+118
View File
@@ -0,0 +1,118 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_ETHERNET_TRANSPORT_HPP
#define NFD_DAEMON_FACE_ETHERNET_TRANSPORT_HPP
#include "ethernet-protocol.hpp"
#include "pcap-helper.hpp"
#include "transport.hpp"
#include <boost/asio/posix/stream_descriptor.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
/**
* @brief Base class for Ethernet-based Transports.
*/
class EthernetTransport : public Transport
{
public:
class Error : public std::runtime_error
{
public:
using std::runtime_error::runtime_error;
};
/**
* @brief Processes the payload of an incoming frame.
* @param payload Payload bytes, starting from the first byte after the Ethernet header
* @param sender Sender address
*/
void
receivePayload(span<const uint8_t> payload, const ethernet::Address& sender);
protected:
EthernetTransport(const ndn::net::NetworkInterface& localEndpoint,
const ethernet::Address& remoteEndpoint);
void
doClose() final;
bool
hasRecentlyReceived() const
{
return m_hasRecentlyReceived;
}
void
resetRecentlyReceived()
{
m_hasRecentlyReceived = false;
}
private:
void
handleNetifStateChange(ndn::net::InterfaceState netifState);
void
doSend(const Block& packet) final;
/**
* @brief Sends the specified TLV block on the network wrapped in an Ethernet frame.
*/
void
sendPacket(const ndn::Block& block);
void
asyncRead();
void
handleRead(const boost::system::error_code& error);
void
handleError(const std::string& errorMessage);
protected:
boost::asio::posix::stream_descriptor m_socket;
PcapHelper m_pcap;
ethernet::Address m_srcAddress;
ethernet::Address m_destAddress;
std::string m_interfaceName;
private:
signal::ScopedConnection m_netifStateChangedConn;
signal::ScopedConnection m_netifMtuChangedConn;
bool m_hasRecentlyReceived;
#ifdef _DEBUG
/// number of frames dropped by the kernel, as reported by libpcap
size_t m_nDropped;
#endif
};
} // namespace nfd::face
#endif // NFD_DAEMON_FACE_ETHERNET_TRANSPORT_HPP
+159
View File
@@ -0,0 +1,159 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_FACE_COMMON_HPP
#define NFD_DAEMON_FACE_FACE_COMMON_HPP
#include "ethernet-protocol.hpp"
#include "udp-protocol.hpp"
#include "common/logger.hpp"
#include <ndn-cxx/encoding/nfd-constants.hpp>
#include <boost/logic/tribool.hpp>
#include <variant>
namespace nfd {
namespace face {
class Face;
class LinkService;
/**
* \brief Identifies a face.
*/
using FaceId = uint64_t;
/// Indicates an invalid FaceId
inline constexpr FaceId INVALID_FACEID = ndn::nfd::INVALID_FACE_ID;
/// Identifies the InternalFace used in management
inline constexpr FaceId FACEID_INTERNAL_FACE = 1;
/// Identifies a packet comes from the ContentStore
inline constexpr FaceId FACEID_CONTENT_STORE = 254;
/// Identifies the NullFace that drops every packet
inline constexpr FaceId FACEID_NULL = 255;
/// Upper bound of reserved FaceIds
inline constexpr FaceId FACEID_RESERVED_MAX = 255;
/**
* \brief Minimum MTU that may be set.
*
* This is done to ensure the NDNLPv2 fragmentation feature functions properly.
*/
inline constexpr ssize_t MIN_MTU = 64;
/**
* \brief Identifies a remote endpoint on the link.
*
* This ID is only meaningful in the context of the same Transport.
* Incoming packets from the same remote endpoint have the same EndpointId,
* and incoming packets from different remote endpoints have different EndpointIds.
*
* Typically, a point-to-point Transport has only one meaningful EndpointId,
* represented by `std::monostate`.
*/
using EndpointId = std::variant<std::monostate, ethernet::Address, udp::Endpoint>;
/** \brief Parameters used to set Transport properties or LinkService options on a newly created face.
*
* Parameters are passed as a struct rather than individually, so that a future change in the list
* of parameters does not require an update to the method signature in all subclasses.
*/
struct FaceParams
{
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
std::optional<time::nanoseconds> baseCongestionMarkingInterval;
std::optional<uint64_t> defaultCongestionThreshold;
std::optional<ssize_t> mtu;
bool wantLocalFields = false;
bool wantLpReliability = false;
boost::logic::tribool wantCongestionMarking = boost::logic::indeterminate;
};
/** \brief For internal use by FaceLogging macros.
*
* FaceLogHelper wraps a reference to Face, LinkService, or Transport object.
*
* `std::ostream& operator<<(std::ostream& os, const FaceLogHelper<T>& flh)`
* should be specialized to print "[id=888,local=scheme://local/uri,remote=scheme://remote/uri] "
* which will appear as part of the log message.
*/
template<typename T>
class FaceLogHelper
{
public:
explicit
FaceLogHelper(const T& obj1) noexcept
: obj(obj1)
{
}
public:
const T& obj;
};
} // namespace face
using face::EndpointId;
using face::FaceId;
} // namespace nfd
/** \defgroup FaceLogging Face logging macros
*
* These macros augment the log message with some face-specific information,
* such as the face ID, that are useful to distinguish which face produced the
* message. It is strongly recommended to use these macros instead of the
* generic ones for all logging inside Face, LinkService, Transport subclasses.
* @{
*/
/** \cond */
// implementation detail
#define NFD_LOG_FACE(level, msg) NFD_LOG_##level( \
::nfd::face::FaceLogHelper< \
std::remove_cv_t<std::remove_reference_t<decltype(*this)>> \
>(*this) \
<< msg)
/** \endcond */
/** \brief Log a message at TRACE level */
#define NFD_LOG_FACE_TRACE(msg) NFD_LOG_FACE(TRACE, msg)
/** \brief Log a message at DEBUG level */
#define NFD_LOG_FACE_DEBUG(msg) NFD_LOG_FACE(DEBUG, msg)
/** \brief Log a message at INFO level */
#define NFD_LOG_FACE_INFO(msg) NFD_LOG_FACE(INFO, msg)
/** \brief Log a message at WARN level */
#define NFD_LOG_FACE_WARN(msg) NFD_LOG_FACE(WARN, msg)
/** \brief Log a message at ERROR level */
#define NFD_LOG_FACE_ERROR(msg) NFD_LOG_FACE(ERROR, msg)
/** @} */
#endif // NFD_DAEMON_FACE_FACE_COMMON_HPP
+48
View File
@@ -0,0 +1,48 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "face-counters.hpp"
namespace nfd::face {
FaceCounters::FaceCounters(const LinkService::Counters& linkServiceCounters,
const Transport::Counters& transportCounters)
: nInInterests(linkServiceCounters.nInInterests)
, nOutInterests(linkServiceCounters.nOutInterests)
, nInterestsExceededRetx(linkServiceCounters.nInterestsExceededRetx)
, nInData(linkServiceCounters.nInData)
, nOutData(linkServiceCounters.nOutData)
, nInNacks(linkServiceCounters.nInNacks)
, nOutNacks(linkServiceCounters.nOutNacks)
, nInPackets(transportCounters.nInPackets)
, nOutPackets(transportCounters.nOutPackets)
, nInBytes(transportCounters.nInBytes)
, nOutBytes(transportCounters.nOutBytes)
, m_linkServiceCounters(linkServiceCounters)
, m_transportCounters(transportCounters)
{
}
} // namespace nfd::face
+63 -216
View File
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -26,226 +26,73 @@
#ifndef NFD_DAEMON_FACE_FACE_COUNTERS_HPP
#define NFD_DAEMON_FACE_FACE_COUNTERS_HPP
#include "common.hpp"
#include "link-service.hpp"
#include "transport.hpp"
namespace nfd {
namespace nfd::face {
/** \brief represents a counter of number of packets
/** \brief Gives access to counters provided by Face.
*
* This type is a facade that exposes common counters of a Face.
*
* get<T>() can be used to access extended counters provided by
* LinkService or Transport of the Face.
*/
// PacketCounter is noncopyable, because increment should be called on the counter,
// not a copy of it; it's implicitly convertible to uint64_t to be observed
class PacketCounter : noncopyable
class FaceCounters
{
public:
typedef uint64_t rep;
FaceCounters(const LinkService::Counters& linkServiceCounters,
const Transport::Counters& transportCounters);
PacketCounter()
: m_value(0)
{
}
operator rep() const
{
return m_value;
}
PacketCounter&
operator++()
{
++m_value;
return *this;
}
// postfix ++ operator is not provided because it's not needed
void
set(rep value)
{
m_value = value;
}
private:
rep m_value;
};
/** \brief represents a counter of number of bytes
*/
// ByteCounter is noncopyable, because increment should be called on the counter,
// not a copy of it; it's implicitly convertible to uint64_t to be observed
class ByteCounter : noncopyable
{
public:
typedef uint64_t rep;
ByteCounter()
: m_value(0)
{
}
operator rep() const
{
return m_value;
}
ByteCounter&
operator+=(rep n)
{
m_value += n;
return *this;
}
void
set(rep value)
{
m_value = value;
}
private:
rep m_value;
};
/** \brief contains network layer packet counters
*/
class NetworkLayerCounters : noncopyable
{
public:
/// incoming Interest
const PacketCounter&
getNInInterests() const
{
return m_nInInterests;
}
PacketCounter&
getNInInterests()
{
return m_nInInterests;
}
/// incoming Data
const PacketCounter&
getNInDatas() const
{
return m_nInDatas;
}
PacketCounter&
getNInDatas()
{
return m_nInDatas;
}
/// outgoing Interest
const PacketCounter&
getNOutInterests() const
{
return m_nOutInterests;
}
PacketCounter&
getNOutInterests()
{
return m_nOutInterests;
}
/// outgoing Data
const PacketCounter&
getNOutDatas() const
{
return m_nOutDatas;
}
PacketCounter&
getNOutDatas()
{
return m_nOutDatas;
}
protected:
/** \brief copy current obseverations to a struct
* \param recipient an object with set methods for counters
/** \return counters provided by LinkService
* \tparam T LinkService counters type
* \throw std::bad_cast counters type mismatch
*/
template<typename R>
void
copyTo(R& recipient) const
template<typename T>
std::enable_if_t<std::is_base_of_v<LinkService::Counters, T>, const T&>
get() const
{
recipient.setNInInterests(this->getNInInterests());
recipient.setNInDatas(this->getNInDatas());
recipient.setNOutInterests(this->getNOutInterests());
recipient.setNOutDatas(this->getNOutDatas());
return dynamic_cast<const T&>(m_linkServiceCounters);
}
/** \return counters provided by Transport
* \tparam T Transport counters type
* \throw std::bad_cast counters type mismatch
*/
template<typename T>
std::enable_if_t<std::is_base_of_v<Transport::Counters, T>, const T&>
get() const
{
return dynamic_cast<const T&>(m_transportCounters);
}
public:
const PacketCounter& nInInterests;
const PacketCounter& nOutInterests;
const PacketCounter& nInterestsExceededRetx;
const PacketCounter& nInData;
const PacketCounter& nOutData;
const PacketCounter& nInNacks;
const PacketCounter& nOutNacks;
const PacketCounter& nInPackets;
const PacketCounter& nOutPackets;
const ByteCounter& nInBytes;
const ByteCounter& nOutBytes;
/** \brief Count of incoming Interests dropped due to HopLimit == 0.
*/
PacketCounter nInHopLimitZero;
/** \brief Count of outgoing Interests dropped due to HopLimit == 0 on non-local faces.
*/
PacketCounter nOutHopLimitZero;
private:
PacketCounter m_nInInterests;
PacketCounter m_nInDatas;
PacketCounter m_nOutInterests;
PacketCounter m_nOutDatas;
const LinkService::Counters& m_linkServiceCounters;
const Transport::Counters& m_transportCounters;
};
/** \brief contains link layer byte counters
*/
class LinkLayerCounters : noncopyable
{
public:
/// received bytes
const ByteCounter&
getNInBytes() const
{
return m_nInBytes;
}
ByteCounter&
getNInBytes()
{
return m_nInBytes;
}
/// sent bytes
const ByteCounter&
getNOutBytes() const
{
return m_nOutBytes;
}
ByteCounter&
getNOutBytes()
{
return m_nOutBytes;
}
protected:
/** \brief copy current obseverations to a struct
* \param recipient an object with set methods for counters
*/
template<typename R>
void
copyTo(R& recipient) const
{
recipient.setNInBytes(this->getNInBytes());
recipient.setNOutBytes(this->getNOutBytes());
}
private:
ByteCounter m_nInBytes;
ByteCounter m_nOutBytes;
};
/** \brief contains counters on face
*/
class FaceCounters : public NetworkLayerCounters, public LinkLayerCounters
{
public:
/** \brief copy current obseverations to a struct
* \param recipient an object with set methods for counters
*/
template<typename R>
void
copyTo(R& recipient) const
{
this->NetworkLayerCounters::copyTo(recipient);
this->LinkLayerCounters::copyTo(recipient);
}
};
} // namespace nfd
} // namespace nfd::face
#endif // NFD_DAEMON_FACE_FACE_COUNTERS_HPP
+53
View File
@@ -0,0 +1,53 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "face-endpoint.hpp"
#include <boost/hana/functional/overload.hpp>
namespace nfd {
FaceEndpoint::FaceEndpoint(Face& face, const EndpointId& endpoint)
: face(face)
, endpoint(endpoint)
{
}
void
FaceEndpoint::print(std::ostream& os) const
{
std::visit(boost::hana::overload(
[&] (std::monostate) {
os << face.getId();
},
[&] (const ethernet::Address& ep) {
os << '(' << face.getId() << ", " << ep << ')';
},
[&] (const udp::Endpoint& ep) {
os << '(' << face.getId() << ", " << ep << ')';
}), endpoint);
}
} // namespace nfd
+61
View File
@@ -0,0 +1,61 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_FACE_ENDPOINT_HPP
#define NFD_DAEMON_FACE_FACE_ENDPOINT_HPP
#include "face.hpp"
namespace nfd {
/**
* \brief Represents a face-endpoint pair in the forwarder.
* \sa face::Face, face::EndpointId
*/
class FaceEndpoint
{
public:
explicit
FaceEndpoint(Face& face, const EndpointId& endpoint = {});
private:
void
print(std::ostream& os) const;
friend std::ostream&
operator<<(std::ostream& os, const FaceEndpoint& fe)
{
fe.print(os);
return os;
}
public:
Face& face;
const EndpointId endpoint;
};
} // namespace nfd
#endif // NFD_DAEMON_FACE_FACE_ENDPOINT_HPP
-48
View File
@@ -1,48 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NFD_DAEMON_MGMT_FACE_FLAGS_HPP
#define NFD_DAEMON_MGMT_FACE_FLAGS_HPP
#include "face/face.hpp"
#include <ndn-cxx/management/nfd-face-flags.hpp>
namespace nfd {
inline uint64_t
getFaceFlags(const Face& face)
{
uint64_t flags = 0;
if (face.isLocal()) {
flags |= ndn::nfd::FACE_IS_LOCAL;
}
if (face.isOnDemand()) {
flags |= ndn::nfd::FACE_IS_ON_DEMAND;
}
return flags;
}
} // namespace nfd
#endif // NFD_DAEMON_MGMT_FACE_FLAGS_HPP
+164
View File
@@ -0,0 +1,164 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "face-system.hpp"
#include "netdev-bound.hpp"
#include "protocol-factory.hpp"
#include "fw/face-table.hpp"
namespace nfd::face {
NFD_LOG_INIT(FaceSystem);
const std::string CFGSEC_FACESYSTEM = "face_system";
const std::string CFGSEC_GENERAL = "general";
const std::string CFGSEC_GENERAL_FQ = CFGSEC_FACESYSTEM + ".general";
const std::string CFGSEC_NETDEVBOUND = "netdev_bound";
FaceSystem::FaceSystem(FaceTable& faceTable, shared_ptr<ndn::net::NetworkMonitor> netmon)
: m_faceTable(faceTable)
, m_netmon(std::move(netmon))
{
auto pfCtorParams = this->makePFCtorParams();
for (const auto& id : ProtocolFactory::listRegistered()) {
NFD_LOG_TRACE("creating factory " << id);
m_factories[id] = ProtocolFactory::create(id, pfCtorParams);
}
m_netdevBound = make_unique<NetdevBound>(pfCtorParams, *this);
}
ProtocolFactoryCtorParams
FaceSystem::makePFCtorParams()
{
auto addFace = [this] (auto face) { m_faceTable.add(std::move(face)); };
return {addFace, m_netmon};
}
FaceSystem::~FaceSystem() = default;
std::set<const ProtocolFactory*>
FaceSystem::listProtocolFactories() const
{
std::set<const ProtocolFactory*> factories;
for (const auto& p : m_factories) {
factories.insert(p.second.get());
}
return factories;
}
ProtocolFactory*
FaceSystem::getFactoryById(const std::string& id) const
{
auto found = m_factories.find(id);
return found == m_factories.end() ? nullptr : found->second.get();
}
ProtocolFactory*
FaceSystem::getFactoryByScheme(const std::string& scheme) const
{
auto found = m_factoryByScheme.find(scheme);
return found == m_factoryByScheme.end() ? nullptr : found->second;
}
bool
FaceSystem::hasFactoryForScheme(const std::string& scheme) const
{
return m_factoryByScheme.count(scheme) > 0;
}
void
FaceSystem::setConfigFile(ConfigFile& configFile)
{
configFile.addSectionHandler(CFGSEC_FACESYSTEM, [this] (auto&&... args) {
processConfig(std::forward<decltype(args)>(args)...);
});
}
void
FaceSystem::processConfig(const ConfigSection& configSection, bool isDryRun, const std::string&)
{
ConfigContext context;
context.isDryRun = isDryRun;
// process general protocol factory config section
auto generalSection = configSection.get_child_optional(CFGSEC_GENERAL);
if (generalSection) {
for (const auto& pair : *generalSection) {
const std::string& key = pair.first;
if (key == "enable_congestion_marking") {
context.generalConfig.wantCongestionMarking = ConfigFile::parseYesNo(pair, CFGSEC_GENERAL_FQ);
}
else {
NDN_THROW(ConfigFile::Error("Unrecognized option " + CFGSEC_GENERAL_FQ + "." + key));
}
}
}
// process in protocol factories
for (const auto& [sectionName, factory] : m_factories) {
std::set<std::string> oldProvidedSchemes = factory->getProvidedSchemes();
factory->processConfig(configSection.get_child_optional(sectionName), context);
if (!isDryRun) {
for (const auto& scheme : factory->getProvidedSchemes()) {
m_factoryByScheme[scheme] = factory.get();
if (oldProvidedSchemes.erase(scheme) == 0) {
NFD_LOG_TRACE("factory " << sectionName <<
" provides " << scheme << " FaceUri scheme");
}
}
for (const auto& scheme : oldProvidedSchemes) {
m_factoryByScheme.erase(scheme);
NFD_LOG_TRACE("factory " << sectionName <<
" no longer provides " << scheme << " FaceUri scheme");
}
}
}
// process netdev_bound section, after factories start providing *+dev schemes
auto netdevBoundSection = configSection.get_child_optional(CFGSEC_NETDEVBOUND);
m_netdevBound->processConfig(netdevBoundSection, context);
// process other sections
std::set<std::string> seenSections;
for (const auto& pair : configSection) {
const std::string& sectionName = pair.first;
// const ConfigSection& subSection = pair.second;
if (!seenSections.insert(sectionName).second) {
NDN_THROW(ConfigFile::Error("Duplicate section " + CFGSEC_FACESYSTEM + "." + sectionName));
}
if (sectionName == CFGSEC_GENERAL || sectionName == CFGSEC_NETDEVBOUND ||
m_factories.count(sectionName) > 0) {
continue;
}
NDN_THROW(ConfigFile::Error("Unrecognized option " + CFGSEC_FACESYSTEM + "." + sectionName));
}
}
} // namespace nfd::face
+138
View File
@@ -0,0 +1,138 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FACE_FACE_SYSTEM_HPP
#define NFD_DAEMON_FACE_FACE_SYSTEM_HPP
#include "common/config-file.hpp"
#include <ndn-cxx/net/network-address.hpp>
#include <ndn-cxx/net/network-interface.hpp>
#include <ndn-cxx/net/network-monitor.hpp>
namespace nfd {
class FaceTable;
namespace face {
class NetdevBound;
class ProtocolFactory;
struct ProtocolFactoryCtorParams;
/**
* \brief Entry point of NFD's face system.
*
* NFD's face system is organized as a FaceSystem-ProtocolFactory-Channel-Face hierarchy.
* The FaceSystem class is the entry point of the face system and owns all ProtocolFactory objects.
*/
class FaceSystem : noncopyable
{
public:
FaceSystem(FaceTable& faceTable, shared_ptr<ndn::net::NetworkMonitor> netmon);
~FaceSystem();
/**
* \brief Returns all ProtocolFactory objects owned by the face system.
*/
[[nodiscard]] std::set<const ProtocolFactory*>
listProtocolFactories() const;
/**
* \return ProtocolFactory for the specified registered factory id or nullptr if not found.
*/
ProtocolFactory*
getFactoryById(const std::string& id) const;
/**
* \return ProtocolFactory for the specified FaceUri scheme or nullptr if not found.
*/
ProtocolFactory*
getFactoryByScheme(const std::string& scheme) const;
bool
hasFactoryForScheme(const std::string& scheme) const;
FaceTable&
getFaceTable()
{
return m_faceTable;
}
/** \brief Register handler for the `face_system` section of NFD's configuration file.
*/
void
setConfigFile(ConfigFile& configFile);
/** \brief Configuration options from `general` section.
*/
struct GeneralConfig
{
bool wantCongestionMarking = true;
};
/** \brief Context for processing a config section in ProtocolFactory.
*/
class ConfigContext : noncopyable
{
public:
GeneralConfig generalConfig;
bool isDryRun;
};
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
ProtocolFactoryCtorParams
makePFCtorParams();
private:
void
processConfig(const ConfigSection& configSection, bool isDryRun,
const std::string& filename);
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/** \brief Config section name => protocol factory.
*/
std::map<std::string, unique_ptr<ProtocolFactory>> m_factories;
unique_ptr<NetdevBound> m_netdevBound;
private:
/** \brief Scheme => protocol factory.
*
* The same protocol factory may be available under multiple schemes.
*/
std::map<std::string, ProtocolFactory*> m_factoryByScheme;
FaceTable& m_faceTable;
shared_ptr<ndn::net::NetworkMonitor> m_netmon;
};
} // namespace face
using face::FaceSystem;
} // namespace nfd
#endif // NFD_DAEMON_FACE_FACE_SYSTEM_HPP
Loaded 100 of 777 files, more files were not shown because too many files have changed in this diff. Show more