Commit graph

57 commits

Author SHA1 Message Date
b5ec25eb6a Don't check errno on EOF in patty_kiss_tnc_recv() 2024-03-01 00:20:47 -05:00
63a1c2d56e Clear unwanted errno in patty_kiss_tnc_new_fd()
Clear unwanted errno in patty_kiss_tnc_new_fd() when isatty() returns
false on a file descriptor
2024-03-01 00:20:47 -05:00
b99a6607ba Use tcflush() in patty_kiss_tnc_new()
Use tcflush() to initialize TTY state in patty_kiss_tnc_new(), so that
no unexpected data causes KISS framing errors
2024-03-01 00:20:47 -05:00
1493f913a7 Don't use tcdrain() in patty_kiss_frame_send()
Don't use tcdrain() in patty_kiss_frame_send(), as this may cause a
program to block indefinitely on BSD systems
2024-03-01 00:20:47 -05:00
b2d3d3e03f Fix strncpy() buffer size compiler warnings 2024-03-01 00:20:47 -05:00
c417461a0b Implement patty_kiss_frame_send()
Implement patty_kiss_frame_send() as a means of sending a KISS frame
without requiring a patty_kiss_tnc object
2024-03-01 00:20:47 -05:00
16179894d2 Add tcdrain() at end of patty_kiss_tnc_send() 2024-03-01 00:20:46 -05:00
671d4ef337 Don't tcsetattr() ptmx in patty_kiss_tnc_destroy()
Avoid tcsetattr() on a ptmx in patty_kiss_tnc_destroy(), as the old
attributes are not saved when opening a Unix98 PTY master
2024-03-01 00:20:46 -05:00
1f4ffc98ac Implement new patty client code
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
2024-03-01 00:20:46 -05:00
81d063cb68 Skip tcgetattr() in patty_kiss_tnc_new_fd() w/ptmx
Modify patty_kiss_tnc_new_fd() to avoid tcgetattr()/tcsetattr() when
passed a file descriptor for a PTY master, to address incompatibility
with BSD kernelspace Unix98 PTY implementations
2024-03-01 00:20:46 -05:00
09df948871 Only set use tcsetattr() on TTYs for KISS TNCs
Fix patty_kiss_tnc_new_fd() to only attempt tcgetattr()/tcsetattr() on
file descriptors for whom isatty() is true, allowing files and sockets
to once again be used
2024-03-01 00:20:46 -05:00
10745bbabf Set raw TTY attributes on patty_kiss_tnc_new_fd()
Changes:

    * Use cfmakeraw() to set raw TTY attributes in KISS TNC constructor
      patty_kiss_tnc_new_fd()

    * Restore previous TTY attributes in patty_kiss_tnc_destroy()
2024-03-01 00:20:46 -05:00
4f3f8bd5e5 Use S_IFMT mask to test for S_IFSOCK in src/kiss.c 2024-03-01 00:20:46 -05:00
216bd91050 Let patty_kiss_tnc_new() use Unix domain sockets
Modify patty_kiss_tnc_new() to connect to a Unix domain socket
2024-03-01 00:20:46 -05:00
905d5b117c Better handle read()s of multiple frames from TNC
Implement better handling of situations when read() captures multiple
TNC frames; ensure each frame is handled in src/server.c, function
handle_iface(), to ensure packets aren't ignored before the next
select() call
2024-03-01 00:20:46 -05:00
ebbfb50b1c Use KISS framing for raw sockets
Use KISS framing for raw sockets to avoid multiple write() calls from
being buffered, which caused read() on the other end of a file
descriptor to read more than frame at once
2024-03-01 00:20:46 -05:00
bdb73c8805 Making significant headway towards a working server 2024-03-01 00:20:46 -05:00
b5ed9e9b61 Fix patty_kiss_tnc_recv() reads less than bufsz
Fix issues with patty_kiss_tnc_recv() when read() calls return less than
the allocated buffer size
2024-03-01 00:20:46 -05:00
307a668d6d That hurt 2024-03-01 00:20:46 -05:00
d266058ad4 Fix patty_kiss_tnc_recv() issues
Fix patty_kiss_tnc_recv() issues with small buffers (~330 bytes) by
more properly detecting EOF being the condition at which the current
decoder offset in the buffer is equal to the last buffer read size; the
offset can never be the number of bytes read, and the initial read
length is -1, so early EOF conditions are avoided
2024-03-01 00:20:46 -05:00
2e0adee54e Remove _unix suffix from patty_kiss_tnc_fd_unix() 2024-03-01 00:20:46 -05:00
750ab452d2 Refactor patty_kiss_tnc_recv()
Refactor patty_kiss_tnc_recv() to always read a fixed number of bytes
into a circular buffer

