;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.13
;;; Reason:
;;;  When we are asked to forward a packet to a destination who's ethernet address we don't know,
;;;  we send an ARP packet -- but we shouldn't claim to be that protocol address unless the host
;;;  we are forwarding for is on our own backplane.
;;; Written 3-Sep-87 13:06:08 by pld (Peter L. DeWolf) at site LMI Cambridge
;;; while running on Azathoth from band 2
;;; with Experimental System 123.10, Experimental Local-File 73.0, Experimental FILE-Server 22.0, Experimental Unix-Interface 11.0, Experimental Tape 18.0, Experimental KERMIT 34.0, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, Experimental Site Data Editor 6.0, microcode 1754, SDU Boot Tape 3.12, SDU ROM 102.



; From modified file DJ: L.NETWORK.KERNEL; ARP.LISP#126 at 3-Sep-87 13:06:11
#10R ARP#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "ARP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; ARP  "

(defun get-address-info (address protocol ask-if-necessary interface &optional hang-p on-behalf-of)
  "Search the address-translation tables for the address info for a specific
protocol address.  ask-if-necessary determines whether ARP requests should
be generated if the info is not found.  interface optionally specifies a
particular network interface to restrict the search to"
  (declare (values address-info interface))
  (when on-behalf-of
    (dolist (stream *network-protocol-streams*)
      (when (eq protocol (net:np-keyword stream))
	(unless (processor-without-network-interface on-behalf-of (net:np-keyword stream))
	  ;;We don't masquerade as processors not on our own bus
	  (setq on-behalf-of nil)))))
  (dolist (i *network-interfaces*)
    (when (or (null interface) (eq interface i))
      (dolist (at (net:ni-address-translations i))
	(when (and (= address (net:at-protocol-address at))
		   (eq protocol (net:at-protocol at))
		   (or (net:ni-point-to-point i)
		       (null on-behalf-of)
		       (member on-behalf-of (net:at-on-behalf-of at))))
	  (return-from get-address-info (values at i))))))
  (when ask-if-necessary
    (dolist (stream *network-protocol-streams*)
      (when (eq protocol (net:np-keyword stream))
	(dolist (i *network-interfaces*)
	  (when (or (null interface) (eq interface i))
	    (send-addr-pkt address stream i nil on-behalf-of nil hang-p)))
	(return t))))
  (values nil nil))

))
