;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.101
;;; Reason:
;;;  Better ordering of info on Peek Network display.
;;; Written 5-Nov-87 15:37:00 by pld at site LMI Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.100, 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; NETSTAT.LISP#101 at 5-Nov-87 15:37:00
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; NETSTAT  "

(defun peek-tp-final-fields (tp)
  (nconc (ncons	(sent-statistics (tp-statistics-block tp) "  "))
	 (ncons (rcvd-statistics (tp-statistics-block tp) "  "))
	 (ncons (TV:SCROLL-PARSE-ITEM
		  `(:function tp-packets-sent-discarded (,tp) NIL ("  Packets sent/disc ~D"))
		  `(:function tp-packets-received-discarded (,tp) NIL (" rcvd/disc ~D"))
		  `(:function tp-bytes-sent-discarded (,tp) NIL (" Bytes sent/disc ~D"))
		  `(:function tp-bytes-received-discarded (,tp) NIL (" rcvd/disc ~D"))
		  `(:function tp-broadcast-packets-sent (,tp) NIL (" Broadcast sent ~D"))
		  `(:function tp-broadcast-packets-received (,tp) NIL (" rcvd ~D"))))
	 (case (named-structure-p tp)
	   (icmp:icmp-ip-transport-protocol
	    (ncons (TV:SCROLL-MAINTAIN-LIST #'(LAMBDA () (icmp:icmp-user-socket-alist tp))
					    'icmp-socket)))
	   (udp:udp-ip-transport-protocol
	    (ncons (TV:SCROLL-MAINTAIN-LIST #'(LAMBDA () (udp:udp-user-socket-alist tp))
					    'udp-socket)))
	   (tcp:tcp-ip-transport-protocol
	    (ncons (TV:SCROLL-MAINTAIN-LIST #'(LAMBDA () (tcp:tcp-user-socket-alist tp))
					    'tcp-socket)))
	   (otherwise nil))))

))

; From modified file DJ: L.NETWORK.KERNEL; NETSTAT.LISP#101 at 5-Nov-87 15:43:38
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; NETSTAT  "

(defun peek-network-protocol (np)
  "Format is:

Network Protocol <keyword> is <enabled state>
Packets: <n> sent <n> rcvd <n> sdisc <n> rdisc <n> looped
Bytes: <n> sent <n> rcvd <n> sdisc <n> rdisc <n> looped
"
  (list `( :PRE-PROCESS-FUNCTION peek-network-insert-np-special-fields
	  :stream ,np)
	(tv:scroll-parse-item
	  `(:MOUSE-ITEM
	     (NIL :MENU-CHOOSE
		  ("Network protocol Operations"
		   ("Close" :EVAL   (when (tv:mouse-y-or-n-p "Close this network protocol")
				      (funcall np :close))
		    :DOCUMENTATION
		    "Click left to close this network protocol.")
		   ("Reset" :EVAL   (when (tv:mouse-y-or-n-p "Reset this network protocol")
				      (funcall np :reset))
		    :DOCUMENTATION
		    "Click left to reset this network protocol.")
		   ("Inspect" :EVAL (send tv:selected-window :force-kbd-input `(inspect ,np))
		    :DOCUMENTATION
		    "Click left to INSPECT this network protocol.")
		   ("Describe" :EVAL (send tv:selected-window :force-kbd-input `(describe ,np))
		    :DOCUMENTATION
		    "Click left to DESCRIBE this network protocol."))
		  :DOCUMENTATION
		  "Menu of things to do to this network protocol."
		  :BINDINGS
		  ((np ',np)))
	     :FUNCTION np-keyword (,np) NIL ("Network Protocol ~A"))
	  " is "
	  `(:mouse-item
	     (nil :buttons
		  ,(make-list 3 :initial-element
			      `(nil :eval (funcall np (if (np-enabled np) :disable :enable))
				    :bindings ((np ',np))))
		  :DOCUMENTATION
		  "Click to toggle state of network protocol"
		  :BINDINGS
		  ((np ',np)))
	     :function np-enabled (,np) NIL ("~:[dis~;en~]abled"))
	  `(:function network-protocol-address-list (,np) NIL (" on addresses ~A")))
	(sent-statistics (np-statistics-block np) "")
	(rcvd-statistics (np-statistics-block np) "")
	(TV:SCROLL-PARSE-ITEM
	  `(:function np-packets-sent-discarded (,np) NIL ("Packets sent/disc ~D"))
	  `(:function np-packets-received-discarded (,np) NIL (" rcvd/disc ~D"))
	  `(:function np-bytes-sent-discarded (,np) NIL (" Bytes sent/disc ~D"))
	  `(:function np-bytes-received-discarded (,np) NIL (" rcvd/disc ~D")))
	(tv:scroll-parse-item
	  `(:function network-protocol-list (,np) NIL ("Protocols understood: ~A"))
	  `(:function np-protocols-not-understood (,np) NIL (", not understood: ~A,  "))
	  `(:mouse-item
	     (nil :buttons
		  ((nil :eval (funcall np (if (np-active-gauges np) :kill-gauges :make-gauges))
			:bindings ((np ',np)))
		   (nil :eval (ignore))
		   (nil :eval (gauge-menu np (np-active-gauges np))
			:bindings ((np ',np))))
		  :documentation
		  "Click left for default, right for menu"
		  ((np ',np)))
	     :function ,#'(lambda (n) (mapcar 'car (np-active-gauges n))) (,np) NIL ("Gauges: ~A")))
	(TV:SCROLL-PARSE-ITEM
	  :leader 1
	  ""))
  )

))

; From modified file DJ: L.NETWORK.KERNEL; NETSTAT.LISP#101 at 5-Nov-87 15:43:48
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; NETSTAT  "

(defun np-special-fields (np)
  (case (named-structure-p np)
    ((net:network-protocol nil) nil)
    (net:arp-network-protocol nil)
    (chaos:chaos-network-protocol nil)
    (ip:ip-network-protocol
     (list (tv:scroll-parse-item
	     `(:function ip:ip-checksum-failures (,np) NIL ("Bad checksum ~D"))
	     `(:function ip:ip-bad-header (,np) NIL (" bad header ~D"))
	     `(:function ip:ip-bad-options (,np) NIL (" bad options ~D"))
	     `(:function ip:ip-unknown-protocol-packets (,np) NIL (" bad protocol ~D"))
	     `(:function ip:ip-fragment-timeouts (,np) NIL (" frag timeouts ~D")))
	   (tv:scroll-parse-item
	     `(:function ip:ip-hardware-broadcast-packets (,np) NIL ("Hardware Broadcast packets = ~D"))
	     `(:function ip:ip-ip-broadcast-packets (,np) NIL ("  IP Broadcast packets ~D"))
	     `(:function ip:ip-self-address-packets (,np) NIL ("  Self Address packets ~D"))
	     `(:mouse-item
		(nil :buttons
		     ,(make-list 3 :initial-element
				 `(nil :eval (setf (ip:ip-local-checksums np)
						   (not (ip:ip-local-checksums np)))
				       :bindings ((np ',np))))
		     :DOCUMENTATION
		     "Click to toggle local checksums"
		     :BINDINGS
		     ((np ',np)))
		:function ip:ip-local-checksums (,np) NIL (" Local checksums: ~A")))
	   (tv:scroll-parse-item
	     `(:mouse-item
		(nil :buttons
		     ,(make-list 3 :initial-element
				 `(nil :eval (setf (ip:ip-gateway np) (not (ip:ip-gateway np)))
				    :bindings ((np ',np))))
		  :DOCUMENTATION
		  "Click to toggle IP gateway functions"
		  :BINDINGS
		  ((np ',np)))
		:function ip:ip-gateway (,np) NIL ("IP gateway: ~A"))
	     `(:function ip:ip-packets-forwarded (,np) NIL (" forwarded ~D"))
	     `(:function ip:ip-packets-queued (,np) NIL (" queued ~D"))
	     `(:function ip:ip-not-for-me (,np) NIL (" not for me ~D"))
	     `(:function ip:ip-no-forwarding-address (,np) NIL (" no address ~D"))
	     `(:function ip:ip-cant-forward (,np) NIL (" queue full ~D"))
	     `(:function ip:ip-ttl-expired (,np) NIL (" TTL expired ~D")))
	   (TV:SCROLL-MAINTAIN-LIST #'(LAMBDA () (np-protocols np))
				    'peek-transport-protocol)))
    (otherwise nil)))

))
