;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.155
;;; Reason:
;;;  Split out network-variable cleanup tasks into (net:cleanup).
;;;  Do (net:deconfigure) (net:cleanup) before a disk-save.
;;; Written 8-Dec-87 13:29:50 by pld at site Gigamos Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.154, Experimental Local-File 73.3, Experimental FILE-Server 22.1, 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#87 at 8-Dec-87 13:31:29
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defun cleanup ()
  (unless (and (boundp '*loopback-interface*)
	       *loopback-interface*
	       (ni-enabled *loopback-interface*))
    ;;Only do this if network is deconfigured
    (chaos:reset nil)
    (setq chaos:made-pkts nil)
    (setq chaos:pkts-made 0)
    (setq chaos:free-pkts nil)
    (setq chaos:los-pkts nil)
    (setq chaos:current-los-pkt-count 0)
    (setq ethernet:*3com-ethernet-interface* nil)
    (setq ethernet:*excelan-ethernet-interface* nil)
    (setq ethernet:explorer-ethernet-interface nil)
    (setq chaos:cadr-network-interface nil)
    (setq si:share-interface nil)
    (setq net:*loopback-interface* nil)
    (setq arp:*arp-stream* nil)
    (setq chaos:*chaos-stream* nil)
    (setq ip:*ip-stream* nil)
    (setq ip:*free-ip-headers* nil)
    (setq ip:*route-table* nil)
    (setq ip:*default-network-numbers* nil)
    (setq ip:*default-gateway* nil)
    (setq ip:*default-interface* nil)
    (setq ip:*network-list* nil)
    (setq ip:*queued-packet-fifo* (make-fifo))
    (setq icmp:*icmp-stream* nil)
    (setq icmp:*free-icmp-messages* nil)
    (setq udp:*udp-stream* nil)
    (setq udp:*free-udp-buffers* nil)
    (setq udp:*free-udp-headers* nil)
    (setq tcp:*tcp-stream* nil)
    (setq tcp:*free-tcp-buffers* nil)
    (setq tcp:*free-tcp-headers* nil)
    (setq tcp:*send-blocked-sockets* (make-fifo))
    (setq tcp:*send-blocked-control-packets* (make-fifo))
    (setq tcp:*global-timeouts* nil)
    (setq tcp:*tcp-log* (make-fifo))
    (setq tcpa:*udp-rwho-server-packets* nil)
    ))

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#87 at 8-Dec-87 13:31:34
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defun maybe-deconfigure-network ()
  (setq *network-deconfigured-before-gc* nil)
  (when (and (boundp '*loopback-interface*)
	     *loopback-interface*
	     (ni-enabled *loopback-interface*))
    (format *query-io* "~&    Deconfiguring the network will allow garbage collection to reclaim network objects.~%")
    (when (global:with-timeout ((* 30 60.) (progn (write-string "Yes (after timeout)" *query-io*) t))
	    (yes-or-no-p "        Deconfigure network (Yes after thirty seconds) ? "))
      (setq *network-deconfigured-before-gc* t)
      (net:deconfigure)))
  (cleanup))

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#87 at 8-Dec-87 13:31:44
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(add-initialization "Deconfigure Network System" '(progn (deconfigure) (cleanup)) '(:before-cold))

))

(delete-initialization "Cleanup RWHO database" '(:before-cold))
(delete-initialization "Cleanup RWHO database" '(:full-gc))

