| 1 | /*****************************************************************************/cxx . . $ `<file>/hdlcutil/hdrvcomm.c`/ |
| 2 | |
| 3 | /* |
| 4 | * hdrvcomm.c -- HDLC driver communications. |
| 5 | * |
| 6 | * Copyright (C) 1996-1998 Thomas Sailer ([email protected]) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
| 21 | * 02110-1301, USA. |
| 22 | * |
| 23 | * Please note that the GPL allows you to use the driver, NOT the radio. |
| 24 | * In order to use the radio, you need a license from the communications |
| 25 | * authority of your country. |
| 26 | * |
| 27 | * |
| 28 | * History: |
| 29 | * 0.1 10.05.97 Started |
| 30 | * 0.2 14.04.98 Tried to implement AF_PACKET |
| 31 | */ |
| 32 | |
| 33 | /*****************************************************************************/ |
| 34 | |
| 35 | #include <stdio.h> |
| 36 | #include <string.h> |
| 37 | #include <signal.h> |
| 38 | #include <errno.h> |
| 39 | #include <sys/ioctl.h> |
| 40 | #include <sys/types.h> |
| 41 | #include <sys/ipc.h> |
| 42 | #include <sys/msg.h> |
| 43 | #include <endian.h> |
| 44 | #include <netinet/in.h> |
| 45 | #include <fcntl.h> |
| 46 | #include <unistd.h> |
| 47 | #include <stdlib.h> |
| 48 | #include <net/if.h> |
| 49 | #include "hdrvcomm.h"cxx . . $ `<file>/hdlcutil/hdrvcomm.h`/ |
| 50 | #include "usersmdiag.h"cxx . . $ `<file>/hdlcutil/usersmdiag.h`/ |
| 51 | #include <net/if_arp.h> |
| 52 | |
| 53 | #include <net/ethernet.h> |
| 54 | |
| 55 | #include <linux/if_packet.h> |
| 56 | #ifndef SOL_PACKETcxx . . $ `<external>/8962547315054503424/socket.h:151:9`! |
| 57 | #define SOL_PACKET 263 |
| 58 | #endif |
| 59 | |
| 60 | /* ---------------------------------------------------------------------- */ |
| 61 | |
| 62 | static const char *if_namecxx . . $ if_name. = "bcsf0"; |
| 63 | static char *prg_namecxx . . $ prg_name.; |
| 64 | static int fdcxx . . $ fd. = -1; |
| 65 | static struct ifreqcxx . . $ ifreq# ifr_hcxx . . $ ifr_h.; |
| 66 | static int promisccxx . . $ promisc.; |
| 67 | static int afpacketcxx . . $ afpacket. = 1; |
| 68 | static int msqidcxx . . $ msqid. = -1; |
| 69 | |
| 70 | /* ---------------------------------------------------------------------- */ |
| 71 | |
| 72 | static void terminatecxx . . $ terminate(49f6e7a06ebc5aa8).(void) |
| 73 | { |
| 74 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCSIFFLAGScxx . . $ `<external>/13324550044150506404/sockios.h:61:9`!, &ifr_hcxx . . $ ifr_h.) < 0) { |
| 75 | perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (SIOCSIFFLAGS)"); |
| 76 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 77 | } |
| 78 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 79 | } |
| 80 | |
| 81 | /* ---------------------------------------------------------------------- */ |
| 82 | |
| 83 | static void terminate_sigcxx . . $ terminate_sig(d4f767463ce0a6b3).(int signal) |
| 84 | { |
| 85 | printfcxx . . $ printf(581fddd72a8db8fc).("signal %i caught\n", signal); |
| 86 | terminatecxx . . $ terminate(49f6e7a06ebc5aa8).(); |
| 87 | } |
| 88 | |
| 89 | /* ---------------------------------------------------------------------- */ |
| 90 | |
| 91 | int hdrvc_recvpacketcxx . . $ hdrvc_recvpacket(6abd07ddb1a912f0).(char *pkt, int maxlen) |
| 92 | { |
| 93 | struct ifreqcxx . . $ ifreq# ifr_new; |
| 94 | struct sockaddr_llcxx . . $ sockaddr_ll# from; |
| 95 | socklen_tcxx . . $ socklen_t# from_len = sizeof(from); |
| 96 | |
| 97 | if (!promisccxx . . $ promisc.) { |
| 98 | if (afpacketcxx . . $ afpacket.) { |
| 99 | struct sockaddr_llcxx . . $ sockaddr_ll# sll; |
| 100 | struct packet_mreqcxx . . $ packet_mreq# mr; |
| 101 | |
| 102 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&sll, 0, sizeof(sll)); |
| 103 | sll.sll_familycxx . . $ sockaddr_ll#sll_family. = AF_PACKETcxx . . $ `<external>/8962547315054503424/socket.h:113:9`!; |
| 104 | sll.sll_ifindexcxx . . $ sockaddr_ll#sll_ifindex. = ifr_hcxx . . $ ifr_h..ifr_ifindexcxx . . $ `<external>/2638090476884991293/if.h:163:10`!; |
| 105 | sll.sll_protocolcxx . . $ sockaddr_ll#sll_protocol. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(ETH_P_AX25cxx . . $ `<external>/15209105680615352250/if_ether.h:135:9`!); |
| 106 | if (bindcxx . . $ bind(f39c6c650450bfdd).(fdcxx . . $ fd., (struct sockaddrcxx . . $ sockaddr# *)&sll, sizeof(sll)) < 0) { |
| 107 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, |
| 108 | "%s: Error %s (%i) bind failed\n", |
| 109 | prg_namecxx . . $ prg_name., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 110 | exitcxx . . $ exit(3ca292c338df9bb3).(-2); |
| 111 | } |
| 112 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&mr, 0, sizeof(mr)); |
| 113 | mr.mr_ifindexcxx . . $ packet_mreq#mr_ifindex. = sll.sll_ifindexcxx . . $ sockaddr_ll#sll_ifindex.; |
| 114 | mr.mr_typecxx . . $ packet_mreq#mr_type. = PACKET_MR_PROMISCcxx . . $ `<external>/16655405989546975727/if_packet.h:316:9`!; |
| 115 | if (setsockoptcxx . . $ setsockopt(506cc1d0fc70fdf1).(fdcxx . . $ fd., SOL_PACKETcxx . . $ `<external>/8962547315054503424/socket.h:151:9`!, PACKET_ADD_MEMBERSHIPcxx . . $ `<external>/16655405989546975727/if_packet.h:39:9`!, (char *)&mr, sizeof(mr)) < 0) { |
| 116 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, |
| 117 | "%s: Error %s (%i) setsockopt SOL_PACKET, PACKET_ADD_MEMBERSHIP failed\n", |
| 118 | prg_namecxx . . $ prg_name., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 119 | exitcxx . . $ exit(3ca292c338df9bb3).(-2); |
| 120 | } |
| 121 | } else { |
| 122 | struct sockaddrcxx . . $ sockaddr# sa; |
| 123 | |
| 124 | strcpycxx . . $ strcpy(b7b3a83273496486).(sa.sa_datacxx . . $ sockaddr#sa_data., if_namecxx . . $ if_name.); |
| 125 | sa.sa_familycxx . . $ sockaddr#sa_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 126 | if (bindcxx . . $ bind(f39c6c650450bfdd).(fdcxx . . $ fd., &sa, sizeof(sa)) < 0) { |
| 127 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, |
| 128 | "%s: Error %s (%i) bind failed\n", |
| 129 | prg_namecxx . . $ prg_name., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 130 | exitcxx . . $ exit(3ca292c338df9bb3).(-2); |
| 131 | } |
| 132 | ifr_new = ifr_hcxx . . $ ifr_h.; |
| 133 | ifr_new.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`! |= IFF_PROMISCcxx . . $ `<external>/2638090476884991293/if.h:61:10`!; |
| 134 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCSIFFLAGScxx . . $ `<external>/13324550044150506404/sockios.h:61:9`!, &ifr_new) < 0) { |
| 135 | perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (SIOCSIFFLAGS)"); |
| 136 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 137 | } |
| 138 | signalcxx . . $ signal(c2d516773f91faf8).(SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, terminate_sigcxx . . $ terminate_sig(d4f767463ce0a6b3).); |
| 139 | signalcxx . . $ signal(c2d516773f91faf8).(SIGQUITcxx . . $ `<external>/11773118241360591791/signum-generic.h:57:9`!, terminate_sigcxx . . $ terminate_sig(d4f767463ce0a6b3).); |
| 140 | if (atexitcxx . . $ atexit(8919c3b35e68c42d).((void (*)(void))terminatecxx . . $ terminate(49f6e7a06ebc5aa8).)) { |
| 141 | perrorcxx . . $ perror(85c52e162fed56f9).("atexit"); |
| 142 | terminatecxx . . $ terminate(49f6e7a06ebc5aa8).(); |
| 143 | } |
| 144 | } |
| 145 | promisccxx . . $ promisc. = 1; |
| 146 | fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(fdcxx . . $ fd., F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(fdcxx . . $ fd., F_GETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:168:9`!, 0) | O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!); |
| 147 | } |
| 148 | if (!pkt || maxlen < 2) |
| 149 | return 0; |
| 150 | return recvfromcxx . . $ recvfrom(67874f2c95950c9a).(fdcxx . . $ fd., pkt, maxlen, 0, (struct sockaddrcxx . . $ sockaddr# *)&from, &from_len); |
| 151 | return -1; |
| 152 | } |
| 153 | |
| 154 | /* ---------------------------------------------------------------------- */ |
| 155 | |
| 156 | int hdrvc_getfdcxx . . $ hdrvc_getfd(b126dc7c1de90089).(void) |
| 157 | { |
| 158 | return fdcxx . . $ fd.; |
| 159 | } |
| 160 | |
| 161 | /* ---------------------------------------------------------------------- */ |
| 162 | |
| 163 | const char *hdrvc_ifnamecxx . . $ hdrvc_ifname(33a1f659e94feb42).(void) |
| 164 | { |
| 165 | return if_namecxx . . $ if_name.; |
| 166 | } |
| 167 | |
| 168 | /* ---------------------------------------------------------------------- */ |
| 169 | |
| 170 | void hdrvc_argscxx . . $ hdrvc_args(de06760a4a38ab9).(int *argc, char *argv[], const char *def_if) |
| 171 | { |
| 172 | int ac, i; |
| 173 | |
| 174 | if (def_if) |
| 175 | if_namecxx . . $ if_name. = def_if; |
| 176 | if (!argc || !argv || (ac = *argc) < 1) |
| 177 | return; |
| 178 | prg_namecxx . . $ prg_name. = argv[0]; |
| 179 | for (i = 1; i < ac-1; i++) { |
| 180 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-i")) { |
| 181 | if_namecxx . . $ if_name. = argv[i+1]; |
| 182 | ac -= 2; |
| 183 | if (i < ac) |
| 184 | memmovecxx . . $ memmove(cc817cb175f282d).(argv+i, argv+i+2, (ac-i) * sizeof(void *)); |
| 185 | i--; |
| 186 | } |
| 187 | } |
| 188 | *argc = ac; |
| 189 | } |
| 190 | |
| 191 | /* ---------------------------------------------------------------------- */ |
| 192 | |
| 193 | void hdrvc_initcxx . . $ hdrvc_init(49f6e7a06ebc5aa8).(void) |
| 194 | { |
| 195 | key_tcxx . . $ key_t# k; |
| 196 | static struct ifreqcxx . . $ ifreq# ifr; |
| 197 | |
| 198 | strcpycxx . . $ strcpy(b7b3a83273496486).(ifr_hcxx . . $ ifr_h..ifr_namecxx . . $ `<external>/2638090476884991293/if.h:151:10`!, if_namecxx . . $ if_name.); |
| 199 | /* first try to use AF_PACKET */ |
| 200 | if ((fdcxx . . $ fd. = socketcxx . . $ socket(2326284602b0bb2d).(PF_PACKETcxx . . $ `<external>/8962547315054503424/socket.h:61:9`!, SOCK_RAWcxx . . $ `<external>/5956532346368192945/socket_type.h:33:9`!, htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(ETH_P_AX25cxx . . $ `<external>/15209105680615352250/if_ether.h:135:9`!))) < 0 |
| 201 | || ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCGIFINDEXcxx . . $ `<external>/13324550044150506404/sockios.h:85:9`!, &ifr_hcxx . . $ ifr_h.) < 0) { |
| 202 | if (fdcxx . . $ fd. >= 0) |
| 203 | closecxx . . $ close(7864480464b09eea).(fdcxx . . $ fd.); |
| 204 | afpacketcxx . . $ afpacket. = 0; |
| 205 | fdcxx . . $ fd. = socketcxx . . $ socket(2326284602b0bb2d).(PF_INETcxx . . $ `<external>/8962547315054503424/socket.h:45:9`!, SOCK_PACKETcxx . . $ `<external>/5956532346368192945/socket_type.h:44:9`!, htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(ETH_P_AX25cxx . . $ `<external>/15209105680615352250/if_ether.h:135:9`!)); |
| 206 | if (fdcxx . . $ fd. < 0) { |
| 207 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i), cannot open %s\n", |
| 208 | prg_namecxx . . $ prg_name., |
| 209 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, if_namecxx . . $ if_name.); |
| 210 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 211 | } |
| 212 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCGIFFLAGScxx . . $ `<external>/13324550044150506404/sockios.h:60:9`!, &ifr_hcxx . . $ ifr_h.) < 0) { |
| 213 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i), cannot ioctl SIOCGIFFLAGS %s\n", |
| 214 | prg_namecxx . . $ prg_name., |
| 215 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, if_namecxx . . $ if_name.); |
| 216 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 217 | } |
| 218 | } |
| 219 | strcpycxx . . $ strcpy(b7b3a83273496486).(ifr.ifr_namecxx . . $ `<external>/2638090476884991293/if.h:151:10`!, if_namecxx . . $ if_name.); |
| 220 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCGIFHWADDRcxx . . $ `<external>/13324550044150506404/sockios.h:80:9`!, &ifr) < 0 ) { |
| 221 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i), cannot ioctl SIOCGIFHWADDR %s\n", |
| 222 | prg_namecxx . . $ prg_name., |
| 223 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, if_namecxx . . $ if_name.); |
| 224 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 225 | } |
| 226 | if (ifr.ifr_hwaddrcxx . . $ `<external>/2638090476884991293/if.h:152:10`!.sa_familycxx . . $ sockaddr#sa_family. != ARPHRD_AX25cxx . . $ `<external>/9762582127268691413/if_arp.h:74:9`!) { |
| 227 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error, interface %s not AX25 (%i)\n", |
| 228 | prg_namecxx . . $ prg_name., |
| 229 | if_namecxx . . $ if_name., ifr.ifr_hwaddrcxx . . $ `<external>/2638090476884991293/if.h:152:10`!.sa_familycxx . . $ sockaddr#sa_family.); |
| 230 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 231 | } |
| 232 | return; |
| 233 | k = ftokcxx . . $ ftok(cb7559238bb26814).(if_namecxx . . $ if_name., USERSM_KEY_PROJcxx . . $ `hdlcutil/usersmdiag.h:35:9`!); |
| 234 | if (k == (key_tcxx . . $ key_t#)-1) { |
| 235 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i), cannot ftok on %s\n", prg_namecxx . . $ prg_name., |
| 236 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, if_namecxx . . $ if_name.); |
| 237 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 238 | } |
| 239 | msqidcxx . . $ msqid. = msggetcxx . . $ msgget(9b79fb6aee4c0440).(k, 0700); |
| 240 | if (msqidcxx . . $ msqid. < 0) { |
| 241 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i), cannot msgget %d\n", prg_namecxx . . $ prg_name., |
| 242 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, k); |
| 243 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | /* ---------------------------------------------------------------------- */ |
| 248 | |
| 249 | static void hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(struct usersmmsgcxx . . $ usersmmsg# *msg, int len) |
| 250 | { |
| 251 | if (msgsndcxx . . $ msgsnd(9d1ebb2cd9604347).(msqidcxx . . $ msqid., (struct msgbufcxx . . $ msgbuf# *)msg, len+sizeof(msg->hdrcxx . . $ usersmmsg#hdr.)-sizeof(long), 0) < 0) { |
| 252 | perrorcxx . . $ perror(85c52e162fed56f9).("msgsnd"); |
| 253 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | static int hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(struct usersmmsgcxx . . $ usersmmsg# *msg, int maxlen, long type) |
| 258 | { |
| 259 | int len; |
| 260 | |
| 261 | len = msgrcvcxx . . $ msgrcv(bdef3f15a3ce1a15).(msqidcxx . . $ msqid., (struct msgbufcxx . . $ msgbuf# *)msg, maxlen - sizeof(long), type, |
| 262 | MSG_NOERRORcxx . . $ `<external>/16456700908987091709/msq.h:32:9`!); |
| 263 | if (len < 0) { |
| 264 | perrorcxx . . $ perror(85c52e162fed56f9).("msgrcv"); |
| 265 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 266 | } |
| 267 | #if 0 |
| 268 | for (;;) { |
| 269 | if ((len = msgrcv(msqid, (struct msgbuf *)msg, maxlen-sizeof(long), type, IPC_NOWAIT|MSG_NOERROR)) >= 0) |
| 270 | return len+sizeof(long); |
| 271 | if (errno != ENOMSG) { |
| 272 | perror("msgrcv"); |
| 273 | exit(1); |
| 274 | } |
| 275 | usleep(250000); |
| 276 | } |
| 277 | #endif |
| 278 | return len+sizeof(long); |
| 279 | } |
| 280 | |
| 281 | /* ---------------------------------------------------------------------- */ |
| 282 | |
| 283 | |
| 284 | int hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(int cmd, struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# *par) |
| 285 | { |
| 286 | struct ifreqcxx . . $ ifreq# ifr = ifr_hcxx . . $ ifr_h.; |
| 287 | |
| 288 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 289 | return -1; |
| 290 | ifr.ifr_datacxx . . $ `<external>/2638090476884991293/if.h:162:10`! = (caddr_tcxx . . $ caddr_t#)par; |
| 291 | par->cmdcxx . . $ hdlcdrv_ioctl#cmd. = cmd; |
| 292 | return ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCDEVPRIVATEcxx . . $ `<external>/13324550044150506404/sockios.h:167:9`!, &ifr); |
| 293 | } |
| 294 | |
| 295 | /* ---------------------------------------------------------------------- */ |
| 296 | |
| 297 | int hdrvc_sm_ioctlcxx . . $ hdrvc_sm_ioctl(bf89a364da74a233).(int cmd, struct sm_ioctlcxx . . $ sm_ioctl# *par) |
| 298 | { |
| 299 | struct ifreqcxx . . $ ifreq# ifr = ifr_hcxx . . $ ifr_h.; |
| 300 | |
| 301 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 302 | return -1; |
| 303 | ifr.ifr_datacxx . . $ `<external>/2638090476884991293/if.h:162:10`! = (caddr_tcxx . . $ caddr_t#)par; |
| 304 | par->cmdcxx . . $ sm_ioctl#cmd. = cmd; |
| 305 | return ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCDEVPRIVATEcxx . . $ `<external>/13324550044150506404/sockios.h:167:9`!, &ifr); |
| 306 | } |
| 307 | |
| 308 | /* ---------------------------------------------------------------------- */ |
| 309 | |
| 310 | int hdrvc_baycom_ioctlcxx . . $ hdrvc_baycom_ioctl(51d393eee869daf2).(int cmd, struct baycom_ioctlcxx . . $ baycom_ioctl# *par) |
| 311 | { |
| 312 | struct ifreqcxx . . $ ifreq# ifr = ifr_hcxx . . $ ifr_h.; |
| 313 | |
| 314 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 315 | return -1; |
| 316 | ifr.ifr_datacxx . . $ `<external>/2638090476884991293/if.h:162:10`! = (caddr_tcxx . . $ caddr_t#)par; |
| 317 | par->cmdcxx . . $ baycom_ioctl#cmd. = cmd; |
| 318 | return ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCDEVPRIVATEcxx . . $ `<external>/13324550044150506404/sockios.h:167:9`!, &ifr); |
| 319 | } |
| 320 | |
| 321 | /* ---------------------------------------------------------------------- */ |
| 322 | |
| 323 | unsigned int hdrvc_get_ifflagscxx . . $ hdrvc_get_ifflags(db52760e79bf9054).(void) |
| 324 | { |
| 325 | struct ifreqcxx . . $ ifreq# ifr; |
| 326 | |
| 327 | memcpycxx . . $ memcpy(cc817cb175f282d).(&ifr, &ifr_hcxx . . $ ifr_h., sizeof(ifr)); |
| 328 | if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(fdcxx . . $ fd., SIOCGIFFLAGScxx . . $ `<external>/13324550044150506404/sockios.h:60:9`!, &ifr) < 0) { |
| 329 | perrorcxx . . $ perror(85c52e162fed56f9).("ioctl: SIOCGIFFLAGS"); |
| 330 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 331 | } |
| 332 | return ifr.ifr_flagscxx . . $ `<external>/2638090476884991293/if.h:157:10`!; |
| 333 | return IFF_UPcxx . . $ `<external>/2638090476884991293/if.h:45:10`! | IFF_RUNNINGcxx . . $ `<external>/2638090476884991293/if.h:57:10`!; |
| 334 | } |
| 335 | |
| 336 | /* ---------------------------------------------------------------------- */ |
| 337 | |
| 338 | int hdrvc_diagcxx . . $ hdrvc_diag(d151554320de317f).(struct sm_diag_datacxx . . $ sm_diag_data# *diag) |
| 339 | { |
| 340 | struct sm_ioctlcxx . . $ sm_ioctl# smi; |
| 341 | int ret; |
| 342 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 343 | |
| 344 | if (!diag) { |
| 345 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 346 | return -1; |
| 347 | } |
| 348 | memcpycxx . . $ memcpy(cc817cb175f282d).(&smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag., diag, sizeof(smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag.)); |
| 349 | ret = hdrvc_sm_ioctlcxx . . $ hdrvc_sm_ioctl(bf89a364da74a233).(SMCTL_DIAGNOSEcxx . . $ `hdlcutil/soundmodem.h:81:9`!, &smi); |
| 350 | memcpycxx . . $ memcpy(cc817cb175f282d).(diag, &smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag., sizeof(smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag.)); |
| 351 | return ret; |
| 352 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_REQ_DIAGcxx . . $ `hdlcutil/usersmdiag.h:47:9`!; |
| 353 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 354 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..modecxx . . $ usersm_diag#mode. = diag->modecxx . . $ sm_diag_data#mode.; |
| 355 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..flagscxx . . $ usersm_diag#flags. = diag->flagscxx . . $ sm_diag_data#flags.; |
| 356 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..samplesperbitcxx . . $ usersm_diag#samplesperbit. = diag->samplesperbitcxx . . $ sm_diag_data#samplesperbit.; |
| 357 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen. = diag->datalencxx . . $ sm_diag_data#datalen.; |
| 358 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, sizeof(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag.)); |
| 359 | ret = hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(&msg, sizeof(msg), USERSM_CMD_ACK_DIAGcxx . . $ `hdlcutil/usersmdiag.h:48:9`!); |
| 360 | if (ret < 0) |
| 361 | return ret; |
| 362 | if (ret < sizeof(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag.) || ret < sizeof(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag.)+msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen.*sizeof(short)) { |
| 363 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 364 | return -1; |
| 365 | } |
| 366 | diag->modecxx . . $ sm_diag_data#mode. = msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..modecxx . . $ usersm_diag#mode.; |
| 367 | diag->flagscxx . . $ sm_diag_data#flags. = msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..flagscxx . . $ usersm_diag#flags.; |
| 368 | diag->samplesperbitcxx . . $ sm_diag_data#samplesperbit. = msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..samplesperbitcxx . . $ usersm_diag#samplesperbit.; |
| 369 | diag->datalencxx . . $ sm_diag_data#datalen. = msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen.; |
| 370 | memcpycxx . . $ memcpy(cc817cb175f282d).(diag->datacxx . . $ sm_diag_data#data., msg.datacxx . . $ usersmmsg#data..diag_outcxx . . $ usersmmsg#$anonymous_type_0#diag_out..samplescxx . . $ usersm_diag_out#samples., msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen.*sizeof(short)); |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | |
| 375 | /* ---------------------------------------------------------------------- */ |
| 376 | |
| 377 | int hdrvc_get_samplescxx . . $ hdrvc_get_samples(b126dc7c1de90089).(void) |
| 378 | { |
| 379 | int ret; |
| 380 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# bi; |
| 381 | |
| 382 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETSAMPLEScxx . . $ `<external>/3637798386850560561/hdlcdrv.h:82:9`!, &bi); |
| 383 | if (ret < 0) |
| 384 | return ret; |
| 385 | return bi.datacxx . . $ hdlcdrv_ioctl#data..bitscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#bits. & 0xff; |
| 386 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!; |
| 387 | return -1; |
| 388 | } |
| 389 | |
| 390 | /* ---------------------------------------------------------------------- */ |
| 391 | |
| 392 | int hdrvc_get_bitscxx . . $ hdrvc_get_bits(b126dc7c1de90089).(void) |
| 393 | { |
| 394 | int ret; |
| 395 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# bi; |
| 396 | |
| 397 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETBITScxx . . $ `<external>/3637798386850560561/hdlcdrv.h:83:9`!, &bi); |
| 398 | if (ret < 0) |
| 399 | return ret; |
| 400 | return bi.datacxx . . $ hdlcdrv_ioctl#data..bitscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#bits. & 0xff; |
| 401 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!; |
| 402 | return -1; |
| 403 | } |
| 404 | |
| 405 | /* ---------------------------------------------------------------------- */ |
| 406 | |
| 407 | int hdrvc_get_channel_access_paramcxx . . $ hdrvc_get_channel_access_param(f136402c1dcd8d85).(struct hdrvc_channel_paramscxx . . $ hdrvc_channel_params# *par) |
| 408 | { |
| 409 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# hi; |
| 410 | int ret; |
| 411 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 412 | |
| 413 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETCHANNELPARcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:73:9`!, &hi); |
| 414 | if (ret < 0) |
| 415 | return ret; |
| 416 | if (!par) { |
| 417 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 418 | return -1; |
| 419 | } |
| 420 | par->tx_delaycxx . . $ hdrvc_channel_params#tx_delay. = hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..tx_delaycxx . . $ hdlcdrv_channel_params#tx_delay.; |
| 421 | par->tx_tailcxx . . $ hdrvc_channel_params#tx_tail. = hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..tx_tailcxx . . $ hdlcdrv_channel_params#tx_tail.; |
| 422 | par->slottimecxx . . $ hdrvc_channel_params#slottime. = hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..slottimecxx . . $ hdlcdrv_channel_params#slottime.; |
| 423 | par->ppersistcxx . . $ hdrvc_channel_params#ppersist. = hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..ppersistcxx . . $ hdlcdrv_channel_params#ppersist.; |
| 424 | par->fulldupcxx . . $ hdrvc_channel_params#fulldup. = hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..fulldupcxx . . $ hdlcdrv_channel_params#fulldup.; |
| 425 | return 0; |
| 426 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_REQ_CHACCESS_PARcxx . . $ `hdlcutil/usersmdiag.h:39:9`!; |
| 427 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 428 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, 0); |
| 429 | ret = hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(&msg, sizeof(msg), USERSM_CMD_ACK_CHACCESS_PARcxx . . $ `hdlcutil/usersmdiag.h:40:9`!); |
| 430 | if (ret < 0) |
| 431 | return ret; |
| 432 | if (ret < sizeof(msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp.)) { |
| 433 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 434 | return -1; |
| 435 | } |
| 436 | par->tx_delaycxx . . $ hdrvc_channel_params#tx_delay. = msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..tx_delaycxx . . $ usersm_chaccess_par#tx_delay.; |
| 437 | par->tx_tailcxx . . $ hdrvc_channel_params#tx_tail. = msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..tx_tailcxx . . $ usersm_chaccess_par#tx_tail.; |
| 438 | par->slottimecxx . . $ hdrvc_channel_params#slottime. = msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..slottimecxx . . $ usersm_chaccess_par#slottime.; |
| 439 | par->ppersistcxx . . $ hdrvc_channel_params#ppersist. = msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..ppersistcxx . . $ usersm_chaccess_par#ppersist.; |
| 440 | par->fulldupcxx . . $ hdrvc_channel_params#fulldup. = msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..fulldupcxx . . $ usersm_chaccess_par#fulldup.; |
| 441 | return 0; |
| 442 | } |
| 443 | |
| 444 | /* ---------------------------------------------------------------------- */ |
| 445 | |
| 446 | int hdrvc_set_channel_access_paramcxx . . $ hdrvc_set_channel_access_param(4ab70b5db353be76).(struct hdrvc_channel_paramscxx . . $ hdrvc_channel_params# par) |
| 447 | { |
| 448 | int ret; |
| 449 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 450 | |
| 451 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# hi; |
| 452 | |
| 453 | hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..tx_delaycxx . . $ hdlcdrv_channel_params#tx_delay. = par.tx_delaycxx . . $ hdrvc_channel_params#tx_delay.; |
| 454 | hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..tx_tailcxx . . $ hdlcdrv_channel_params#tx_tail. = par.tx_tailcxx . . $ hdrvc_channel_params#tx_tail.; |
| 455 | hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..slottimecxx . . $ hdlcdrv_channel_params#slottime. = par.slottimecxx . . $ hdrvc_channel_params#slottime.; |
| 456 | hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..ppersistcxx . . $ hdlcdrv_channel_params#ppersist. = par.ppersistcxx . . $ hdrvc_channel_params#ppersist.; |
| 457 | hi.datacxx . . $ hdlcdrv_ioctl#data..cpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cp..fulldupcxx . . $ hdlcdrv_channel_params#fulldup. = par.fulldupcxx . . $ hdrvc_channel_params#fulldup.; |
| 458 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_SETCHANNELPARcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:74:9`!, &hi); |
| 459 | if (ret < 0) |
| 460 | return ret; |
| 461 | return 0; |
| 462 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_SET_CHACCESS_PARcxx . . $ `hdlcutil/usersmdiag.h:41:9`!; |
| 463 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 464 | msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..tx_delaycxx . . $ usersm_chaccess_par#tx_delay. = par.tx_delaycxx . . $ hdrvc_channel_params#tx_delay.; |
| 465 | msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..tx_tailcxx . . $ usersm_chaccess_par#tx_tail. = par.tx_tailcxx . . $ hdrvc_channel_params#tx_tail.; |
| 466 | msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..slottimecxx . . $ usersm_chaccess_par#slottime. = par.slottimecxx . . $ hdrvc_channel_params#slottime.; |
| 467 | msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..ppersistcxx . . $ usersm_chaccess_par#ppersist. = par.ppersistcxx . . $ hdrvc_channel_params#ppersist.; |
| 468 | msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp..fulldupcxx . . $ usersm_chaccess_par#fulldup. = par.fulldupcxx . . $ hdrvc_channel_params#fulldup.; |
| 469 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, sizeof(msg.datacxx . . $ usersmmsg#data..cpcxx . . $ usersmmsg#$anonymous_type_0#cp.)); |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | /* ---------------------------------------------------------------------- */ |
| 474 | |
| 475 | int hdrvc_calibratecxx . . $ hdrvc_calibrate(7864480464b09eea).(int calib) |
| 476 | { |
| 477 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# bhi; |
| 478 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 479 | |
| 480 | bhi.datacxx . . $ hdlcdrv_ioctl#data..calibratecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#calibrate. = calib; |
| 481 | return hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_CALIBRATEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:76:9`!, &bhi); |
| 482 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_CALIBRATEcxx . . $ `hdlcutil/usersmdiag.h:43:9`!; |
| 483 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 484 | msg.datacxx . . $ usersmmsg#data..calibcxx . . $ usersmmsg#$anonymous_type_0#calib. = calib; |
| 485 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, sizeof(msg.datacxx . . $ usersmmsg#data..calibcxx . . $ usersmmsg#$anonymous_type_0#calib.)); |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | /* ---------------------------------------------------------------------- */ |
| 490 | |
| 491 | int hdrvc_get_channel_statecxx . . $ hdrvc_get_channel_state(b95f36a631c52079).(struct hdrvc_channel_statecxx . . $ hdrvc_channel_state# *st) |
| 492 | { |
| 493 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# bhi; |
| 494 | int ret; |
| 495 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 496 | |
| 497 | if (!st) { |
| 498 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 499 | return -1; |
| 500 | } |
| 501 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETSTATcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:77:9`!, &bhi); |
| 502 | if (ret >= 0) { |
| 503 | st->pttcxx . . $ hdrvc_channel_state#ptt. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..pttcxx . . $ hdlcdrv_channel_state#ptt.; |
| 504 | st->dcdcxx . . $ hdrvc_channel_state#dcd. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..dcdcxx . . $ hdlcdrv_channel_state#dcd.; |
| 505 | st->ptt_keyedcxx . . $ hdrvc_channel_state#ptt_keyed. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..ptt_keyedcxx . . $ hdlcdrv_channel_state#ptt_keyed.; |
| 506 | st->tx_packetscxx . . $ hdrvc_channel_state#tx_packets. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..tx_packetscxx . . $ hdlcdrv_channel_state#tx_packets.; |
| 507 | st->tx_errorscxx . . $ hdrvc_channel_state#tx_errors. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..tx_errorscxx . . $ hdlcdrv_channel_state#tx_errors.; |
| 508 | st->rx_packetscxx . . $ hdrvc_channel_state#rx_packets. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..rx_packetscxx . . $ hdlcdrv_channel_state#rx_packets.; |
| 509 | st->rx_errorscxx . . $ hdrvc_channel_state#rx_errors. = bhi.datacxx . . $ hdlcdrv_ioctl#data..cscxx . . $ hdlcdrv_ioctl#$anonymous_type_0#cs..rx_errorscxx . . $ hdlcdrv_channel_state#rx_errors.; |
| 510 | } |
| 511 | return ret; |
| 512 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_REQ_CHANNELSTATEcxx . . $ `hdlcutil/usersmdiag.h:44:9`!; |
| 513 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 514 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, 0); |
| 515 | ret = hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(&msg, sizeof(msg), USERSM_CMD_ACK_CHANNELSTATEcxx . . $ `hdlcutil/usersmdiag.h:45:9`!); |
| 516 | if (ret < 0) |
| 517 | return ret; |
| 518 | if (ret < sizeof(msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs.)) { |
| 519 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 520 | return -1; |
| 521 | } |
| 522 | st->pttcxx . . $ hdrvc_channel_state#ptt. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..pttcxx . . $ usersm_channel_state#ptt.; |
| 523 | st->dcdcxx . . $ hdrvc_channel_state#dcd. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..dcdcxx . . $ usersm_channel_state#dcd.; |
| 524 | st->ptt_keyedcxx . . $ hdrvc_channel_state#ptt_keyed. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..ptt_keyedcxx . . $ usersm_channel_state#ptt_keyed.; |
| 525 | st->tx_packetscxx . . $ hdrvc_channel_state#tx_packets. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..tx_packetscxx . . $ usersm_channel_state#tx_packets.; |
| 526 | st->tx_errorscxx . . $ hdrvc_channel_state#tx_errors. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..tx_errorscxx . . $ usersm_channel_state#tx_errors.; |
| 527 | st->rx_packetscxx . . $ hdrvc_channel_state#rx_packets. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..rx_packetscxx . . $ usersm_channel_state#rx_packets.; |
| 528 | st->rx_errorscxx . . $ hdrvc_channel_state#rx_errors. = msg.datacxx . . $ usersmmsg#data..cscxx . . $ usersmmsg#$anonymous_type_0#cs..rx_errorscxx . . $ usersm_channel_state#rx_errors.; |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | /* ---------------------------------------------------------------------- */ |
| 533 | |
| 534 | int hdrvc_diag2cxx . . $ hdrvc_diag2(2b48473033b61705).(unsigned int mode, unsigned int flags, short *data, |
| 535 | unsigned int maxdatalen, unsigned int *samplesperbit) |
| 536 | { |
| 537 | int ret; |
| 538 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 539 | static unsigned int modeconvusersm[4] = { |
| 540 | USERSM_DIAGMODE_OFFcxx . . $ `hdlcutil/usersmdiag.h:58:9`!, USERSM_DIAGMODE_INPUTcxx . . $ `hdlcutil/usersmdiag.h:59:9`!, USERSM_DIAGMODE_DEMODcxx . . $ `hdlcutil/usersmdiag.h:60:9`!, |
| 541 | USERSM_DIAGMODE_CONSTELLATIONcxx . . $ `hdlcutil/usersmdiag.h:61:9`! |
| 542 | }; |
| 543 | |
| 544 | if (mode > HDRVC_DIAGMODE_CONSTELLATIONcxx . . $ `hdlcutil/hdrvcomm.h:73:9`!) { |
| 545 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 546 | return -1; |
| 547 | } |
| 548 | struct sm_ioctlcxx . . $ sm_ioctl# smi; |
| 549 | static unsigned int modeconvsm[4] = { |
| 550 | SM_DIAGMODE_OFFcxx . . $ `hdlcutil/soundmodem.h:57:9`!, SM_DIAGMODE_INPUTcxx . . $ `hdlcutil/soundmodem.h:58:9`!, SM_DIAGMODE_DEMODcxx . . $ `hdlcutil/soundmodem.h:59:9`!, |
| 551 | SM_DIAGMODE_CONSTELLATIONcxx . . $ `hdlcutil/soundmodem.h:60:9`! |
| 552 | }; |
| 553 | |
| 554 | smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..modecxx . . $ sm_diag_data#mode. = modeconvsm[mode]; |
| 555 | smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..flagscxx . . $ sm_diag_data#flags. = (flags & HDRVC_DIAGFLAG_DCDGATEcxx . . $ `hdlcutil/hdrvcomm.h:78:9`!) ? SM_DIAGFLAG_DCDGATEcxx . . $ `hdlcutil/soundmodem.h:65:9`! : 0; |
| 556 | smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..samplesperbitcxx . . $ sm_diag_data#samplesperbit. = 0; |
| 557 | smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..datalencxx . . $ sm_diag_data#datalen. = maxdatalen; |
| 558 | smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..datacxx . . $ sm_diag_data#data. = data; |
| 559 | ret = hdrvc_sm_ioctlcxx . . $ hdrvc_sm_ioctl(bf89a364da74a233).(SMCTL_DIAGNOSEcxx . . $ `hdlcutil/soundmodem.h:81:9`!, &smi); |
| 560 | if (ret < 0) |
| 561 | return ret; |
| 562 | if (samplesperbit) |
| 563 | *samplesperbit = smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..samplesperbitcxx . . $ sm_diag_data#samplesperbit.; |
| 564 | if (smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..modecxx . . $ sm_diag_data#mode. != modeconvsm[mode] || !(smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..flagscxx . . $ sm_diag_data#flags. & SM_DIAGFLAG_VALIDcxx . . $ `hdlcutil/soundmodem.h:66:9`!)) |
| 565 | return 0; |
| 566 | return smi.datacxx . . $ sm_ioctl#data..diagcxx . . $ sm_ioctl#$anonymous_type_0#diag..datalencxx . . $ sm_diag_data#datalen.; |
| 567 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_REQ_DIAGcxx . . $ `hdlcutil/usersmdiag.h:47:9`!; |
| 568 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 569 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..modecxx . . $ usersm_diag#mode. = modeconvusersm[mode]; |
| 570 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..flagscxx . . $ usersm_diag#flags. = (flags & HDRVC_DIAGFLAG_DCDGATEcxx . . $ `hdlcutil/hdrvcomm.h:78:9`!) ? USERSM_DIAGFLAG_DCDGATEcxx . . $ `hdlcutil/usersmdiag.h:66:9`! : 0; |
| 571 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..samplesperbitcxx . . $ usersm_diag#samplesperbit. = 0; |
| 572 | msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen. = maxdatalen; |
| 573 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, sizeof(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag.)); |
| 574 | ret = hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(&msg, sizeof(msg), USERSM_CMD_ACK_DIAGcxx . . $ `hdlcutil/usersmdiag.h:48:9`!); |
| 575 | if (ret < 0) |
| 576 | return ret; |
| 577 | if (ret < sizeof(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag.) || ret < sizeof(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag.)+msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen.*sizeof(short)) { |
| 578 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 579 | return -1; |
| 580 | } |
| 581 | if (samplesperbit) |
| 582 | *samplesperbit = msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..samplesperbitcxx . . $ usersm_diag#samplesperbit.; |
| 583 | if (msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..modecxx . . $ usersm_diag#mode. != modeconvusersm[mode] || !(msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..flagscxx . . $ usersm_diag#flags. & USERSM_DIAGFLAG_VALIDcxx . . $ `hdlcutil/usersmdiag.h:67:9`!)) |
| 584 | return 0; |
| 585 | if (!data || msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen. <= 0) |
| 586 | return 0; |
| 587 | memcpycxx . . $ memcpy(cc817cb175f282d).(data, msg.datacxx . . $ usersmmsg#data..diag_outcxx . . $ usersmmsg#$anonymous_type_0#diag_out..samplescxx . . $ usersm_diag_out#samples., msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen.*sizeof(short)); |
| 588 | return msg.datacxx . . $ usersmmsg#data..diagcxx . . $ usersmmsg#$anonymous_type_0#diag..datalencxx . . $ usersm_diag#datalen.; |
| 589 | } |
| 590 | |
| 591 | /* ---------------------------------------------------------------------- */ |
| 592 | |
| 593 | int hdrvc_get_driver_namecxx . . $ hdrvc_get_driver_name(6abd07ddb1a912f0).(char *buf, int bufsz) |
| 594 | { |
| 595 | int ret; |
| 596 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 597 | |
| 598 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# bhi; |
| 599 | |
| 600 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_DRIVERNAMEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:91:9`!, &bhi); |
| 601 | if (ret < 0) |
| 602 | return ret; |
| 603 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, bhi.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename., bufsz); |
| 604 | return 0; |
| 605 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_REQ_DRVNAMEcxx . . $ `hdlcutil/usersmdiag.h:50:9`!; |
| 606 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 607 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, 0); |
| 608 | ret = hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(&msg, sizeof(msg), USERSM_CMD_ACK_DRVNAMEcxx . . $ `hdlcutil/usersmdiag.h:51:9`!); |
| 609 | if (ret < 0) |
| 610 | return ret; |
| 611 | if (ret < 1) { |
| 612 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 613 | return -1; |
| 614 | } |
| 615 | if (bufsz < ret) |
| 616 | ret = bufsz; |
| 617 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, msg.datacxx . . $ usersmmsg#data..bycxx . . $ usersmmsg#$anonymous_type_0#by., ret); |
| 618 | buf[ret-1] = 0; |
| 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | /* ---------------------------------------------------------------------- */ |
| 623 | |
| 624 | int hdrvc_get_mode_namecxx . . $ hdrvc_get_mode_name(6abd07ddb1a912f0).(char *buf, int bufsz) |
| 625 | { |
| 626 | int ret; |
| 627 | struct usersmmsgcxx . . $ usersmmsg# msg; |
| 628 | |
| 629 | struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# bhi; |
| 630 | |
| 631 | ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETMODEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:88:9`!, &bhi); |
| 632 | if (ret < 0) |
| 633 | return ret; |
| 634 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, bhi.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename., bufsz); |
| 635 | return 0; |
| 636 | msg.hdrcxx . . $ usersmmsg#hdr..typecxx . . $ usersm_hdr#type. = USERSM_CMD_REQ_DRVMODEcxx . . $ `hdlcutil/usersmdiag.h:52:9`!; |
| 637 | msg.hdrcxx . . $ usersmmsg#hdr..channelcxx . . $ usersm_hdr#channel. = 0; |
| 638 | hdrvc_sendmsgcxx . . $ hdrvc_sendmsg(150056160ff3a357).(&msg, 0); |
| 639 | ret = hdrvc_recvmsgcxx . . $ hdrvc_recvmsg(943d5497cf2bb8af).(&msg, sizeof(msg), USERSM_CMD_ACK_DRVMODEcxx . . $ `hdlcutil/usersmdiag.h:53:9`!); |
| 640 | if (ret < 0) |
| 641 | return ret; |
| 642 | if (ret < 1) { |
| 643 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 644 | return -1; |
| 645 | } |
| 646 | if (bufsz < ret) |
| 647 | ret = bufsz; |
| 648 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, msg.datacxx . . $ usersmmsg#data..bycxx . . $ usersmmsg#$anonymous_type_0#by., ret); |
| 649 | buf[ret-1] = 0; |
| 650 | return 0; |
| 651 | } |
| 652 | |
| 653 | /* ---------------------------------------------------------------------- */ |