;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.235
;;; Reason:
;;;  Patches for serial IP:
;;;    - Add :serial network interface to configuration list
;;;    - :send method of net:network-protocol compares addresses
;;;      with eql rather than =
;;; Written 15-Apr-88 15:02:45 by keith (Keith M. Corbett) at site LMI
;;; while running on Opus from band 3
;;; with Experimental System 123.234, Experimental Local-File 73.4, Experimental FILE-Server 22.2, Experimental Unix-Interface 11.0, Experimental KERMIT 34.3, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, Experimental Tiger 27.0, Experimental Site Data Editor 9.0, Experimental Tape 22.1, microcode 1755, SDU Boot Tape 3.14, SDU ROM 8, Beta II/site/patch.



; From modified file OPUS: L.NETWORK.KERNEL; CONFIGURE.LISP#97 at 15-Apr-88 15:02:46
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defvar *protocol-configuration*
	`((:ethernet  (:internet ,ip-ethernet-type (:address :subnet) :address)
		      (:chaos ,chaos-ethernet-type :subnet :address)
		      (:arp ,arp-ethernet-type nil nil))
	  (:loopback  (:internet ,ip-ethernet-type (#x7f000000 #xff000000) #x7f000000)
		      (:chaos ,chaos-ethernet-type nil :address))
	  (:backplane (:internet ,ip-ethernet-type nil :address)
		      (:chaos 0 nil :address))
	  (:serial    (:internet ,ip-ethernet-type nil :address))
	  )
  "List of (hardware-type protocol...) for network interfaces")

))

; From modified file OPUS: L.NETWORK.KERNEL; NETWORK-PROTOCOL.LISP#143 at 15-Apr-88 15:28:24
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; NETWORK-PROTOCOL  "

(defop (network-protocol :send) (packet length interface address &optional hang-p)
  (declare (ignore hang-p))
  (when (and (ni-enabled interface) (ni-loopback interface) (eql address (ni-address interface)))
    (setq interface *loopback-interface*))
  (let* ((int-pkt (original-array packet))
	 (header (ni-sent-header-length interface))
	 (trailer (ni-sent-trailer-length interface))
	 (total-length (+ length header trailer)))
    (cond ((and (np-enabled self) (ni-enabled interface))
	   (incf (np-packets-sent self))
	   (incf (np-bytes-sent self) length)
	   (setf (fill-pointer int-pkt) (ceiling total-length 2))
	   (incf (ni-packets-sent interface))
	   (incf (ni-bytes-sent interface) total-length)
	   (let ((type (cdr (assoc (ni-keyword interface) (np-protocol self) :test #'eq))))
	     ;;***for print-int-pkt-status...
	     (setf (int-pkt-bit-count int-pkt) (swap-two-bytes type))
	     (funcall (ni-send-function interface)
		      int-pkt
		      (ni-address interface)
		      address
		      type
		      (ceiling total-length 2))))
	  (t
	   (incf (np-packets-sent-discarded self))
	   (incf (np-bytes-sent-discarded self) length)
	   (incf (ni-packets-sent-discarded interface))
	   (incf (ni-bytes-sent-discarded interface) length)
	   (free-packet packet)
	   nil))				;Didn't send it
    ))

))

;;ip-network-protocol inherits methods from  network-protocol.  They are defstructs, not
;;flavors, however, so we have to explicitly force changes to bubble through.
(net:create-included-methods 'ip:ip-network-protocol)
(net:create-included-methods 'chaos:chaos-network-protocol)
