comparison rvinterf/old/sendsp/sendsp.c @ 964:373af5f74e39

rvinterf: all retired stuff gathered under old
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Fri, 06 Nov 2015 23:22:47 +0000
parents rvinterf/misc/sendsp.c@5d9001f0c3aa
children
comparison
equal deleted inserted replaced
963:d69d1e097b18 964:373af5f74e39
1 /*
2 * This hack-utility sends a GPF System Primitive given on the command line
3 * to a target GSM device via rvinterf.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <strings.h>
10 #include <stdlib.h>
11 #include "pktmux.h"
12 #include "limits.h"
13
14 char *socket_pathname = "/tmp/rvinterf_socket";
15
16 main(argc, argv)
17 char **argv;
18 {
19 char *stackdest, *primarg;
20 unsigned intlen;
21 u_char sendpkt[MAX_PKT_TO_TARGET];
22 unsigned pktlen;
23
24 if (argc < 3) {
25 usage: fprintf(stderr, "usage: %s [-s socket] stackdest primarg\n",
26 argv[0]);
27 exit(1);
28 }
29 if (strcmp(argv[1], "-s")) {
30 if (argc != 3)
31 goto usage;
32 stackdest = argv[1];
33 primarg = argv[2];
34 } else {
35 if (argc != 5)
36 goto usage;
37 socket_pathname = argv[2];
38 stackdest = argv[3];
39 primarg = argv[4];
40 }
41 if (strlen(stackdest) > 4) {
42 fprintf(stderr,
43 "error: stack destination arg may not exceed 4 characters\n");
44 exit(1);
45 }
46 intlen = 12 + strlen(primarg) + 1;
47 pktlen = intlen + 4;
48 if (pktlen > MAX_PKT_TO_TARGET) {
49 fprintf(stderr, "error: max pkt to target limit exceeded\n");
50 exit(1);
51 }
52 /* fill out the packet */
53 sendpkt[0] = RVT_L23_HEADER;
54 sendpkt[1] = 0xB7; /* system prim */
55 sendpkt[2] = intlen;
56 sendpkt[3] = intlen >> 8;
57 /* send zeros for the timestamp */
58 sendpkt[4] = 0;
59 sendpkt[5] = 0;
60 sendpkt[6] = 0;
61 sendpkt[7] = 0;
62 /* as far as TI's sw is concerned, we are PCO */
63 sendpkt[8] = 'P';
64 sendpkt[9] = 'C';
65 sendpkt[10] = 'O';
66 sendpkt[11] = ' ';
67 sprintf(sendpkt + 12, "%-4s%s", stackdest, primarg);
68 /* send it! */
69 send_pkt_to_target(sendpkt, pktlen);
70 exit(0);
71 }