|
|
@ -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] |
|
|
|
) |
|
|
@ -117,15 +117,15 @@ |
|
|
|
# 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 |
|
|
@ -165,7 +165,7 @@ |
|
|
|
(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 |
|
|
|
))) |
|
|
|