debug the icmp responding
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Sat, 13 Nov 2021 11:35:48 +0000 (22:35 +1100)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Sat, 13 Nov 2021 11:35:48 +0000 (22:35 +1100)
arper.lsp

index caf763dac2db43321d48aebd7c05090edee75fa8..10ac3888b55bbb0f108301389c26ff1228dc917d 100755 (executable)
--- a/arper.lsp
+++ b/arper.lsp
@@ -1,4 +1,4 @@
-#!/usr/local/bin/newlisp
+#!/usr/bin/newlisp
 # Copyright 2017, Ralph Ronnquist <ralph.ronnquist@gmail.com>
 
 ;; This program iplements arp responding for selected IP and
@@ -28,7 +28,7 @@
 # Tell about usage and exit with error.
 (define (usage)
   (write-line 2 [text];; Usage: -t <tap> <conf>
-;; where <tap> is the tap to service, and <conf> is the pathnmae fore
+;; where <tap> is the tap to service, and <conf> is the pathname for
 ;; the configuration file.
 [/text]
    )
 # handle, and then issues a corresponding response.
 (define (icmp-request-handler)
   (letn ((h (unpack "bbbb bbbb" (26 buffer)))
-         (n (ntohs((unpack "u" (16 buffer)) 0))))
-    (println "ICMP request " (pack-ip (0 4 h)) " --> " (pack-ip (4 4 h)))
-    (when (member (4 4 h) MYIPS)
+         (n (ntohs((unpack "u" (16 buffer)) 0)))
+         (MYMAC (MAP (string (4 4 h)))) )
+    (when MYMAC
       (write IFD
              (pack-bytes
               (flat (list
                      # Ethernet header (14 bytes)
                      (unpack "bbbbbb" (6 buffer))
-                     2 (4 4 h) 2
+                     MYMAC
                      (stonb 0x0800) ; Type = IPv4
                      # IPv4 header (20 bytes, with header checksum)
                      (ipv4-header-checksum
   (when (> n 14)
     (case (ntohs ((unpack "u" (12 buffer)) 0)) ; Ethertype
       (0x0806 (and arp-handler (arp-handler)))
-      ;(0x0800 (and ipv4-handler (ipv4-handler)))
+      (0x0800 (and ipv4-handler (ipv4-handler)))
       ;(0x86DD (and ipv6-handler (ipv6-handler)))
       (true nil) ; ignore all else
       )))