annotate autocal/l1tmops.c @ 16:1c4abfe8bcd9

autocal/l1tmops.c started
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 May 2017 17:45:30 +0000
parents
children 0645344feee5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we are going to implement the functions for executing
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * various L1TM operations on the DUT.
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <rvinterf/pktmux.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/tm3.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/l1tm.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <rvinterf/exitcodes.h>
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern u_char rvi_msg[];
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern int rvi_msg_len;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 l1tm_pkt_exch(outbuf, outlen)
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u_char *outbuf;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int i, c;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 outbuf[0] = RVT_TM_HEADER;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 c = 0;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 for (i = 1; i <= outlen; i++)
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 c ^= outbuf[i];
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 outbuf[i] = c;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 target_pkt_exch(outbuf, outlen + 2);
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (rvi_msg[1] != RVT_TM_HEADER) {
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 fprintf(stderr,
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 "DUT error: response packet is not on TM channel\n");
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 exit(ERROR_TARGET);
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (rvi_msg_len < 5) {
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 fprintf(stderr, "DUT error: TM response packet is too short\n");
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 exit(ERROR_TARGET);
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 c = 0;
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (i = 2; i < rvi_msg_len; i++)
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 c ^= rvi_msg[i];
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (c) {
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 fprintf(stderr, "DUT error: TM response bad checksum\n");
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 exit(ERROR_TARGET);
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (rvi_msg[2] != outbuf[1]) {
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 fprintf(stderr, "DUT error: TM response has wrong CID\n");
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 exit(ERROR_TARGET);
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return(0);
1c4abfe8bcd9 autocal/l1tmops.c started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }