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 (connection packet &optional (start 0) end)
    (unless end (setf end (length packet)))
    (with-tcp-connection-locked connection
      (let* ((seq (ub32ref/be packet (+ start 4)))
             (ack (ub32ref/be packet (+ start 8)))
             (flags (aref packet (+ start 13)))
             (header-length (* (ash (aref packet (+ start 12)) -4) 4))
             (data-length (- end (+ start header-length))))
        (case (tcp-connection-state connection)
          (:syn-sent
  
negative.code:           (header (make-array 20 :element-type '(unsigned-byte 8)))
            (packet (list header payload)))
       ;; Assemble the TCP header.
      (setf (ub16ref/be header +tcp4-header-source-port+) src-port
            (ub16ref/be header +tcp4-header-destination-port+) dst-port
            (ub32ref/be header +tcp4-header-sequence-number+) seq-num
            (ub32ref/be header +tcp4-header-acknowledgment-number+) ack-num
            ;; Data offset/header length (5 32-bit words) and flags.
            (ub16ref/be header +tcp4-header-flags-and-data-offset+) (logior #x5000
                                                                            (if fin-p +tcp4-flag-fin+ 0)
                                                                            (if syn-p +tcp4-flag-syn+ 0)
                                                                            (if rst-p +tcp4-flag-rst+ 0)
                                                                            (if psh-p +tcp4-flag-psh+ 0)
                                                                            (if ack-p +tcp4-flag-ack+ 0))
            ;; Window.
            (ub16ref/be header +tcp4-header-window-size+) window
            ;; Checksum.
            (ub16ref/be header +tcp4-header-checksum+) 0
            ;; Urgent pointer.
            (ub16ref/be header +tcp4-header-urgent-pointer+) 0)
      ;; Compute the final checksum.
      (setf checksum (compute-ip-pseudo-header-partial-checksum
                      (mezzano.network.ip::ipv4-address-address src-ip)
  