Other changes:

    * Avoid needing memmove() per packet processed

    * Allow processing packets larger than the internal read buffer
2024-03-01 00:20:46 -05:00
66e5de9d6c Make patty_kiss_tnc_open() use default buffer size
Make patty_kiss_tnc_open() use default buffer size

Other changes:

    * Make src/decode.c no longer require a filename to use as a TNC
2024-03-01 00:20:46 -05:00
d44889121e Do not decode KISS frames into internal buffer
Changes:

    * Modify patty_kiss_tnc_recv() to accept a pointer to a read buffer,
      and a maximum length argument, to receive one packet

    * Modify src/decode.c to use the new patty_kiss_tnc_recv() calling
      form
2024-03-01 00:20:46 -05:00
e74941f714 Fix patty_kiss_tnc_send()
Fix patty_kiss_tnc_send() to ensure frames survive unmodified through
round trips of patty_kiss_tnc_send() and patty_kiss_tnc_recv() calls
2024-03-01 00:20:46 -05:00
54a521e8a8 Use only one write(2) call per frame start
Use only one write(2) call per frame start in src/kiss.c
2024-03-01 00:20:46 -05:00
d7ab08338c Implement patty_kiss_tnc_open_fd()
Implement patty_kiss_tnc_open_fd() to create a TNC object for an
existing Unix file descriptor
2024-03-01 00:20:46 -05:00
ede262397b Refactor patty_kiss_tnc_recv()
Refactor patty_kiss_tnc_recv() to be much more compact and correct;
ensure the KISS command byte is absolutely required, and that
consecutive frame end markers are handled without error
2024-03-01 00:20:46 -05:00
663965db71 Getting there 2024-03-01 00:20:46 -05:00
9217b0366f Sprucing things up a bit 2024-03-01 00:20:46 -05:00
f1e7fc356f Use enum kiss_flags type, not int 2024-03-01 00:20:46 -05:00
df23b0b8e3 Remove irrelevant comment 2024-03-01 00:20:46 -05:00
de0c0ef844 Use uint8_t instead of unsigned char in src/kiss.c 2024-03-01 00:20:46 -05:00
b44a6789a8 Keep escape sequences as static variables 2024-03-01 00:20:46 -05:00
1666666e9d This is all very necessary if I am to wrest tight control over frame decoding into my own hands 2024-03-01 00:20:46 -05:00
63f031b461 It occurs to me I'll need patty_kiss_tnc_decode() to be exported 2024-03-01 00:20:46 -05:00
2c0974658a I'm running out of shitty commit messages 2024-03-01 00:20:46 -05:00
ff76e77336 Stub out patty_ax25_next_event() 2024-03-01 00:20:46 -05:00
86b099bd58 Hmm! Getting somewhere maybe 2015-07-20 23:21:45 -05:00
22874e6e06 Since we broke off, I'm using lipstick again 2015-07-17 00:45:14 +00:00
775c2c5283 s/errors/dropped/g 2015-07-15 21:59:56 -05:00
9af63066b6 Go to hell and back to get valid frames off the wire, and keep track of error counts 2015-07-15 21:59:08 -05:00
6a427c4097 Make tnc_buffer() only return bytes actually read 2015-07-15 21:45:46 -05:00
e7b1c2cf54 Riveting commentary 2015-07-15 21:19:34 -05:00
1cccfca835 KEEN REFACTORING YES VERY MUCH THANK YOU MA'AM 2015-07-15 21:16:39 -05:00
fde6e56d50 Separate buffering method <3 2015-07-15 20:32:24 -05:00
250d19c599 Eh, alignment 2015-07-15 20:29:50 -05:00
4c27c45615 Yes, really 2015-07-16 00:31:40 +00:00
9278eca7c3 IT'S ALIVE\! 2015-07-16 00:31:27 +00:00
1ef84ca2b4 Hi, yes, I'm aware none of this compiles nor makes sense at this time 2015-07-14 22:27:42 -05:00