anchor.diff:  ;;;; This code is licensed under the MIT license.
   
   (in-package :mezzano.network.tcp)
  +
  +(defconstant +tcp4-header-source-port+ 0)
  +(defconstant +tcp4-header-destination-port+ 2)
  +(defconstant +tcp4-header-sequence-number+ 4)
  +(defconstant +tcp4-header-acknowledgment-number+ 8)
  +(defconstant +tcp4-header-flags-and-data-offset+ 12)
  +(defconstant +tcp4-header-window-size+ 14)
  +(defconstant +tcp4-header-checksum+ 16)
  +(defconstant +tcp4-header-urgent-pointer+ 18)
   
   (defconstant +tcp4-flag-fin+ #b00000001)
   (defconstant +tcp4-flag-syn+ #b00000010)
  
positive.code: 
  (defun %tcp4-receive (packet remote-ip start end)
    (setf remote-ip (mezzano.network.ip:make-ipv4-address remote-ip))
    (let* ((remote-port (ub16ref/be packet start))
           (local-port (ub16ref/be packet (+ start 2)))
           (flags (aref packet (+ start 13)))
           (connection (get-tcp-connection remote-ip remote-port local-port)))
      (cond
        (connection
         (tcp4-receive connection packet start end))
        ((eql flags +tcp4-flag-syn+)
         (format t "Establishing TCP connection. l ~D  r ~D  from ~X.~%" local-port remote-port remote-ip)
         (let* ((seq (ub32ref/be packet (+ start 4)))
                (blah (random #x100000000))
                (connection (make-tcp-connection :state :syn-received
                                                 :local-port local-port
  
negative.code:                     (+ (length header) payload-size)))
      (setf checksum (mezzano.network.ip:compute-ip-partial-checksum header 0 nil checksum))
      (setf checksum (mezzano.network.ip:compute-ip-checksum payload 0 nil checksum))
      (setf (ub16ref/be header +tcp4-header-checksum+) checksum)
      packet)))
  
  (defun allocate-local-tcp-port ()
  