annotate autocal/rvinterf.c @ 15:724e16223187

autocal/rvinterf.c now has all essential code for talking to rvinterf
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 May 2017 23:04:42 +0000
parents d7e436bf4876
children e86779d5445c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Interface to the DUT via rvinterf
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/socket.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/un.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <unistd.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <rvinterf/pktmux.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <rvinterf/localsock.h>
15
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
15 #include <rvinterf/limits.h>
13
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <rvinterf/exitcodes.h>
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char *rvif_socket_pathname = "/tmp/rvinterf_socket";
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int rvif_socket;
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
15
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
21 int rx_enable_state;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
22 u_char rvi_msg[LOCALSOCK_MAX_MSG];
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
23 int rvi_msg_len;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
24
13
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 connect_rvinterf_socket()
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 /* local socket binding voodoo copied from osmocon */
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 struct sockaddr_un local;
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 unsigned int namelen;
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 int rc;
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 rvif_socket = socket(AF_UNIX, SOCK_STREAM, 0);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (rvif_socket < 0) {
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 perror("socket(AF_UNIX, SOCK_STREAM, 0)");
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 exit(ERROR_UNIX);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 local.sun_family = AF_UNIX;
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 strncpy(local.sun_path, rvif_socket_pathname, sizeof(local.sun_path));
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 local.sun_path[sizeof(local.sun_path) - 1] = '\0';
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /* we use the same magic that X11 uses in Xtranssock.c for
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * calculating the proper length of the sockaddr */
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 #if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 local.sun_len = strlen(local.sun_path);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 #endif
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 #if defined(BSD44SOCKETS) || defined(SUN_LEN)
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 namelen = SUN_LEN(&local);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 #else
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 namelen = strlen(local.sun_path) +
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 offsetof(struct sockaddr_un, sun_path) + 1;
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 #endif
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 rc = connect(rvif_socket, (struct sockaddr *) &local, namelen);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if (rc != 0) {
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 perror(rvif_socket_pathname);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 exit(ERROR_RVINTERF);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 }
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 return(0);
d7e436bf4876 starting autocal
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 }
15
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
62
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
63 static void
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
64 collect_bytes_from_rvi(buf, nbytes)
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
65 u_char *buf;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
66 {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
67 int cc;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
68
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
69 while (nbytes) {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
70 cc = read(rvif_socket, buf, nbytes);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
71 if (cc <= 0) {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
72 perror("read from rvinterf socket");
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
73 exit(ERROR_RVINTERF);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
74 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
75 buf += cc;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
76 nbytes -= cc;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
77 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
78 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
79
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
80 collect_rvi_msg()
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
81 {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
82 u_char lenbuf[2];
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
83
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
84 collect_bytes_from_rvi(lenbuf, 2);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
85 rvi_msg_len = lenbuf[0] << 8 | lenbuf[1];
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
86 if (rvi_msg_len < 1 || rvi_msg_len > LOCALSOCK_MAX_MSG) {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
87 fprintf(stderr, "Invalid length from rvinterf: %02X%02X\n",
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
88 lenbuf[0], lenbuf[1]);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
89 exit(ERROR_RVINTERF);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
90 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
91 collect_bytes_from_rvi(rvi_msg, rvi_msg_len);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
92 return(0);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
93 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
94
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
95 send_rvimisc_command(cmdpkt, cmdlen)
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
96 u_char *cmdpkt;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
97 {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
98 u_char lenbuf[2];
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
99
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
100 lenbuf[0] = 0;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
101 lenbuf[1] = cmdlen;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
102 write(rvif_socket, lenbuf, 2);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
103 write(rvif_socket, cmdpkt, cmdlen);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
104 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
105
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
106 rx_control(enable)
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
107 {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
108 u_char cmdpkt[2];
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
109 int cmdlen;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
110
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
111 /* are we already in the desired state? */
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
112 if (rx_enable_state == enable)
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
113 return(0);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
114 /* no, do the work */
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
115 if (enable) {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
116 cmdpkt[0] = CLI2RVI_WANT_MUXPROTO;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
117 cmdpkt[1] = RVT_TM_HEADER;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
118 cmdlen = 2;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
119 } else {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
120 cmdpkt[0] = CLI2RVI_RESET_PACKET_RX;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
121 cmdlen = 1;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
122 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
123 send_rvimisc_command(cmdpkt, cmdlen);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
124 collect_rvi_msg();
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
125 if (rvi_msg[0] != RVI2CLI_LOCAL_CMD_RESP || rvi_msg_len < 2) {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
126 fprintf(stderr,
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
127 "error: unexpected response to rvinterf local command\n");
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
128 exit(ERROR_RVINTERF);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
129 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
130 if (rvi_msg[1] != '+') {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
131 fprintf(stderr, "Error from rvinterf: %.*s\n", rvi_msg_len - 1,
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
132 rvi_msg + 1);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
133 exit(ERROR_RVINTERF);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
134 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
135 rx_enable_state = enable;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
136 return(0);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
137 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
138
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
139 send_pkt_to_target(pkt, pktlen)
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
140 u_char *pkt;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
141 {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
142 u_char hdrbuf[3];
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
143 int len1;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
144
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
145 len1 = pktlen + 1;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
146 hdrbuf[0] = len1 >> 8;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
147 hdrbuf[1] = len1 & 0xFF;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
148 hdrbuf[2] = CLI2RVI_PKT_TO_TARGET;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
149 write(rvif_socket, hdrbuf, 3);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
150 write(rvif_socket, pkt, pktlen);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
151 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
152
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
153 target_pkt_exch(outpkt, outpktlen)
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
154 u_char *outpkt;
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
155 {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
156 rx_control(1);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
157 send_pkt_to_target(outpkt, outpktlen);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
158 collect_rvi_msg();
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
159 if (rvi_msg[0] != RVI2CLI_PKT_FROM_TARGET) {
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
160 fprintf(stderr,
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
161 "error: unexpected response type from rvinterf\n");
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
162 exit(ERROR_RVINTERF);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
163 }
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
164 return(0);
724e16223187 autocal/rvinterf.c now has all essential code for talking to rvinterf
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
165 }