From 17287576555a5c46fa23549e2e5f073660dccb70 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 21 Apr 1999 09:51:03 +0200 Subject: Import ax25-tools 0.0.1 from tarball --- ax25/axctl.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 ax25/axctl.c (limited to 'ax25/axctl.c') diff --git a/ax25/axctl.c b/ax25/axctl.c new file mode 100644 index 0000000..84422fd --- /dev/null +++ b/ax25/axctl.c @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +int main(int argc, char **argv) +{ + struct ax25_ctl_struct ax25_ctl; + char *addr; + int s; + + if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) { + printf("axctl: %s\n", VERSION); + return 0; + } + + if (argc < 5) { + fprintf(stderr, "Usage: axctl [-v] port dest src -t1|-t2|-t3|-n2|-paclen|-idle|-window|-maxq|-kill parm\n"); + return 1; + } + + if (ax25_config_load_ports() == 0) { + fprintf(stderr, "axctl: no AX.25 port data configured\n"); + return 1; + } + + if ((addr = ax25_config_get_addr(argv[1])) == NULL) { + fprintf(stderr, "axctl: invalid port name - %s\n", argv[1]); + return 1; + } + + if (ax25_aton_entry(addr, (char *)&ax25_ctl.port_addr) == -1) + return 1; + if (ax25_aton_entry(argv[2], (char *)&ax25_ctl.dest_addr) == -1) + return 1; + if (ax25_aton_entry(argv[3], (char *)&ax25_ctl.source_addr) == -1) + return 1; + + if ((s = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) { + perror("axctl: socket"); + return 1; + } + + if (strcmp(argv[4], "-kill") == 0) { + ax25_ctl.cmd = AX25_KILL; + ax25_ctl.arg = 0; + } else { + if (argc < 6) { + fprintf(stderr,"axctl: parameter missing\n"); + return 1; + } + ax25_ctl.arg = atoi(argv[5]); + + if (strcmp(argv[4], "-t1") == 0) + ax25_ctl.cmd = AX25_T1; + else if (strcmp(argv[4], "-t2") == 0) + ax25_ctl.cmd = AX25_T2; + else if (strcmp(argv[4], "-t3") == 0) + ax25_ctl.cmd = AX25_T3; + else if (strcmp(argv[4], "-idle") == 0) + ax25_ctl.cmd = AX25_IDLE; + else if (strcmp(argv[4], "-n2") == 0) + ax25_ctl.cmd = AX25_N2; + else if (strcmp(argv[4], "-window") == 0) + ax25_ctl.cmd = AX25_WINDOW; + else if (strcmp(argv[4], "-paclen") == 0) + ax25_ctl.cmd = AX25_PACLEN; + } + + if (ioctl(s, SIOCAX25CTLCON, &ax25_ctl) != 0) { + perror("axctl: SIOAX25CTLCON"); + return 1; + } + + return 0; +} + -- cgit v1.2.3