| 1 | #cxx . . $ `<file>/user_call/ax25_call.c`/include <stdlib.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <unistd.h> |
| 5 | #include <errno.h> |
| 6 | #include <signal.h> |
| 7 | |
| 8 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 9 | |
| 10 | #include <sys/time.h> |
| 11 | #include <sys/types.h> |
| 12 | #include <sys/socket.h> |
| 13 | |
| 14 | #include <netax25/ax25.h> |
| 15 | #include <netrose/rose.h> |
| 16 | |
| 17 | #include <netax25/axlib.h> |
| 18 | #include <netax25/axconfig.h> |
| 19 | |
| 20 | #include "user_io.h"cxx . . $ `<file>/user_call/user_io.h`/ |
| 21 | |
| 22 | static void alarm_handlercxx . . $ alarm_handler(d4f767463ce0a6b3).(int sig) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 27 | { |
| 28 | char buffer[256], *addr; |
| 29 | int s, addrlen = sizeof(struct full_sockaddr_ax25cxx . . $ full_sockaddr_ax25#); |
| 30 | struct full_sockaddr_ax25cxx . . $ full_sockaddr_ax25# axbind, axconnect; |
| 31 | |
| 32 | while ((s = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, "ci:o:")) != -1) { |
| 33 | switch (s) { |
| 34 | case 'c': |
| 35 | init_compresscxx . . $ init_compress(49f6e7a06ebc5aa8).(); |
| 36 | compressioncxx . . $ compression. = 1; |
| 37 | break; |
| 38 | case 'i': |
| 39 | paclen_incxx . . $ paclen_in. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 40 | break; |
| 41 | case 'o': |
| 42 | paclen_outcxx . . $ paclen_out. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 43 | break; |
| 44 | case ':': |
| 45 | case '?': |
| 46 | errcxx . . $ err(fda57c8427c60377).("ERROR: invalid option usage\r"); |
| 47 | return 1; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | if (paclen_incxx . . $ paclen_in. < 1 || paclen_outcxx . . $ paclen_out. < 1) { |
| 52 | errcxx . . $ err(fda57c8427c60377).("ERROR: invalid paclen\r"); |
| 53 | return 1; |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | * Arguments should be "ax25_call port mycall remcall [digis ...]" |
| 58 | */ |
| 59 | if ((argc - optindcxx . . $ optind.) < 3) { |
| 60 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "ERROR: invalid number of parameters\r"); |
| 61 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 62 | } |
| 63 | |
| 64 | if (ax25_config_load_portscxx . . $ ax25_config_load_ports(b126dc7c1de90089).() == 0) { |
| 65 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "ERROR: problem with axports file\r"); |
| 66 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 67 | } |
| 68 | |
| 69 | /* |
| 70 | * Parse the passed values for correctness. |
| 71 | */ |
| 72 | axconnect.fsa_ax25cxx . . $ full_sockaddr_ax25#fsa_ax25..sax25_familycxx . . $ sockaddr_ax25#sax25_family. = axbind.fsa_ax25cxx . . $ full_sockaddr_ax25#fsa_ax25..sax25_familycxx . . $ sockaddr_ax25#sax25_family. = AF_AX25cxx . . $ `<external>/8962547315054503424/socket.h:98:9`!; |
| 73 | axbind.fsa_ax25cxx . . $ full_sockaddr_ax25#fsa_ax25..sax25_ndigiscxx . . $ sockaddr_ax25#sax25_ndigis. = 1; |
| 74 | |
| 75 | addr = ax25_config_get_addrcxx . . $ ax25_config_get_addr(7a9722d75b371431).(argv[optindcxx . . $ optind.]); |
| 76 | if (addr == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 77 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: invalid AX.25 port name - %s\r", argv[optindcxx . . $ optind.]); |
| 78 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 79 | } |
| 80 | |
| 81 | if (ax25_aton_entrycxx . . $ ax25_aton_entry(2f051e3560ff300f).(addr, axbind.fsa_digipeatercxx . . $ full_sockaddr_ax25#fsa_digipeater.[0].ax25_callcxx . . $ $anonymous_type_a9c4e75d34810e13_0#ax25_call.) == -1) { |
| 82 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: invalid AX.25 port callsign - %s\r", argv[optindcxx . . $ optind.]); |
| 83 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 84 | } |
| 85 | |
| 86 | if (ax25_aton_entrycxx . . $ ax25_aton_entry(2f051e3560ff300f).(argv[optindcxx . . $ optind. + 1], axbind.fsa_ax25cxx . . $ full_sockaddr_ax25#fsa_ax25..sax25_callcxx . . $ sockaddr_ax25#sax25_call..ax25_callcxx . . $ $anonymous_type_a9c4e75d34810e13_0#ax25_call.) == -1) { |
| 87 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: invalid callsign - %s\r", argv[optindcxx . . $ optind. + 1]); |
| 88 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 89 | } |
| 90 | |
| 91 | if (ax25_aton_arglistcxx . . $ ax25_aton_arglist(8658968f15335cbc).((const char**)(&argv[optindcxx . . $ optind. + 2]), &axconnect) == -1) { |
| 92 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: invalid destination callsign or digipeater\r"); |
| 93 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | * Open the socket into the kernel. |
| 98 | */ |
| 99 | s = socketcxx . . $ socket(2326284602b0bb2d).(AF_AX25cxx . . $ `<external>/8962547315054503424/socket.h:98:9`!, SOCK_SEQPACKETcxx . . $ `<external>/5956532346368192945/socket_type.h:38:9`!, 0); |
| 100 | if (s < 0) { |
| 101 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: cannot open AX.25 socket, %s\r", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 102 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * Set our AX.25 callsign and AX.25 port callsign accordingly. |
| 107 | */ |
| 108 | if (bindcxx . . $ bind(f39c6c650450bfdd).(s, (struct sockaddrcxx . . $ sockaddr# *)&axbind, addrlen) != 0) { |
| 109 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: cannot bind AX.25 socket, %s\r", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 110 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 111 | } |
| 112 | |
| 113 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "Connecting to %s ...\r", argv[optindcxx . . $ optind. + 2]); |
| 114 | user_writecxx . . $ user_write(f128fb2b071bb568).(STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!, buffer, strlencxx . . $ strlen(751346f8406fd082).(buffer)); |
| 115 | |
| 116 | /* |
| 117 | * If no response in 30 seconds, go away. |
| 118 | */ |
| 119 | alarmcxx . . $ alarm(2141b656ce2cc063).(30); |
| 120 | |
| 121 | signalcxx . . $ signal(c2d516773f91faf8).(SIGALRMcxx . . $ `<external>/11773118241360591791/signum-generic.h:61:9`!, alarm_handlercxx . . $ alarm_handler(d4f767463ce0a6b3).); |
| 122 | |
| 123 | /* |
| 124 | * Lets try and connect to the far end. |
| 125 | */ |
| 126 | if (connectcxx . . $ connect(f39c6c650450bfdd).(s, (struct sockaddrcxx . . $ sockaddr# *)&axconnect, addrlen) != 0) { |
| 127 | switch (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) { |
| 128 | case ECONNREFUSEDcxx . . $ `<external>/17922322188510340118/errno.h:95:9`!: |
| 129 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "*** Connection refused - aborting\r"); |
| 130 | break; |
| 131 | case ENETUNREACHcxx . . $ `<external>/17922322188510340118/errno.h:85:9`!: |
| 132 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "*** No known route - aborting\r"); |
| 133 | break; |
| 134 | case EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!: |
| 135 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "*** Connection timed out - aborting\r"); |
| 136 | break; |
| 137 | default: |
| 138 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "ERROR: cannot connect to AX.25 callsign, %s\r", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | errcxx . . $ err(fda57c8427c60377).(buffer); |
| 143 | } |
| 144 | |
| 145 | /* |
| 146 | * We got there. |
| 147 | */ |
| 148 | alarmcxx . . $ alarm(2141b656ce2cc063).(0); |
| 149 | |
| 150 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "*** Connected\r"); |
| 151 | user_writecxx . . $ user_write(f128fb2b071bb568).(STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!, buffer, strlencxx . . $ strlen(751346f8406fd082).(buffer)); |
| 152 | |
| 153 | select_loopcxx . . $ select_loop(7864480464b09eea).(s); |
| 154 | |
| 155 | strcpycxx . . $ strcpy(b7b3a83273496486).(buffer, "\r*** Disconnected\r"); |
| 156 | user_writecxx . . $ user_write(f128fb2b071bb568).(STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!, buffer, strlencxx . . $ strlen(751346f8406fd082).(buffer)); |
| 157 | |
| 158 | end_compresscxx . . $ end_compress(49f6e7a06ebc5aa8).(); |
| 159 | |
| 160 | return 0; |
| 161 | } |