1 ;;;; Lysiane Bouchard - Vincent St-Amour
4 (define arp-operation-request '#u8(#x00 #x01))
5 (define arp-operation-response '#u8(#x00 #x02))
6 (define arp-ethernet-type '#u8(#x00 #x01))
8 ;; called when an ARP request is received
10 (if (and (u8vector-equal-field? pkt arp-hardware-type arp-ethernet-type 0 2)
11 (u8vector-equal-field?
12 pkt arp-protocol-type ethernet-frame-type-ipv4 0 2)
13 (= (u8vector-ref pkt arp-hardware-address-length) 6)
14 (= (u8vector-ref pkt arp-protocol-address-length) 4)
15 ;; TODO we really need all these checks ? be liberal in what you accept...
16 (u8vector-equal-field? pkt arp-operation arp-operation-request 0 2)
17 (or (u8vector-equal-field? pkt arp-target-ip my-ip 0 4) ; check if we are the target
18 (u8vector-equal-field? pkt arp-target-ip broadcast-ip 0 4)) ;; TODO bug, even with a broadcast, this doesn't pass
19 ) ;; TODO should we tolerate broadcast ? goes against the spirit of ARP
22 (u8vector-copy! arp-operation-response 0 pkt arp-operation 2) ; ARP response
23 (u8vector-copy! pkt arp-source-hardware-address
24 pkt arp-target-hardware-address 6)
25 (u8vector-copy! pkt arp-source-ip pkt arp-target-ip 4)
26 (u8vector-copy! my-mac 0 pkt arp-source-hardware-address 6)
27 (u8vector-copy! my-ip 0 pkt arp-source-ip 4)
28 (ethernet-encapsulation arp-length))