FreeCalypso > hg > freecalypso-sw
annotate rvinterf/include/localsock.h @ 704:3b6cc1a90ef8
dl_dcch3.c compiles
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 03 Oct 2014 03:38:51 +0000 |
parents | cb833ff54d88 |
children | a5c8f48003cd |
rev | line source |
---|---|
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This header defines and describes (through comments) the local UNIX domain |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * socket interface implemented between rvinterf and its clients like fc-tmsh. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * The UNIX domain sockets used for this ad hoc interface are of the |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 * SOCK_STREAM kind, but the true nature of the communication is message-based. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 * We use the same trick that is used for DNS over TCP: every message in each |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
8 * direction is preceded by a 2-byte length. This length is sent MSB first |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
9 * just like in DNS over TCP. The limit on the size of these messages |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 * (for sizing buffers etc) is: |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 */ |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #define LOCALSOCK_MAX_MSG 1024 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 /* |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 * Each message in the client->rvinterf direction (can be seen as command) |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 * begins (after the length) with an opcode byte as follows: |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 */ |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 #define CLI2RVI_WANT_RVTRACE 0x00 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 #define CLI2RVI_WANT_MUXPROTO 0x01 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 #define CLI2RVI_PKT_TO_TARGET 0x02 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 #define CLI2RVI_RAWBYTES_TO_TARGET 0x03 |
266
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
24 #define CLI2RVI_RESET_PACKET_RX 0x04 |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 /* |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 * The first two commands (CLI2RVI_WANT_RVTRACE and CLI2RVI_WANT_MUXPROTO) |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 * are the means by which client programs inform rvinterf that they are |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 * interested in receiving copies of certain packets coming from the target. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 * |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 * The CLI2RVI_WANT_RVTRACE opcode needs to be followed by a USEID mask value |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
32 * and a USEID match value, both in the network byte order, i.e., MSB first, |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
33 * for a total message length of 9 bytes. For every RV trace message received |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
34 * from the target, rvinterf will iterate through all active clients to see who |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
35 * is interested: if the received USEID ANDed with the mask equals the match |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
36 * value, the message will be forwarded to that client. |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 * |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 * The CLI2RVI_WANT_MUXPROTO opcode needs to be followed by one byte |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 * identifying the RVTMUX protocol of interest, i.e., the first byte of the |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 * packets exchanged between the host and the target, e.g., 0x12 for L1 traces |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 * as defined in pktmux.h, for a total message length of 2 bytes. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 * |
266
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
43 * The CLI2RVI_RESET_PACKET_RX opcode resets the "interests" previously set |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
44 * with CLI2RVI_WANT_RVTRACE and/or CLI2RVI_WANT_MUXPROTO. It is a "blanket" |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
45 * reset; the command message consists of just the opcode. |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
46 * |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 * The last two commands (CLI2RVI_PKT_TO_TARGET and CLI2RVI_RAWBYTES_TO_TARGET) |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 * cause data payload to be sent to the target serial port. Payload following |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 * CLI2RVI_PKT_TO_TARGET (must not exceed MAX_PKT_TO_TARGET) is sent with the |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 * proper packet encapsulation per TI; bytes following |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 * CLI2RVI_RAWBYTES_TO_TARGET are sent raw. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 */ |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 /* |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 * Each message in the rvinterf->client direction begins (after the length) |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 * with a message type byte as follows: |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 */ |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 #define RVI2CLI_PKT_FROM_TARGET 0x00 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 #define RVI2CLI_LOCAL_CMD_RESP 0x01 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 /* |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 * Messages beginning with RVI2CLI_PKT_FROM_TARGET are packets received |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 * from the target GSM device; the byte following this type code is the |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 * first byte of the packet from the target, e.g., 0x11 for RV traces or |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 * 0x12 for L1 traces. Rvinterf will only start sending these messages |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 * to a client after that client has expressed interest in receiving |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 * target->host packets of a particular type. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 * |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 * Messages beginning with RVI2CLI_LOCAL_CMD_RESP are generated locally |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 * by rvinterf itself as responses to commands, currently as responses to |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 * CLI2RVI_WANT_{RVTRACE,MUXPROTO}. The byte following the |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 * RVT2CLI_LOCAL_CMD_RESP type code is ASCII '+' or ASCII '-', indicating |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 * success or error, respectively. Any remaining bytes form a message |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 * for the user. |
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 */ |