patty/bin/kiss.c
XANTRONIX Development cb33d799ff Implement patty_ax25_if_driver
Changes:

    * Implement patty_ax25_if_driver type, providing a vtable with
      pointers to methods implementing an AX.25 interface PHY

    * Implement patty_ax25_if_name() to return a pointer to the name
      string of an AX.25 interface

    * Decouple patty_kiss_tnc from src/if.c using patty_ax25_if_driver

    * Remove port input/output arguments from patty_kiss_tnc_send()
      and patty_kiss_tnc_recv(), respectively; use 0 as the default,
      but keep the port argument in patty_kiss_frame_send()

    * Implement patty_ax25_if_fd() to return file descriptor backing a
      PHY; use this rather than patty_kiss_tnc_fd() in src/server.c to
      further decouple interfaces from their implementation

    * Remove 'enum patty_ax25_if_type' type; refactor constructor
      patty_ax25_if_new() to no longer take this as an argument, but
      rather a patty_ax25_if_driver to use to instantiate the PHY
      with the information pointer passed

    * Break out patty_kiss_tnc code from src/kiss.c into src/tnc.c,
      leaving only patty_kiss_frame_send() in the original; this is
      needed to prevent a cyclic dependency within patty_ax25_sock and
      other areas

    * Rename patty_bin_if_config() to patty_bin_if_create(); a separate
      patty_bin_if_config() will likely be created later as necessary
      to change an existing interface

    * Split PHY-specific interface configuration code into separate
      delegates in bin/if.c

    * Implement usage of patty_error to better capture internal error
      states not currently representable with semantic error numbers
      while configuring and instantiating PHYs

    * Pass patty_error object to patty_bin_kiss_config() to receive
      detailed error information
2024-03-01 00:20:47 -05:00

42 lines
1.1 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <patty/bin/kiss.h>
int patty_bin_kiss_config(int argc,
char **argv,
patty_kiss_tnc_info *info,
patty_error *e) {
int i;
memset(info, '\0', sizeof(*info));
info->flags |= PATTY_KISS_TNC_DEVICE;
info->device = argv[0];
for (i=1; i<argc; i++) {
if (strcmp(argv[i], "crtscts") == 0) {
info->flags |= PATTY_KISS_TNC_FLOW;
info->flow = PATTY_KISS_TNC_FLOW_CRTSCTS;
} else if (strcmp(argv[i], "xonxoff") == 0) {
info->flags |= PATTY_KISS_TNC_FLOW;
info->flow = PATTY_KISS_TNC_FLOW_XONXOFF;
} else if (argv[i][0] >= '0' && argv[i][0] <= '9') {
int baud = atoi(argv[i]);
info->flags |= PATTY_KISS_TNC_BAUD;
info->baud = baud;
} else {
patty_error_fmt(e, "Invalid KISS TNC device parameter '%s'",
argv[i]);
goto error_invalid_device_setting;
}
}
return 0;
error_invalid_device_setting:
return -1;
}