Implement frame segmentation/reassembly state machine as per AX.25 v2.2
specifications, as per Section 6.6 "Disassembler/Reassembler" and
associated appendices
Reduced default I frame info field to 127 bytes so as to hopefully
better coincide with common TNC firmware; it is suspected (but not
confirmed that they do include the protocol identifier as part of the
info field length
Use default I frame lengths for common TNCs per version; for AX.25
prior to 2.2, use 128, otherwise, use 255, the maximum for Kenwood and
possibly other Kantronics-style TNCs
Changes:
* Add validation to accept() to ensure file descriptors provided
refer to SOCK_STREAM sockets in the SOCK_LISTENING state
* Rather than writing a reply to the patty client socket when
accepting a SABM or SABME request, write a message to the
remote end of the listening socket; this avoids issues wherein
a client receives an unexpected accept() response that may be
unrelated to another pending request; this also allows client
code to use select(2) on listening sockets
* In patty_client_accept(), send the initial request to validate
that the local socket can accept connections, and then wait for
a connection to be made, reading a message written to the
listening socket from the patty server
* Allow select(2) to notify on accepted connections
Changes:
* Replace usage of gettimeofday() with clock_gettime() in the main
event loop, patty_ax25_server_run(), as gettimeofday() apparently
goes backwards in time occasionally, as per:
https://bugzilla.redhat.com/show_bug.cgi?id=174390
Thanks Iain MM0ROR!
* Fix patty_timer_expired() to properly return true if the
remaining number of seconds is zero, but the remaining higher
precision time is less than zero
* Implement patty_timer_sub() to subtract two struct timespec
values, as glibc lacks timespecsub()
Implement PATTY_AX25_SOCK_DGRAM type sockets as a means of exchanging UI
frames between stations without requiring calling code to encode and
decode UI frames explicitly
Add SOCK_PARAMS to patty_client_setsockopt() to allow for setting
(presently) the MTU and TX window of a given socket to accommodate the
needs of specific remote stations
Implement the SOCK_WAIT and SOCK_READY socket flow control states to
indicate a Receive Ready or Receive Not Ready state on the remote end
Other changes:
* Fix issue wherein flow control was never halted when the remote
end has received k (window) number of frames without the sending
station asking for acknowledgment
Changes:
* Reimplement patty_ax25_sock_send() to be geared specifically for
sending raw frames; the function which formerly held this name is
now a private method
* Implement patty_ax25_sock_recv() to receive a frame from a raw
socket
* Implement patty_ax25_sock_recv_pending() to determine how many raw
frames are pending receipt in the buffer
* When handling raw sockets, use patty_ax25_sock_recv_pending() to
ensure any raw pending frames read from a client intended for
transmission on an interface are read completely
Changes:
* When associating a promiscuous socket with an interface, rather
than creating a patty_kiss_tnc object, simply store the socket
file descriptor and use patty_kiss_frame_send() to send incoming
or outgoing frames for that interface to the promiscuous socket
* Add special initialization code in src/sock.c for SOCK_RAW; don't
allocate any buffers, but instead set a few flags and otherwise
use 0-initialized defaults
* Implement handle_sock_raw() in src/server.c to check to see if any
raw frames are pending, and if so, send them to the associated
interface if provided by setsockopt()
* Make patty_ax25_sock_bind_if() only call the function
patty_ax25_if_add_promisc() only if the socket status is PROMISC;
this allows support for non-promiscuous sockets used for outbound
purposes
Changes:
* Rename seq_send to vs, ie, V(S)
* Rename seq_recv to vr, ie, V(R)
* Ensure handling RR responses updates V(S) with the N(R) value of
the received frame
Changes:
* Fix Classes of Operations and HDLC parameter bit flags in
include/patty/ax25.h to match the documentation after more careful
analysis; resolve issues with byte order
* Add support for previously missing HDLC parameters to function
patty_print_params()
* Fix Info TX/RX field encodings to be in bits, rather than bytes
* Implement patty_ax25_sock_realloc_bufs() to reallocate buffers
based on current window and I frame sizes
* Implement patty_ax25_sock_params_upgrade() to upgrade a socket's
parameters to the AX.25 v2.2 documented defaults; this will not
change parameters if the socket is already set to v2.2
* Implement patty_ax25_sock_params_max() to upgrade a socket's
parameters to the highest values supported by patty
* Reimplement patty_ax25_sock_send_xid() to send highest desired
parameters, rather than the values currently set on the socket
* When receiving XID frames destined to listening sockets, use
patty_ax25_sock_params_max() to negotiate from high to low
parameters
* When receiving SABME flags, use patty_ax25_sock_params_upgrade()
to ensure at least base AX.25 v2.2 parameter defaults are set
* Fix issue where outbound connections initiated with XID were
unable to time out after N retries
Implement new patty client code, replacing src/call.c with src/client.c
providing clients with an interface dealing with file descriptors valid
in their process space; this also obviates the need to open a Unix
domain socket to a patty server explicitly, and helps keep track of
sockets opened on the server, locally
Changes:
* Implement patty_client_new() to handle opening the server Unix
domain socket, and to allocate a dict for mapping server-side
sockets with current process file descriptors
* Reimplement all server calls in src/call.c around the new
patty_client type; calls which result in the creation of a
Unix98 PTY by the patty server now handle opening the local PTY
and setting the file descriptor to raw mode. Furthermore, these
calls deal exclusively in terms of current process file
descriptors
* Refactor src/server.c to use the new patty_client type and calls
* Refactor examples/client.c, examples/server.c, examples/ax25dump.c
to use the new patty_client type and calls
* Fix a bug in src/server.c, respond_accept() wherein a 0, rather
than the file descriptor of the socket, is sent to the client as a
return value
More strictly adhere to the behaviors of Timers T1, T2 and T3 as
prescribed in the AX.25 v2.2 Specification, Section 4.4.5 "Timeout Error
Recovery" descriptions for Timer T1 and T3, as well as Section 6.7.1.2
"Response Delay Timer T2"
Changes:
* Implement patty_timer type to store both a struct timeval and a
bitfield for indicating timer state; currently, this only holds
the PATTY_TIMER_RUNNING flag to indicate whether a timer has been
stopped (irrespective of its "expired" status)
* Remove 'target' argument from patty_timer_start(); instead, rely
on select() polling every 1s to cause events to trigger at a
regular interval
* Make patty_timer_expired() return false if PATTY_TIMER_RUNNING is
not set
* Implement patty_timer_stop() to clear the PATTY_TIMER_RUNNING flag
of a timer
* Make patty_timer_clear() set all fields to zero, including
clearing the PATTY_TIMER_RUNNING flag
Implement AX.25 v2.2 Section 6.7.1.2 "Response Delay Timer T2" as per
specification; do not acknowledge several sequential I frames until a
certain period of time has passed since the receipt of the most recent I
frame
Changes:
* Implement patty_timer_expired() to determine if a timer has
expired or has gone negative
* Implement patty_timer_cancel() to set a timer to zero
* Implement patty_timer_start() to initialize a timer, add a
specified number of milliseconds, and ensure a target timer (such
as the server timer) is set for at least that value as well
* Implement patty_timer_tick() to subtract an elapsed time value
from a timer
* Remove functions specific to each timer in src/sock.c, as those
can now be handled generically by src/timer.c
* Replace calls to patty_ax25_sock_timer_t1_*() with patty_timer_*()
calls instead; reference the struct timeval objects directly
within the sock (for the time being, pending opaque structures)
Changes:
* Combine patty_ax25_sock_ack_timer_restart() and _set() into one
method, patty_ax25_sock_ack_timer_start(), which accepts a new
struct timeval argument to potentially add the Timer T1 value to
* Reorder some functions in src/sock.c, include/patty/ax25/sock.h
Changes:
* Implement patty_ax25_sock_timeR_ack_restart() to initialize the
XID/SABM/SABME ack Timer T1
* Implement patty_ax25_sock_timer_ack_cancel() to clear Timer T1
* Implement patty_ax25_sock_timer_ack_sub() to subtract the value of
a struct timeval from Timer T1
* Implement patty_ax25_sock_timer_ack_expired() to indicate if the
ack Timer T1 has expired
Other changes:
* Rearrange patty_ax25_sock a bit
Begin to reimplement patty_ax25_sock_reset() to follow the AX.25 v2.2
Specification, Section 6.5 "Resetting Procedure" indications to set V(S)
and V(R) to 0
Rename patty_ax25_sock_reset() to patty_ax25_sock_init(), so as to allow
for the implementation of a future _reset() method which shall be used
to implement AX.25 v2.2 Section 6.5 "Resetting Procedure"
Changes:
* Make patty_ax25_sock_send_rr() accept a P/F flag value
* Make patty_ax25_sock_send_rnr() accept a P/F flag value
* Make patty_ax25_sock_send_rej() accept a P/F flag value
Changes:
* Add an enum patty_ax25_version argument to the function
patty_ax25_sock_upgrade() to allow upgrading a socket to a certain
set of AX.25 defaults
Keep distinct default Classes of Procedures parameter flag values for
sockets and interfaces, as the Asynchronous Balanced Mode parameter does
not apply to the interface itself, and the Half/Full Duplex parameters
do not apply to the sock
Changes:
* Make bind() validate that no other socket has the same
callsign/SSID bound to a listening socket, emitting EADDRINUSE if
one already exists
* Make bind() validate that no address is already bound to the
socket, emitting EINVAL otherwise
Changes:
* Add a "pending disconnect" state to enum patty_ax25_sock_state
(PATTY_AX25_SOCK_PENDING_DISCONNECT), used when an originating
system sends a DISC frame, pending a UA response
* When handling a UA frame, rather than terminating a socket in the
established state implicitly, check for a "pending disconnect"
state explicitly
Other changes:
* When a remote socket has already been obtained in handle_frame()
in src/server.c, pass that socket to any other method that would
otherwise be looking up the same socket
Changes:
* Don't use a separate dict for keeping track of sockets pending
accept and sockets pending connect; rely more on the semantic
meaning of the enum patty_ax25_sock_status values
* Ensure DISC frames are acknowledged by UA frames
* Ensure a receiving system only shuts down a connection after
receiving a UA frame in response to a sent DISC frame
* Ensure a sending system only shuts down a connection just prior to
sending a UA frame in response to a received DISC frame
* Don't use the P/F flag for the connection management U frames;
implicitly assume the P/F flag is set to 1, and always send frames
with a true P/F flag
Changes:
* Replace patty_ax25_sock member 'buf' with 'tx_buf' and 'rx_buf'
for transmitting or receiving single, non-sequential packets
* Make patty_ax25_sock_upgrade() reallocate all I/O buffers based on
window size and MTU/MRU, useful when entering SABME mode
Changes:
* Modify patty_ax25_sock_send_xid() to require the 'cr' argument,
which specifies whether the frame address field is to be encoded
with the 'command' or 'response' bits set as appropriate
Changes:
* Add 'format' member to patty_ax25_frame
* Drop 'format' argument in patty_ax25_encode_reply_to()
* Drop 'format' argument in patty_ax25_encode()
* Consolidate private functions for encoding frame addresses to one
much simpler function to perform encoding; simplify encoding of
addresses in frames sent in reply to other frames
Changes:
* Implement patty_ax25_sock_upgrade() to upgrade a socket from the
default AX.25 2.0 parameters to AX.25 2.2 parameters, meant to be
used upon receipt of an XID frame
* Implement patty_ax25_sock_params_set() to set lowest common
denominator parameters to a socket, downgrading or adapting to the
parameters advertised by a peer XID frame as necessary
Changes:
* Define different sets of default parameters for AX.25 versions
2.2 and prior
* Add flags_classes, flags_hdlc and version to patty_ax25_sock
* Remove flags member from patty_ax25_sock
* Inherit Classes of Procedures value from interface when an
interface is bound to a socket