nfd + ndn-cxx: New ports
Change-Id: I7ea6eba5828fca96409117debdcb8a0af87e5ff4
diff --git a/net/nfd/Portfile b/net/nfd/Portfile
new file mode 100644
index 0000000..a893ec5
--- /dev/null
+++ b/net/nfd/Portfile
@@ -0,0 +1,136 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id$
+
+PortSystem 1.0
+PortGroup github 1.0
+
+github.setup named-data NFD b47d53842a6ea8d32800459270a667952d4079bf
+checksums rmd160 b4c9d6217791642ee6438172be07356554ab2efd \
+ sha256 8c40c6e96266e064455c2ca6b0b87eedd2bfed10511edcba9940facb6131802a
+
+name nfd
+homepage http://named-data.net/doc/NFD/
+license GPL3+
+version 0.1.0-rc1.1
+
+categories net
+platforms darwin
+maintainers ucla.edu:alexander.afanasyev
+
+description Named Data Networking Forwarding Daemon
+
+long_description \
+ NFD is a network forwarder that implements and evolves together with the \
+ Named Data Networking (NDN) protocol. 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 protocol features, algorithms, new \
+ applications. We have not fully optimized the code for \
+ performance. The intention is that performance optimizations are one \
+ type of experiments that developers can conduct by trying out \
+ different data structures and different algorithms\; over time, better \
+ implementations may emerge within the same design framework.
+
+depends_lib-append port:ndn-cxx \
+ port:libpcap
+
+depends_build-append port:pkgconfig \
+ port:py27-sphinx
+
+use_configure yes
+
+configure.env-append SPHINX_BUILD=${prefix}/bin/sphinx-build-2.7
+configure.cmd ./waf configure
+
+build.cmd ./waf
+build.target build
+
+destroot.cmd ./waf
+destroot.target install
+destroot.destdir --destdir=${destroot}
+
+set ndn_user ndn
+set ndn_group ndn
+
+add_users ${ndn_user} shell=/bin/sh group=${ndn_group} \
+ realname=NDN\ User
+
+post-destroot {
+ # Install plists
+ xinstall -m 755 -d ${destroot}${prefix}/etc/LaunchDaemons/net.named-data.nfd/
+ xinstall -m 755 ${filespath}/net.named-data.nfd.plist \
+ ${destroot}${prefix}/etc/LaunchDaemons/net.named-data.nfd/
+ xinstall -m 755 ${filespath}/net.named-data.nrd.plist \
+ ${destroot}${prefix}/etc/LaunchDaemons/net.named-data.nfd/
+
+ reinplace "s|/usr/local|${prefix}|g" \
+ ${destroot}${prefix}/etc/LaunchDaemons/net.named-data.nfd/net.named-data.nfd.plist
+ reinplace "s|/usr/local|${prefix}|g" \
+ ${destroot}${prefix}/etc/LaunchDaemons/net.named-data.nfd/net.named-data.nrd.plist
+
+ # Install replacement for nfd-start/stop scripts
+ xinstall -m 755 ${filespath}/nfd-start "${destroot}${prefix}/bin/"
+ xinstall -m 755 ${filespath}/nfd-stop "${destroot}${prefix}/bin/"
+}
+
+post-activate {
+
+ # Create log dir
+ xinstall -m 755 -d -o ${ndn_user} -g ${ndn_group} \
+ ${prefix}/var/log/ndn
+
+ system "cd /Library/LaunchDaemons && sudo ln -sf \
+ ${prefix}/etc/LaunchDaemons/net.named-data.nfd/net.named-data.nfd.plist"
+ system "cd /Library/LaunchDaemons && sudo ln -sf \
+ ${prefix}/etc/LaunchDaemons/net.named-data.nfd/net.named-data.nrd.plist"
+
+ if {![file exists ${prefix}/etc/ndn/nfd.conf]} {
+
+ file copy ${prefix}/etc/ndn/nfd.conf.sample \
+ ${prefix}/etc/ndn/nfd.conf
+
+ # Generate self-signed NDN certificate for nfd (owned by root)
+ xinstall -m 755 -d ${prefix}/var/lib/ndn/nfd/.ndn
+ system "echo tpm=file > ${prefix}/var/lib/ndn/nfd/.ndn/client.conf"
+ system "HOME=${prefix}/var/lib/ndn/nfd ndnsec-keygen /localhost/daemons/nfd | \
+ HOME=${prefix}/var/lib/ndn/nfd ndnsec-install-cert -"
+
+ # Generate self-signed NDN certificate for nrd (owned by ndn)
+ xinstall -m 755 -d -o ${ndn_user} -g ${ndn_group} ${prefix}/var/lib/ndn/nrd/.ndn
+ system "sudo -u ${ndn_user} -g ${ndn_group} sh -c 'echo tpm=file \
+ > ${prefix}/var/lib/ndn/nrd/.ndn/client.conf'"
+ system "sudo -u ${ndn_user} -g ${ndn_group} HOME=${prefix}/var/lib/ndn/nrd \
+ ndnsec-keygen /localhost/daemons/nrd | \
+ sudo -u ${ndn_user} -g ndn HOME=${prefix}/var/lib/ndn/nrd ndnsec-install-cert -"
+
+ # Dump RIB Management daemon's certificate
+ xinstall -m 755 -d ${prefix}/etc/ndn/certs
+ system "sudo sh -c 'sudo -u ${ndn_user} -g ${ndn_group} HOME=${prefix}/var/lib/ndn/nrd \
+ ndnsec-dump-certificate -i /localhost/daemons/nrd \
+ > ${prefix}/etc/ndn/certs/localhost_daemons_nrd.ndncert'"
+
+ }
+}
+
+pre-deactivate {
+ system "${prefix}/bin/nfd-stop"
+
+ system "rm ${prefix}/etc/LaunchDaemons/net.named-data.nfd/net.named-data.nfd.plist"
+ system "rm ${prefix}/etc/LaunchDaemons/net.named-data.nfd/net.named-data.nrd.plist"
+}
+
+notes "
+
+To start NFD and ensure it is started when system boots:
+
+ nfd-start
+
+To stop NFD and disable auto-start when system boots:
+
+ nfd-stop
+
+NFD log files are located in ${prefix}/var/log/ndn/
+
+Configuration file is in ${prefix}/var/etc/ndn/
+
+"
diff --git a/net/nfd/files/net.named-data.nfd.plist b/net/nfd/files/net.named-data.nfd.plist
new file mode 100644
index 0000000..a8da970
--- /dev/null
+++ b/net/nfd/files/net.named-data.nfd.plist
@@ -0,0 +1,23 @@
+<?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.nfd</string>
+<key>ProgramArguments</key>
+<array>
+ <string>/usr/local/bin/nfd</string>
+ <string>--config</string>
+ <string>/usr/local/etc/ndn/nfd.conf</string>
+</array>
+<key>EnvironmentVariables</key>
+<dict>
+ <key>HOME</key><string>/usr/local/var/lib/ndn/nfd</string>
+</dict>
+<key>Debug</key><true/>
+<key>Disabled</key><true/>
+<key>KeepAlive</key><true/>
+<key>StandardErrorPath</key><string>/usr/local/var/log/ndn/nfd.log</string>
+<key>ProcessType</key><string>Background</string>
+</dict>
+</plist>
diff --git a/net/nfd/files/net.named-data.nrd.plist b/net/nfd/files/net.named-data.nrd.plist
new file mode 100644
index 0000000..3cd7aaa
--- /dev/null
+++ b/net/nfd/files/net.named-data.nrd.plist
@@ -0,0 +1,25 @@
+<?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>
diff --git a/net/nfd/files/nfd-start b/net/nfd/files/nfd-start
new file mode 100755
index 0000000..af1853f
--- /dev/null
+++ b/net/nfd/files/nfd-start
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+sudo launchctl load -w /Library/LaunchDaemons/net.named-data.nfd.plist
+sudo launchctl load -w /Library/LaunchDaemons/net.named-data.nrd.plist
diff --git a/net/nfd/files/nfd-stop b/net/nfd/files/nfd-stop
new file mode 100755
index 0000000..2d64e9f
--- /dev/null
+++ b/net/nfd/files/nfd-stop
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+sudo launchctl unload -w /Library/LaunchDaemons/net.named-data.nfd.plist
+sudo launchctl unload -w /Library/LaunchDaemons/net.named-data.nrd.plist
diff --git a/net/nfd/files/nfd.conf.sample b/net/nfd/files/nfd.conf.sample
new file mode 100644
index 0000000..05f0316
--- /dev/null
+++ b/net/nfd/files/nfd.conf.sample
@@ -0,0 +1,195 @@
+; The general section contains settings of nfd process.
+; general
+; {
+; }
+
+log
+{
+ ; default_level specifies the logging level for modules
+ ; that are not explicitly named. All debugging levels
+ ; listed above the selected value are enabled.
+ ;
+ ; Valid values:
+ ;
+ ; NONE ; no messages
+ ; ERROR ; error messages
+ ; WARN ; warning messages
+ ; INFO ; informational messages (default)
+ ; DEBUG ; debugging messages
+ ; TRACE ; trace messages (most verbose)
+ ; ALL ; all messages
+
+ default_level INFO
+
+ ; You may override default_level by assigning a logging level
+ ; to the desired module name. Module names can be found in two ways:
+ ;
+ ; Run:
+ ; nfd --modules
+ ; nrd --modules
+ ;
+ ; Or look for NFD_LOG_INIT(<module name>) statements in .cpp files
+ ;
+ ; Example module-level settings:
+ ;
+ ; FibManager DEBUG
+ ; Forwarder INFO
+}
+
+; The face_system section defines what faces and channels are created.
+face_system
+{
+ ; The unix section contains settings of UNIX stream faces and channels.
+ unix
+ {
+ listen yes ; set to 'no' to disable UNIX stream listener, default 'yes'
+ path /var/run/nfd.sock ; UNIX stream listener path
+ }
+
+ ; The tcp section contains settings of TCP faces and channels.
+ tcp
+ {
+ listen yes ; set to 'no' to disable TCP listener, default 'yes'
+ port 6363 ; TCP listener port number
+ enable_v4 yes ; set to 'no' to disable IPv4 channels, default 'yes'
+ enable_v6 yes ; set to 'no' to disable IPv6 channels, default 'yes'
+ }
+
+ ; The udp section contains settings of UDP faces and channels.
+ ; UDP channel is always listening; delete udp section to disable UDP
+ udp
+ {
+ port 6363 ; UDP unicast port number
+ enable_v4 yes ; set to 'no' to disable IPv4 channels, default 'yes'
+ enable_v6 yes ; set to 'no' to disable IPv6 channels, default 'yes'
+ idle_timeout 600 ; idle time (seconds) before closing a UDP unicast face
+ keep_alive_interval 25; interval (seconds) between keep-alive refreshes
+
+ ; UDP multicast settings
+ ; NFD creates one UDP multicast face per NIC
+ mcast yes ; set to 'no' to disable UDP multicast, default 'yes'
+ mcast_port 56363 ; UDP multicast port number
+ mcast_group 224.0.23.170 ; UDP multicast group (IPv4 only)
+ }
+
+ ; The ether section contains settings of Ethernet faces and channels.
+ ether
+ {
+ ; Ethernet multicast settings
+ ; NFD creates one Ethernet multicast face per NIC
+ mcast yes ; set to 'no' to disable Ethernet multicast, default 'yes'
+ mcast_group 01:00:5E:00:17:AA ; Ethernet multicast group
+ }
+}
+
+authorizations
+{
+ authorize
+ {
+ certfile certs/localhost_daemons_nrd.ndncert
+ privileges
+ {
+ faces
+ fib
+ strategy-choice
+ }
+ }
+
+ authorize
+ {
+ certfile any
+ privileges
+ {
+ faces
+ strategy-choice
+ }
+ }
+}
+
+rib
+{
+ ; The following localhost_security allows anyone to register routing entries in local RIB
+ localhost_security
+ {
+ trust-anchor
+ {
+ type any
+ }
+ }
+
+ ; localhop_security should be enabled when NFD runs on a hub.
+ ; "/localhop/nfd/fib" command prefix will be disabled when localhop_security section is missing.
+ ; localhop_security
+ ; {
+ ; ; This section defines the trust model for NFD RIB Management. It consists of rules and
+ ; ; trust-anchors, which are briefly defined in this file. For more information refer to
+ ; ; manpage of ndn-validator.conf:
+ ; ;
+ ; ; man ndn-validator.conf
+ ; ;
+ ; ; A trust-anchor is a pre-trusted certificate. This can be any certificate that is the
+ ; ; root of certification chain (e.g., NDN testbed root certificate) or an existing
+ ; ; default system certificate `default.ndncert`.
+ ; ;
+ ; ; A rule defines conditions a valid packet MUST have. A packet must satisfy one of the
+ ; ; rules defined here. A rule can be broken into two parts: matching & checking. A packet
+ ; ; will be matched against rules from the first to the last until a matched rule is
+ ; ; encountered. The matched rule will be used to check the packet. If a packet does not
+ ; ; match any rule, it will be treated as invalid. The matching part of a rule consists
+ ; ; of `for` and `filter` sections. They collectively define which packets can be checked
+ ; ; with this rule. `for` defines packet type (data or interest) and `filter` defines
+ ; ; conditions on other properties of a packet. Right now, you can only define conditions
+ ; ; on packet name, and you can only specify ONLY ONE filter for packet name. The
+ ; ; checking part of a rule consists of `checker`, which defines the conditions that a
+ ; ; VALID packet MUST have. See comments in checker section for more details.
+ ;
+ ; rule
+ ; {
+ ; id "NRD Prefix Registration Command Rule"
+ ; for interest ; rule for Interests (to validate CommandInterests)
+ ; filter
+ ; {
+ ; type name ; condition on interest name (w/o signature)
+ ; regex ^[<localhop><localhost>]<nfd><rib>[<register><unregister>]<>{3}$
+ ; }
+ ; checker
+ ; {
+ ; type customized
+ ; sig-type rsa-sha256 ; interest must have a rsa-sha256 signature
+ ; key-locator
+ ; {
+ ; type name ; key locator must be the certificate name of the
+ ; ; signing key
+ ; regex ^[^<KEY>]*<KEY><>*<ksk-.*><ID-CERT>$
+ ; }
+ ; }
+ ; }
+ ; rule
+ ; {
+ ; id "NDN Testbed Hierarchy Rule"
+ ; for data ; rule for Data (to validate NDN certificates)
+ ; filter
+ ; {
+ ; type name ; condition on data name
+ ; regex ^[^<KEY>]*<KEY><>*<ksk-.*><ID-CERT><>$
+ ; }
+ ; checker
+ ; {
+ ; type hierarchical ; the certificate name of the signing key and
+ ; ; the data name must follow the hierarchical model
+ ; sig-type rsa-sha256 ; data must have a rsa-sha256 signature
+ ; }
+ ; }
+ ; trust-anchor
+ ; {
+ ; type file
+ ; file-name keys/default.ndncert ; the file name, by default this file should be placed in the
+ ; ; same folder as this config file.
+ ; }
+ ; ; trust-anchor ; Can be repeated multiple times to specify multiple trust anchors
+ ; ; {
+ ; ; type file
+ ; ; file-name keys/ndn-testbed.ndncert
+ ; ; }
+ ; }
+}