1 /*
2 * Copyright 2024, 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 #pragma once
18
19 #include <interface/metrics/metrics.h>
20 #include <lib/tipc/tipc_srv.h>
21 #include <string.h>
22
23 __BEGIN_CDECLS
24
25 struct metrics_crash_msg {
26 struct metrics_req req;
27 struct metrics_report_crash_req crash_args;
28 } __attribute__((__packed__));
29
30 /**
31 * struct srv_state - global state of the metrics TA
32 * @ns_handle: Channel corresponding to Android metrics_d
33 */
34 struct srv_state {
35 handle_t ns_handle;
36 };
37
is_ns_connected(struct srv_state * state)38 static inline bool is_ns_connected(struct srv_state* state) {
39 return state->ns_handle != INVALID_IPC_HANDLE;
40 }
41
set_srv_state(struct tipc_port * port,struct srv_state * state)42 static inline void set_srv_state(struct tipc_port* port,
43 struct srv_state* state) {
44 port->priv = state;
45 }
46
get_srv_state(const struct tipc_port * port)47 static inline struct srv_state* get_srv_state(const struct tipc_port* port) {
48 return (struct srv_state*)(port->priv);
49 }
50
equal_uuid(const struct uuid * a,const struct uuid * b)51 static inline bool equal_uuid(const struct uuid* a, const struct uuid* b) {
52 return memcmp(a, b, sizeof(struct uuid)) == 0;
53 }
54
55 __END_CDECLS
56
57