;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.45
;;; Reason:
;;;  (net:configure) now calls (net:initialize-network-buffers) to reset the
;;;  int-pkt free list -- to recover after a warm boot, for example.
;;; Written 9-Oct-87 11:57:34 by pld at site LMI Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.43, 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, microcode 1754, SDU Boot Tape 3.12, SDU ROM 8.



; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#81 at 9-Oct-87 11:57:35
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defun configure ()
  ;; If we are in the cold load, do a mini-configuration
  (when si:*in-cold-load-p*
    (cold-load-configure)
    (return-from configure t))

  ;; Clear out current network configuration
  (deconfigure)

  ;; Reset the int-pkts
  (initialize-network-buffers)
  
  ;; Put the network clock function onto the clock list
  (without-interrupts
    (pushnew 'net:network-clock sys:clock-function-list))
  
  ;; Start the device drivers
  (setup-loopback "LOOPBACK")
  (select-processor
    (:lambda
      (si:set-processor-owning-ethernet :find :3com)
      (cond ((eq ethernet:*3com-owner* si:*my-op*)
	     (ethernet:setup-3com "ONE")
	     (si:set-processor-owning-ethernet :give-up :excelan))
	    (t
	     (si:set-processor-owning-ethernet :find :excelan)
	     (if (eq ethernet:*excelan-owner* si:*my-op*)
		 (ethernet:setup-excelan "ONE"))))
      (si:setup-share-interface "SHARE"))
    (:explorer
      (ethernet:setup-explorer-ethernet "ONE"))
    (:cadr
      (chaos:setup-cadr-network "ONE")))
  
  ;; Start the protocol modules
  (when (eq si:*my-op* si:*ethernet-hardware-controller*)
    (arp:setup-arp))
  (chaos:setup-chaos)

  (let ((ip-address-p (ip:setup-ip)))
    (cond (ip-address-p
	   (icmp:setup-icmp)
	   (udp:setup-udp)
	   (tcp:setup-tcp))
	  (t
	   (tv:notify nil "This processor has no Internet Address")))
  
    (select-processor
      (:lambda
	;;KLUDGE: share interface must be set up before chaos, as chaos enables itself on share device --
	;;but share interface sets %processor-conf-chaos-address, so must reset it after chaos
	;;has set its address
	(send si:share-interface :reset)
	;; for all of our other processors, set up ARP translation for share interface
	(setq *processor-forwarding-alist* nil)
	(dolist (op si:*other-processors*)
	  (push (cons op nil) *processor-forwarding-alist*)
	  (dolist (domain '(:chaos :internet))
	    (let ((address (find-network-address-for-other-processor op domain)))
	      (when address
		(add-address-info address domain si:share-interface op))))))
      ((:cadr :explorer)))

    (dolist (x (ni-address-alist *loopback-interface*))
      ;;For all protocols enabled on the loopback interface, set up address translations
      (when (second x)
	(add-address-info (second x) (first x) *loopback-interface* nil)))

    (when ip-address-p
      ;;Start the TCP/UDP server process and enable network services
      (tcp-application:initialize-tcp-server-process)
      (tcp-application:enable-all-network-services)
      (tcp-application:initialize-udp-rwho-server-process)))

  ;;Start the network receiver process
  (start-receiver)

  (setup-network-gauges)			;If Fancy-Landscape enabled, populate screen with gauges

  t)

))
