((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/tun" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "tun" (toc) (section 3 "Description" (p "A library to create Linux TUN/TAP interfaces")) (section 3 "Current status" (p "The library currently allows the opening of a TUN/TAP interface in either TUN or TAP mode and keeps track of the interface name and its file descriptor. It provides two utility functions tun-up! and tun-mac which bring the interface up and return the interface MAC address respectively.") (p "Note: the library assumes the presence of the \"/dev/net/tun\" device file. See https://www.kernel.org/doc/Documentation/networking/tuntap.txt.")) (section 3 "Author" (p "Omar Shorbaji")) (section 3 "Requirements" (p "defstruct lolevel socket")) (section 3 "API " (def (sig (procedure " (make-tun #!optional (mode 'tun) (pi #f)) " (id make-tun))) (p "returns a tun/tap interface. The mode argument can be 'tun for a tunnel interface or 'tap for a tap interface. When the argument pi is #t we do not send the IFF_NO_PI flag and the interface includes packet information (four bytes) when reading every packet or frame")) (def (sig (procedure "(tun-fd tun)" (id tun-fd))) (p "returns the file descriptor associated with the tunnel interface. Writing to this file descriptor sends data out of the interface. Note that written data must be well-formed packet (for tun) or ethernet frame (for tap).")) (def (sig (procedure " (tun-name) " (id tun-name))) (p "returns the name of the TUN/TAP interface. Available after running make-tun")) (def (sig (procedure " (tun-mac tun) " (id tun-mac))) (p "returns the MAC address associated with a TUN or TAP interface as a list of 6 integers"))) (section 3 "Examples" (highlight scheme "\n(define tap (make-tun 'tap)) ; creates a TUN/TAP interface in tap mode\n\n(tun-up! tun)                ; brings interface up\n\n(print \"MAC address: \" (tun-mac tap))\n\n(use posix ethernet)\n\n(let* ((pr (file-read fd size))\n       (buf (car pr))\n       (n (cadr pr)))\n  (with-input-from-string (string-take buf n)\n     (read-ethernet-frame))) ; reads an ethernet frame from TAP interface\n  ")) (section 3 "Repository" (p (link "https://github.com/shorbaji/chicken-tun"))) (section 3 "License" (pre ";; Copyright (c) 2016, Omar Shorbaji\n;; All rights reserved.\n;; \n;; Redistribution and use in source and binary forms, with or without\n;; modification, are permitted provided that the following conditions are met:\n;; \n;; Redistributions of source code must retain the above copyright notice, this\n;; list of conditions and the following disclaimer. \n;; Redistributions in binary form must reproduce the above copyright notice,\n;; this list of conditions and the following disclaimer in the documentation\n;; and/or other materials provided with the distribution.  \n;; Neither the name of the author nor the names of its contributors may be\n;; used to endorse or promote products derived from this software without\n;; specific prior written permission.  \n;; \n;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE\n;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFcl\n;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n;; POSSIBILITY OF SUCH DAMAGE.\n")) (section 3 "Version History" (p "0.1  alpha release"))))