blob: 350791b2617f06c2e135d3d5c1395ec8aa5f1466 [file] [log] [blame]
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001/*
2 * Copyright (c) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_RIL_INTERNAL_H
18#define ANDROID_RIL_INTERNAL_H
19
Amit Mahajancd77a5b2016-08-25 11:19:21 -070020namespace android {
21
Amit Mahajan35e93102017-03-28 11:17:55 -070022#define RIL_SERVICE_NAME_BASE "slot"
23#define RIL1_SERVICE_NAME "slot1"
24#define RIL2_SERVICE_NAME "slot2"
25#define RIL3_SERVICE_NAME "slot3"
26#define RIL4_SERVICE_NAME "slot4"
Amit Mahajan439da362017-02-13 17:43:04 -080027
Amit Mahajancd77a5b2016-08-25 11:19:21 -070028/* Constants for response types */
29#define RESPONSE_SOLICITED 0
30#define RESPONSE_UNSOLICITED 1
31#define RESPONSE_SOLICITED_ACK 2
32#define RESPONSE_SOLICITED_ACK_EXP 3
33#define RESPONSE_UNSOLICITED_ACK_EXP 4
34
Amit Mahajan5829a472016-12-28 17:28:07 -080035// Enable verbose logging
36#define VDBG 0
37
38#define MIN(a,b) ((a)<(b) ? (a) : (b))
39
40// Enable RILC log
41#define RILC_LOG 0
42
43#if RILC_LOG
44 #define startRequest sprintf(printBuf, "(")
45 #define closeRequest sprintf(printBuf, "%s)", printBuf)
46 #define printRequest(token, req) \
47 RLOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
48
49 #define startResponse sprintf(printBuf, "%s {", printBuf)
50 #define closeResponse sprintf(printBuf, "%s}", printBuf)
51 #define printResponse RLOGD("%s", printBuf)
52
53 #define clearPrintBuf printBuf[0] = 0
54 #define removeLastChar printBuf[strlen(printBuf)-1] = 0
55 #define appendPrintBuf(x...) snprintf(printBuf, PRINTBUF_SIZE, x)
56#else
57 #define startRequest
58 #define closeRequest
59 #define printRequest(token, req)
60 #define startResponse
61 #define closeResponse
62 #define printResponse
63 #define clearPrintBuf
64 #define removeLastChar
65 #define appendPrintBuf(x...)
66#endif
67
Amit Mahajancd77a5b2016-08-25 11:19:21 -070068typedef struct CommandInfo CommandInfo;
69
70extern "C" const char * requestToString(int request);
71
72typedef struct RequestInfo {
73 int32_t token; //this is not RIL_Token
74 CommandInfo *pCI;
75 struct RequestInfo *p_next;
76 char cancelled;
77 char local; // responses to local commands do not go back to command process
78 RIL_SOCKET_ID socket_id;
79 int wasAckSent; // Indicates whether an ack was sent earlier
80} RequestInfo;
81
82typedef struct CommandInfo {
83 int requestNumber;
Amit Mahajan759786a2017-03-03 17:35:47 -080084 int(*responseFunction) (int slotId, int responseType, int token,
Amit Mahajancd77a5b2016-08-25 11:19:21 -070085 RIL_Errno e, void *response, size_t responselen);
86} CommandInfo;
87
Sanket Padawef220dc52017-01-02 23:46:00 -080088RequestInfo * addRequestToList(int serial, int slotId, int request);
Amit Mahajancd77a5b2016-08-25 11:19:21 -070089
Amit Mahajan35e93102017-03-28 11:17:55 -070090char * RIL_getServiceName();
Amit Mahajancd77a5b2016-08-25 11:19:21 -070091
Sanket Padawef220dc52017-01-02 23:46:00 -080092void releaseWakeLock();
Amit Mahajanc7ad6262017-03-14 16:39:27 -070093
94void onNewCommandConnect(RIL_SOCKET_ID socket_id);
95
Amit Mahajancd77a5b2016-08-25 11:19:21 -070096} // namespace android
97
98#endif //ANDROID_RIL_INTERNAL_H