| 1 | #cxx . . $ `<file>/kiss/kissattach.c`/include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | #include <unistd.h> |
| 5 | #include <termios.h> |
| 6 | #include <fcntl.h> |
| 7 | #include <signal.h> |
| 8 | #include <ctype.h> |
| 9 | #include <netdb.h> |
| 10 | #include <syslog.h> |
| 11 | #include <errno.h> |
| 12 | |
| 13 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 14 | #include <scm-version.h>cxx . . $ `<file>/scm-version.h`/ |
| 15 | |
| 16 | #include <sys/types.h> |
| 17 | #include <sys/stat.h> |
| 18 | #include <sys/socket.h> |
| 19 | #include <sys/ioctl.h> |
| 20 | |
| 21 | #include <net/if.h> |
| 22 | #include <netax25/ax25.h> |
| 23 | #include <netrose/rose.h> |
| 24 | |
| 25 | #include <netax25/daemon.h> |
| 26 | #include <netax25/axlib.h> |
| 27 | #include <netax25/ttyutils.h> |
| 28 | |
| 29 | #include "../pathnames.h"cxx . . $ `<file>/pathnames.h`/ |
| 30 | |
| 31 | #ifndef N_6PACKcxx . . $ `<external>/2577046224257520258/ioctl-types.h:58:9`! |
| 32 | #define N_6PACK 7 /* This is valid for all architectures in 2.2.x */ |
| 33 | #endif |
| 34 | |
| 35 | static char *callsigncxx . . $ callsign.; |
| 36 | static int speedcxx . . $ speed.; |
| 37 | static int mtucxx . . $ mtu.; |
| 38 | static int loggingcxx . . $ logging. = FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 39 | static char *prognamecxx . . $ progname.; |
| 40 | static char *kttynamecxx . . $ kttyname.; |
| 41 | static char *portnamecxx . . $ portname.; |
| 42 | static char *inetaddrcxx . . $ inetaddr.; |
| 43 | static int allow_broadcastcxx . . $ allow_broadcast.; |
| 44 | static int i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master.; /* unix98 ptmx support */ |
| 45 | |
| 46 | static char *kiss_basenamecxx . . $ kiss_basename(7a9722d75b371431).(char *s) |
| 47 | { |
| 48 | char *p = strrchrcxx . . $ strrchr(2050848944e00d54).(s, '/'); |
| 49 | return p ? p + 1 : s; |
| 50 | } |
| 51 | |
| 52 | static void terminatecxx . . $ terminate(d4f767463ce0a6b3).(int sig) |
| 53 | { |
| 54 | if (loggingcxx . . $ logging.) { |
| 55 | syslogcxx . . $ syslog(afcfcee7634adf7d).(LOG_INFOcxx . . $ `<external>/6168640806541382331/syslog.h:57:9`!, "terminating on SIGTERM\n"); |
| 56 | closelogcxx . . $ closelog(49f6e7a06ebc5aa8).(); |
| 57 | } |
| 58 | |
| 59 | if (!i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master.) |
| 60 | tty_unlockcxx . . $ tty_unlock(1ef8e6ec083aabb9).(kttynamecxx . . $ kttyname.); |
| 61 | |
| 62 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 63 | } |
| 64 | |
| 65 | static int readconfigcxx . . $ readconfig(1ef8e6ec083aabb9).(char *port) |
| 66 | { |
| 67 | FILEcxx . . $ FILE# *fp; |
| 68 | char buffer[90], *s; |
| 69 | int n = 0; |
| 70 | |
| 71 | fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(CONF_AXPORTS_FILEcxx . . $ `pathnames.h:3:9`!, "r"); |
| 72 | if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 73 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: cannot open axports file %s\n", |
| 74 | prognamecxx . . $ progname., CONF_AXPORTS_FILEcxx . . $ `pathnames.h:3:9`!); |
| 75 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 76 | } |
| 77 | |
| 78 | while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(buffer, 90, fp) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 79 | n++; |
| 80 | |
| 81 | s = strchrcxx . . $ strchr(2050848944e00d54).(buffer, '\n'); |
| 82 | if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 83 | *s = '\0'; |
| 84 | |
| 85 | if (*buffer == 0 || *buffer == '#') |
| 86 | continue; |
| 87 | |
| 88 | s = strtokcxx . . $ strtok(b7b3a83273496486).(buffer, " \t\r\n"); |
| 89 | if (s == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 90 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unable to parse line %d of the axports file\n", prognamecxx . . $ progname., n); |
| 91 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 92 | } |
| 93 | |
| 94 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(s, port) != 0) |
| 95 | continue; |
| 96 | |
| 97 | s = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, " \t\r\n"); |
| 98 | if (s == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 99 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unable to parse line %d of the axports file\n", prognamecxx . . $ progname., n); |
| 100 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 101 | } |
| 102 | |
| 103 | callsigncxx . . $ callsign. = strdupcxx . . $ strdup(a8b8e32347182212).(s); |
| 104 | |
| 105 | s = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, " \t\r\n"); |
| 106 | if (s == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 107 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unable to parse line %d of the axports file\n", prognamecxx . . $ progname., n); |
| 108 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 109 | } |
| 110 | |
| 111 | speedcxx . . $ speed. = atoicxx . . $ atoi(5c4306d8553b3696).(s); |
| 112 | |
| 113 | s = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, " \t\r\n"); |
| 114 | if (s == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 115 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unable to parse line %d of the axports file\n", prognamecxx . . $ progname., n); |
| 116 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 117 | } |
| 118 | |
| 119 | if (mtucxx . . $ mtu. == 0) { |
| 120 | mtucxx . . $ mtu. = atoicxx . . $ atoi(5c4306d8553b3696).(s); |
| 121 | if (mtucxx . . $ mtu. <= 0) { |
| 122 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: invalid paclen setting\n", prognamecxx . . $ progname.); |
| 123 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 128 | |
| 129 | return TRUEcxx . . $ `<external>/7610632489885431094/daemon.h:27:9`!; |
| 130 | } |
| 131 | |
| 132 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 133 | |
| 134 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: cannot find port %s in axports\n", prognamecxx . . $ progname., port); |
| 135 | |
| 136 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | static int setifcallcxx . . $ setifcall(3c8082c546dd2ea0).(int fd, char *name) |
| 141 | { |
| 142 | char call[7]; |
| 143 | |
| 144 | if (ax25_aton_entrycxx . . $ ax25_aton_entry(2f051e3560ff300f).(name, call) == -1) |
| 145 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 146 | |
| 147 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCSIFHWADDRcxx . . $ `<external>/13324550044150506404/sockios.h:77:9`!, call) != 0) { |
| 148 | closecxx . . $ close(7864480464b09eea).(fd); |
| 149 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 150 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCSIFHWADDR"); |
| 151 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 152 | } |
| 153 | |
| 154 | return TRUEcxx . . $ `<external>/7610632489885431094/daemon.h:27:9`!; |
| 155 | } |
| 156 | |
| 157 | |
| 158 | static int startifacecxx . . $ startiface(a341ed1111783abc).(char *dev, struct hostentcxx . . $ hostent# *hp) |
| 159 | { |
| 160 | struct ifreqcxx . . $ ifreq# ifr; |
| 161 | int fd; |
| 162 | |
| 163 | fd = socketcxx . . $ socket(2326284602b0bb2d).(AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!, SOCK_DGRAMcxx . . $ `<external>/5956532346368192945/socket_type.h:31:9`!, 0); |
| 164 | if (fd < 0) { |
| 165 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 166 | perrorcxx . . $ perror(85c52e162fed56f9).("socket"); |
| 167 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 168 | } |
| 169 | |
| 170 | strcpycxx . . $ strcpy(b7b3a83273496486).(ifr.ifr_namecxx . . $ `<external>/2638090476884991293/if.h:151:10`!, dev); |
| 171 | |
| 172 | if (hp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 173 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_familycxx . . $ sockaddr#sa_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 174 | |
| 175 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[0] = 0; |
| 176 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[1] = 0; |
| 177 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[2] = hp->h_addr_listcxx . . $ hostent#h_addr_list.[0][0]; |
| 178 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[3] = hp->h_addr_listcxx . . $ hostent#h_addr_list.[0][1]; |
| 179 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[4] = hp->h_addr_listcxx . . $ hostent#h_addr_list.[0][2]; |
| 180 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[5] = hp->h_addr_listcxx . . $ hostent#h_addr_list.[0][3]; |
| 181 | ifr.ifr_addrcxx . . $ `<external>/2638090476884991293/if.h:153:10`!.sa_datacxx . . $ sockaddr#sa_data.[6] = 0; |
| 182 | |
| 183 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCSIFADDRcxx . . $ `<external>/13324550044150506404/sockios.h:63:9`!, &ifr) < 0) { |
| 184 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 185 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCSIFADDR"); |
| 186 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | ifr.ifr_mtucxx . . $ `<external>/2638090476884991293/if.h:159:10`! = mtucxx . . $ mtu.; |
| 191 | |
| 192 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCSIFMTUcxx . . $ `<external>/13324550044150506404/sockios.h:75:9`!, &ifr) < 0) { |
| 193 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 194 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCSIFMTU"); |
| 195 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 196 | } |
| 197 | |
| 198 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCGIFFLAGScxx . . $ `<external>/13324550044150506404/sockios.h:60:9`!, &ifr) < 0) { |
| 199 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 200 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCGIFFLAGS"); |
| 201 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 202 | } |
| 203 | |
| 204 | ifr.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`! &= IFF_NOARPcxx . . $ `<external>/2638090476884991293/if.h:59:10`!; |
| 205 | ifr.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`! |= IFF_UPcxx . . $ `<external>/2638090476884991293/if.h:45:10`!; |
| 206 | ifr.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`! |= IFF_RUNNINGcxx . . $ `<external>/2638090476884991293/if.h:57:10`!; |
| 207 | if (allow_broadcastcxx . . $ allow_broadcast.) |
| 208 | ifr.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`! |= IFF_BROADCASTcxx . . $ `<external>/2638090476884991293/if.h:47:10`!; /* samba broadcasts are a pain.. */ |
| 209 | else |
| 210 | ifr.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`! &= ~(IFF_BROADCASTcxx . . $ `<external>/2638090476884991293/if.h:47:10`!); /* samba broadcasts are a pain.. */ |
| 211 | |
| 212 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCSIFFLAGScxx . . $ `<external>/13324550044150506404/sockios.h:61:9`!, &ifr) < 0) { |
| 213 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 214 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCSIFFLAGS"); |
| 215 | return FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!; |
| 216 | } |
| 217 | |
| 218 | closecxx . . $ close(7864480464b09eea).(fd); |
| 219 | |
| 220 | return TRUEcxx . . $ `<external>/7610632489885431094/daemon.h:27:9`!; |
| 221 | } |
| 222 | |
| 223 | static void usagecxx . . $ usage(49f6e7a06ebc5aa8).(void) |
| 224 | { |
| 225 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-b] [-l] [-m mtu] [-v] tty port [inetaddr]\n", prognamecxx . . $ progname.); |
| 226 | } |
| 227 | |
| 228 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 229 | { |
| 230 | int fd; |
| 231 | int disc = N_AX25cxx . . $ `<external>/2577046224257520258/ioctl-types.h:56:9`!; |
| 232 | char dev[64]; |
| 233 | int v = 4; |
| 234 | char *namepts = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* name of the unix98 pts slave, which |
| 235 | * the client has to use */ |
| 236 | struct hostentcxx . . $ hostent# *hp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 237 | |
| 238 | prognamecxx . . $ progname. = kiss_basenamecxx . . $ kiss_basename(7a9722d75b371431).(argv[0]); |
| 239 | |
| 240 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prognamecxx . . $ progname., "spattach")) |
| 241 | disc = N_6PACKcxx . . $ `<external>/2577046224257520258/ioctl-types.h:58:9`!; |
| 242 | |
| 243 | while ((fd = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, "b6i:lm:v")) != -1) { |
| 244 | switch (fd) { |
| 245 | case '6': |
| 246 | disc = N_6PACKcxx . . $ `<external>/2577046224257520258/ioctl-types.h:58:9`!; |
| 247 | break; |
| 248 | case 'b': |
| 249 | allow_broadcastcxx . . $ allow_broadcast. = 1; |
| 250 | break; |
| 251 | case 'i': |
| 252 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: -i flag depreciated, use new command line format instead.\n", prognamecxx . . $ progname.); |
| 253 | inetaddrcxx . . $ inetaddr. = optargcxx . . $ optarg.; |
| 254 | break; |
| 255 | case 'l': |
| 256 | loggingcxx . . $ logging. = TRUEcxx . . $ `<external>/7610632489885431094/daemon.h:27:9`!; |
| 257 | break; |
| 258 | case 'm': |
| 259 | mtucxx . . $ mtu. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 260 | if (mtucxx . . $ mtu. <= 0) { |
| 261 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: invalid mtu size - %s\n", prognamecxx . . $ progname., optargcxx . . $ optarg.); |
| 262 | return 1; |
| 263 | } |
| 264 | break; |
| 265 | case 'v': |
| 266 | printfcxx . . $ printf(581fddd72a8db8fc).("%s: %s\n", prognamecxx . . $ progname., FULL_VERcxx . . $ `scm-version.h:6:9`!); |
| 267 | return 0; |
| 268 | case ':': |
| 269 | case '?': |
| 270 | usagecxx . . $ usage(49f6e7a06ebc5aa8).(); |
| 271 | return 1; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | #ifdef notdef |
| 276 | if ((argc - optind) != 3 && ((argc - optind) != 2 || !inetaddr)) { |
| 277 | #else |
| 278 | if ((argc - optindcxx . . $ optind.) < 2) { |
| 279 | #endif |
| 280 | usagecxx . . $ usage(49f6e7a06ebc5aa8).(); |
| 281 | return 1; |
| 282 | } |
| 283 | |
| 284 | kttynamecxx . . $ kttyname. = argv[optindcxx . . $ optind.++]; |
| 285 | portnamecxx . . $ portname. = argv[optindcxx . . $ optind.++]; |
| 286 | |
| 287 | if (argc-1 >= optindcxx . . $ optind. && !inetaddrcxx . . $ inetaddr.) |
| 288 | inetaddrcxx . . $ inetaddr. = argv[optindcxx . . $ optind.]; |
| 289 | |
| 290 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("/dev/ptmx", kttynamecxx . . $ kttyname.)) |
| 291 | i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master. = 1; |
| 292 | |
| 293 | if (!i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master.) { |
| 294 | if (tty_is_lockedcxx . . $ tty_is_locked(1ef8e6ec083aabb9).(kttynamecxx . . $ kttyname.)) { |
| 295 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: device %s already in use\n", prognamecxx . . $ progname., kttynamecxx . . $ kttyname.); |
| 296 | return 1; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | if (!readconfigcxx . . $ readconfig(1ef8e6ec083aabb9).(portnamecxx . . $ portname.)) |
| 301 | return 1; |
| 302 | |
| 303 | if (inetaddrcxx . . $ inetaddr. && (hp = gethostbynamecxx . . $ gethostbyname(69056c040771b155).(inetaddrcxx . . $ inetaddr.)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 304 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: invalid internet name/address - %s\n", prognamecxx . . $ progname., inetaddrcxx . . $ inetaddr.); |
| 305 | return 1; |
| 306 | } |
| 307 | |
| 308 | fd = opencxx . . $ open(e156e3aa1e5c4ad1).(kttynamecxx . . $ kttyname., O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`! | O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!); |
| 309 | if (fd == -1) { |
| 310 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!) { |
| 311 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Cannot find serial device %s, no such file or directory.\n", prognamecxx . . $ progname., kttynamecxx . . $ kttyname.); |
| 312 | } else { |
| 313 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: %s: ", prognamecxx . . $ progname., kttynamecxx . . $ kttyname.); |
| 314 | perrorcxx . . $ perror(85c52e162fed56f9).("open"); |
| 315 | } |
| 316 | return 1; |
| 317 | } |
| 318 | |
| 319 | if (i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master.) { |
| 320 | /* get name of pts-device */ |
| 321 | namepts = ptsnamecxx . . $ ptsname(ff224f080444ee45).(fd); |
| 322 | if (namepts == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 323 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Cannot get name of pts-device.\n", prognamecxx . . $ progname.); |
| 324 | return 1; |
| 325 | } |
| 326 | /* unlock pts-device */ |
| 327 | if (unlockptcxx . . $ unlockpt(7864480464b09eea).(fd) == -1) { |
| 328 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Cannot unlock pts-device %s\n", prognamecxx . . $ progname., namepts); |
| 329 | return 1; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | if (speedcxx . . $ speed. != 0 && !tty_speedcxx . . $ tty_speed(9b79fb6aee4c0440).(fd, speedcxx . . $ speed.)) |
| 334 | return 1; |
| 335 | |
| 336 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, TIOCSETDcxx . . $ `<external>/123502480044527469/ioctls.h:55:9`!, &disc) == -1) { |
| 337 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error setting line discipline: ", prognamecxx . . $ progname.); |
| 338 | perrorcxx . . $ perror(85c52e162fed56f9).("TIOCSETD"); |
| 339 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Are you sure you have enabled %s support in the kernel\n", |
| 340 | disc == N_AX25cxx . . $ `<external>/2577046224257520258/ioctl-types.h:56:9`! ? "MKISS" : "6PACK"); |
| 341 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "or, if you made it a module, that the module is loaded?\n"); |
| 342 | return 1; |
| 343 | } |
| 344 | |
| 345 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCGIFNAMEcxx . . $ `<external>/13324550044150506404/sockios.h:57:9`!, dev) == -1) { |
| 346 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 347 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCGIFNAME"); |
| 348 | return 1; |
| 349 | } |
| 350 | |
| 351 | if (!setifcallcxx . . $ setifcall(3c8082c546dd2ea0).(fd, callsigncxx . . $ callsign.)) |
| 352 | return 1; |
| 353 | |
| 354 | /* Now set the encapsulation */ |
| 355 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, SIOCSIFENCAPcxx . . $ `<external>/13324550044150506404/sockios.h:79:9`!, &v) == -1) { |
| 356 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: ", prognamecxx . . $ progname.); |
| 357 | perrorcxx . . $ perror(85c52e162fed56f9).("SIOCSIFENCAP"); |
| 358 | return 1; |
| 359 | } |
| 360 | |
| 361 | /* ax25 ifaces should not really need to have an IP address assigned to */ |
| 362 | if (!startifacecxx . . $ startiface(a341ed1111783abc).(dev, hp)) |
| 363 | return 1; |
| 364 | |
| 365 | printfcxx . . $ printf(581fddd72a8db8fc).("AX.25 port %s bound to device %s\n", portnamecxx . . $ portname., dev); |
| 366 | if (i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master.) { |
| 367 | /* Users await the slave pty to be referenced in the 3d line */ |
| 368 | printfcxx . . $ printf(581fddd72a8db8fc).("Awaiting client connects on\n%s\n", namepts); |
| 369 | } |
| 370 | if (loggingcxx . . $ logging.) { |
| 371 | openlogcxx . . $ openlog(7b85637613228108).(prognamecxx . . $ progname., LOG_PIDcxx . . $ `<external>/6168640806541382331/syslog.h:162:9`!, LOG_DAEMONcxx . . $ `<external>/6168640806541382331/syslog.h:96:9`!); |
| 372 | syslogcxx . . $ syslog(afcfcee7634adf7d).(LOG_INFOcxx . . $ `<external>/6168640806541382331/syslog.h:57:9`!, "AX.25 port %s bound to device %s%s%s\n", portnamecxx . . $ portname., dev, (i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master. ? " with slave pty " : ""), (i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master. ? namepts : "")); |
| 373 | |
| 374 | } |
| 375 | |
| 376 | signalcxx . . $ signal(c2d516773f91faf8).(SIGHUPcxx . . $ `<external>/11773118241360591791/signum-generic.h:56:9`!, SIG_IGNcxx . . $ `<external>/11773118241360591791/signum-generic.h:30:9`!); |
| 377 | signalcxx . . $ signal(c2d516773f91faf8).(SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, terminatecxx . . $ terminate(d4f767463ce0a6b3).); |
| 378 | |
| 379 | /* |
| 380 | * Become a daemon if we can. |
| 381 | */ |
| 382 | if (!daemon_startcxx . . $ daemon_start(7864480464b09eea).(FALSEcxx . . $ `<external>/7610632489885431094/daemon.h:31:9`!)) { |
| 383 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: cannot become a daemon\n", prognamecxx . . $ progname.); |
| 384 | return 1; |
| 385 | } |
| 386 | if (!i_am_unix98_pty_mastercxx . . $ i_am_unix98_pty_master.) { |
| 387 | if (!tty_lockcxx . . $ tty_lock(1ef8e6ec083aabb9).(kttynamecxx . . $ kttyname.)) |
| 388 | return 1; |
| 389 | } |
| 390 | |
| 391 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 392 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 393 | closecxx . . $ close(7864480464b09eea).(0); |
| 394 | closecxx . . $ close(7864480464b09eea).(1); |
| 395 | closecxx . . $ close(7864480464b09eea).(2); |
| 396 | |
| 397 | while (1) |
| 398 | sleepcxx . . $ sleep(2141b656ce2cc063).(10000); |
| 399 | |
| 400 | /* NOT REACHED */ |
| 401 | return 0; |
| 402 | } |