| 1 | #cxx . . $ `<file>/rose/rsparms.c`/include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | #include <ctype.h> |
| 5 | #include <unistd.h> |
| 6 | |
| 7 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 8 | #include <scm-version.h>cxx . . $ `<file>/scm-version.h`/ |
| 9 | |
| 10 | #include <sys/types.h> |
| 11 | #include <sys/ioctl.h> |
| 12 | |
| 13 | #include <sys/socket.h> |
| 14 | #include <netax25/ax25.h> |
| 15 | #include <netrose/rose.h> |
| 16 | |
| 17 | #include <netax25/axlib.h> |
| 18 | #include <netax25/axconfig.h> |
| 19 | #include <netax25/rsconfig.h> |
| 20 | |
| 21 | #include "../pathnames.h"cxx . . $ `<file>/pathnames.h`/ |
| 22 | |
| 23 | static char nodes_usagecxx . . $ nodes_usage.[] = "usage: rsparms -nodes add|del nodeaddr[/mask] " |
| 24 | "port neighbour [digis...]\n rsparms -nodes list\n"; |
| 25 | |
| 26 | /* print the Rose neighbour whose number is supplied */ |
| 27 | static void printnbcxx . . $ printnb(fda57c8427c60377).(char *neigh) |
| 28 | { |
| 29 | FILEcxx . . $ FILE#* fp; |
| 30 | char addr[10], callsign[10], port[10], digi[10]; |
| 31 | char buff[80]; |
| 32 | int args; |
| 33 | |
| 34 | fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(PROC_RS_NEIGH_FILEcxx . . $ `pathnames.h:26:9`!, "r"); |
| 35 | if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 36 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"rsparms: Couldn't open %s file\n",PROC_RS_NEIGH_FILEcxx . . $ `pathnames.h:26:9`!); |
| 37 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 38 | } |
| 39 | |
| 40 | while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(buff, 80, fp)) { |
| 41 | addr[0] = '\0'; |
| 42 | callsign[0] = '\0'; |
| 43 | port[0] = '\0'; |
| 44 | digi[0] = '\0'; |
| 45 | |
| 46 | args=sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(buff,"%9s %9s %9s %*s %*s %*s %*s %*s %*s %9s",addr,callsign,port,digi); |
| 47 | |
| 48 | if (args==4) { /* We have a digi */ |
| 49 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(addr,neigh)==0) |
| 50 | printfcxx . . $ printf(581fddd72a8db8fc).("%-6s %-9s via %-9s",port,callsign,digi); |
| 51 | } else |
| 52 | if (args==3) { /* No digi */ |
| 53 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(addr,neigh)==0) |
| 54 | printfcxx . . $ printf(581fddd72a8db8fc).("%-6s %-9s",port,callsign); |
| 55 | } |
| 56 | } |
| 57 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 58 | } |
| 59 | |
| 60 | static void nodescxx . . $ nodes(8d5b198710c10580).(int s, int argc, char *argv[]) |
| 61 | { |
| 62 | struct rose_route_structcxx . . $ rose_route_struct# rs_node; |
| 63 | char *dev; |
| 64 | char *mask; |
| 65 | char nodeaddr[11]; |
| 66 | int i, n; |
| 67 | |
| 68 | FILEcxx . . $ FILE# *fn; |
| 69 | char address[12], rmask[5], neigh1[10], neigh2[10], neigh3[10]; |
| 70 | char buff[80]; |
| 71 | int args; |
| 72 | |
| 73 | if (argc < 3) { |
| 74 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s", nodes_usagecxx . . $ nodes_usage.); |
| 75 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 76 | } |
| 77 | |
| 78 | if (ax25_config_load_portscxx . . $ ax25_config_load_ports(b126dc7c1de90089).() == 0) { |
| 79 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: no AX.25 ports configured\n"); |
| 80 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 81 | } |
| 82 | |
| 83 | if (argv[2][0] != 'a' && argv[2][0] != 'd' && argv[2][0] != 'l') { |
| 84 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: invalid operation %s\n", argv[2]); |
| 85 | closecxx . . $ close(7864480464b09eea).(s); |
| 86 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 87 | } |
| 88 | |
| 89 | if (argv[2][0] == 'l') { |
| 90 | fn = fopencxx . . $ fopen(82ec0787cd37e0a3).(PROC_RS_NODES_FILEcxx . . $ `pathnames.h:27:9`!, "r"); |
| 91 | if (fn == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 92 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"rsparms: Couldn't open %s file\n",PROC_RS_NODES_FILEcxx . . $ `pathnames.h:27:9`!); |
| 93 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 94 | } |
| 95 | |
| 96 | while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(buff,80,fn)) { |
| 97 | args=sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(buff,"%10s %4s %*s %9s %9s %9s",address, rmask, neigh1, neigh2, neigh3); |
| 98 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(address,"address")==0) |
| 99 | continue; |
| 100 | |
| 101 | if (args>2) { |
| 102 | printfcxx . . $ printf(581fddd72a8db8fc).("%10s/%4s -> ",address,rmask); |
| 103 | printnbcxx . . $ printnb(fda57c8427c60377).(neigh1); |
| 104 | putcharcxx . . $ putchar(7864480464b09eea).('\n'); |
| 105 | } |
| 106 | if (args>3) { |
| 107 | printfcxx . . $ printf(581fddd72a8db8fc).("%15s -> ",""); |
| 108 | printnbcxx . . $ printnb(fda57c8427c60377).(neigh2); |
| 109 | putcharcxx . . $ putchar(7864480464b09eea).('\n'); |
| 110 | } |
| 111 | if (args>4) { |
| 112 | printfcxx . . $ printf(581fddd72a8db8fc).("%15s -> ",""); |
| 113 | printnbcxx . . $ printnb(fda57c8427c60377).(neigh3); |
| 114 | putcharcxx . . $ putchar(7864480464b09eea).('\n'); |
| 115 | } |
| 116 | } |
| 117 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 118 | } |
| 119 | |
| 120 | if (argc < 6) { |
| 121 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s", nodes_usagecxx . . $ nodes_usage.); |
| 122 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 123 | } |
| 124 | |
| 125 | if ((mask = strchrcxx . . $ strchr(2050848944e00d54).(argv[3], '/')) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 126 | *mask = '\0'; |
| 127 | mask++; |
| 128 | |
| 129 | if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(mask, "%hu", &rs_node.maskcxx . . $ rose_route_struct#mask.) != 1) { |
| 130 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: no mask supplied!\n"); |
| 131 | closecxx . . $ close(7864480464b09eea).(s); |
| 132 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 133 | } |
| 134 | |
| 135 | if (rs_node.maskcxx . . $ rose_route_struct#mask. > 10) { |
| 136 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: invalid mask size: %s\n", mask);; |
| 137 | closecxx . . $ close(7864480464b09eea).(s); |
| 138 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 139 | } |
| 140 | } else { |
| 141 | rs_node.maskcxx . . $ rose_route_struct#mask. = 10; |
| 142 | } |
| 143 | |
| 144 | /* Make all non significant digits equal to zero */ |
| 145 | strcpycxx . . $ strcpy(b7b3a83273496486).(nodeaddr, argv[3]); |
| 146 | |
| 147 | for (i = rs_node.maskcxx . . $ rose_route_struct#mask.; i < 10; i++) |
| 148 | nodeaddr[i] = '0'; |
| 149 | |
| 150 | nodeaddr[i] = '\0'; |
| 151 | |
| 152 | if (rose_atoncxx . . $ rose_aton(2f051e3560ff300f).(nodeaddr, rs_node.addresscxx . . $ rose_route_struct#address..rose_addrcxx . . $ $anonymous_type_5dce1781888849ce_0#rose_addr.) != 0) { |
| 153 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: invalid address %s\n", nodeaddr); |
| 154 | closecxx . . $ close(7864480464b09eea).(s); |
| 155 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 156 | } |
| 157 | |
| 158 | dev = ax25_config_get_devcxx . . $ ax25_config_get_dev(7a9722d75b371431).(argv[4]); |
| 159 | if (dev == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 160 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: invalid port name - %s\n", argv[4]); |
| 161 | closecxx . . $ close(7864480464b09eea).(s); |
| 162 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 163 | } |
| 164 | |
| 165 | strcpycxx . . $ strcpy(b7b3a83273496486).(rs_node.devicecxx . . $ rose_route_struct#device., dev); |
| 166 | |
| 167 | if (ax25_aton_entrycxx . . $ ax25_aton_entry(2f051e3560ff300f).(argv[5], rs_node.neighbourcxx . . $ rose_route_struct#neighbour..ax25_callcxx . . $ $anonymous_type_a9c4e75d34810e13_0#ax25_call.) != 0) { |
| 168 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: invalid callsign %s\n", argv[5]); |
| 169 | closecxx . . $ close(7864480464b09eea).(s); |
| 170 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 171 | } |
| 172 | |
| 173 | for (i = 6, n = 0; i < argc && n < AX25_MAX_DIGIScxx . . $ `<external>/4484543697214945496/ax25.h:66:9`!; i++, n++) { |
| 174 | if (ax25_aton_entrycxx . . $ ax25_aton_entry(2f051e3560ff300f).(argv[i], rs_node.digipeaterscxx . . $ rose_route_struct#digipeaters.[n].ax25_callcxx . . $ $anonymous_type_a9c4e75d34810e13_0#ax25_call.) != 0) { |
| 175 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: nodes: invalid callsign %s\n", argv[i]); |
| 176 | closecxx . . $ close(7864480464b09eea).(s); |
| 177 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | rs_node.ndigiscxx . . $ rose_route_struct#ndigis. = n; |
| 182 | |
| 183 | if (argv[2][0] == 'a') { |
| 184 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(s, SIOCADDRTcxx . . $ `<external>/13324550044150506404/sockios.h:52:9`!, &rs_node) == -1) { |
| 185 | perrorcxx . . $ perror(85c52e162fed56f9).("rsparms: SIOCADDRT"); |
| 186 | closecxx . . $ close(7864480464b09eea).(s); |
| 187 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 188 | } |
| 189 | } else { |
| 190 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(s, SIOCDELRTcxx . . $ `<external>/13324550044150506404/sockios.h:53:9`!, &rs_node) == -1) { |
| 191 | perrorcxx . . $ perror(85c52e162fed56f9).("rsparms: SIOCDELRT"); |
| 192 | closecxx . . $ close(7864480464b09eea).(s); |
| 193 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 202 | { |
| 203 | ax25_addresscxx . . $ ax25_address# rose_call; |
| 204 | int s = 0; |
| 205 | |
| 206 | if (argc == 1) { |
| 207 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: rsparms -call|-nodes|-version ...\n"); |
| 208 | return 1; |
| 209 | } |
| 210 | |
| 211 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(argv[1], "-v", 2) == 0) { |
| 212 | printfcxx . . $ printf(581fddd72a8db8fc).("rsparms: %s\n", FULL_VERcxx . . $ `scm-version.h:6:9`!); |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(argv[1], "-c", 2) == 0) { |
| 217 | if (argc < 3) { |
| 218 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: rsparms -call <callsign>|none\n"); |
| 219 | return 1; |
| 220 | } |
| 221 | |
| 222 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[2], "none") != 0) { |
| 223 | if (ax25_aton_entrycxx . . $ ax25_aton_entry(2f051e3560ff300f).(argv[2], rose_call.ax25_callcxx . . $ $anonymous_type_a9c4e75d34810e13_0#ax25_call.) == -1) { |
| 224 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "rsparms: invalid callsign %s\n", argv[2]); |
| 225 | return 1; |
| 226 | } |
| 227 | } else { |
| 228 | rose_call = null_ax25_addresscxx . . $ null_ax25_address.; |
| 229 | } |
| 230 | |
| 231 | s = socketcxx . . $ socket(2326284602b0bb2d).(AF_ROSEcxx . . $ `<external>/8962547315054503424/socket.h:106:9`!, SOCK_SEQPACKETcxx . . $ `<external>/5956532346368192945/socket_type.h:38:9`!, 0); |
| 232 | if (s < 0) { |
| 233 | perrorcxx . . $ perror(85c52e162fed56f9).("rsparms: socket"); |
| 234 | return 1; |
| 235 | } |
| 236 | |
| 237 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(s, SIOCRSL2CALLcxx . . $ `<external>/13060138072867289166/rose.h:48:9`!, &rose_call) == -1) { |
| 238 | perrorcxx . . $ perror(85c52e162fed56f9).("rsparms: ioctl"); |
| 239 | closecxx . . $ close(7864480464b09eea).(s); |
| 240 | return 1; |
| 241 | } |
| 242 | |
| 243 | closecxx . . $ close(7864480464b09eea).(s); |
| 244 | |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(argv[1], "-n", 2) == 0) { |
| 249 | |
| 250 | s = socketcxx . . $ socket(2326284602b0bb2d).(AF_ROSEcxx . . $ `<external>/8962547315054503424/socket.h:106:9`!, SOCK_SEQPACKETcxx . . $ `<external>/5956532346368192945/socket_type.h:38:9`!, 0); |
| 251 | if (s < 0) { |
| 252 | perrorcxx . . $ perror(85c52e162fed56f9).("rsparms: socket"); |
| 253 | return 1; |
| 254 | } |
| 255 | nodescxx . . $ nodes(8d5b198710c10580).(s, argc, argv); |
| 256 | closecxx . . $ close(7864480464b09eea).(s); |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: rsparms -call|-nodes|-version ...\n"); |
| 261 | |
| 262 | closecxx . . $ close(7864480464b09eea).(s); |
| 263 | |
| 264 | return 1; |
| 265 | } |