For Chris, mostly,
In my AX25 code, the two queues are named read_data and write_data,
you can search for those values. The length, position, and size are
right after it and described in the comment above.
There are also some functions named "sub_seq", "add_seq" and
"seq_in_range" that handle the wraparound. In particular,
seq_in_range is a little tricky. And I see that I should comment
those better.
And if you want, I can look at splitting up my code into a library
that has the state machine that could be re-used. It may be some
overkill, though, it does all the extended sequencing, XID, and such
that we don't need.
-corey