untrusted comment: verify with st.pub
RWQTleDnDrmVqVsxIW6RA2afooIUBkLHaGZ/SAvXumdJoDQL1TGn4jeJf+75dwkpABHKDwxGqp0f1jahiXWL3RP4xq7z5tBCWwo=
#|
Well, I'm starting a sm0l implementation of chaosnet
named so because everyone sees every message on the
ether, so everyone just syncronises by the last 
successful ether hardware packet ; no centralisation.

Addresses are the phase of the next available cycle
that address is meant to jump in on when they have
something to send.

No-one else tries to send if someone is already 
sending, and if there's a collision everyone aborts 
and cools off for two cycles.

I made a class that just holds the mandated array
with slightly vulgar repetitive access methods.

The next step will be an ether class that syncronises 
across lisp images, maybe just neighbors since the
ether forms a line of connections.

By the way, who was it that knew gopher://quux.org ?
Who wrote about chaosnet on the gopher before.

Check my mastodon for a link to a good scan of the
Chaosnet paper (found on Wikipedia).

I'm imagining one LAN = one ether, and then two-sided
bridges over tor, for safe self-hosting.

chaosnet doesn't attempt security, same as gopher,
so tor also adds privacy and security.
|#
(in-package "chaostape-screwnet")

(defclass hard-packet ()
 ((hw-packet :initarg :hw-packet :reader hw-packet))
 (:default-initargs
  :hw-packet (make-array (or (/ (+ 4032 48) 16) 255)
              :element-type `(mod ,(expt 2 16)))))

(defmethod destination ((obj hard-packet))
 (aref (hw-packet obj) 0))
(defmethod (setf destination) (val (obj hard-packet))
 (setf (aref (hw-packet obj) 0) val))

(defmethod source ((obj hard-packet))
 (aref (hw-packet obj) 1))
(defmethod (setf source) (val (obj hard-packet))
 (setf (aref (hw-packet obj) 1) val))

(defmethod check ((obj hard-packet))
 (aref (hw-packet obj) 2))
(defmethod (setf check) (val (obj hard-packet))
 (setf (aref (hw-packet obj) 2) val))

(defmethod data ((obj hard-packet))
 (subseq (hw-packet obj) 3))
(defmethod (setf data) (val (obj hard-packet))
 (setf (subseq (hw-packet obj) 3) val))