• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <lib/tipc/tipc_srv.h>
20 #include <string.h>
21 
22 __BEGIN_CDECLS
23 
24 /**
25  * struct srv_state - global state of the metrics TA
26  * @ns_handle:              Channel corresponding to Android metrics_d
27  */
28 struct srv_state {
29     handle_t ns_handle;
30 };
31 
is_ns_connected(struct srv_state * state)32 static inline bool is_ns_connected(struct srv_state* state) {
33     return state->ns_handle != INVALID_IPC_HANDLE;
34 }
35 
set_srv_state(struct tipc_port * port,struct srv_state * state)36 static inline void set_srv_state(struct tipc_port* port,
37                                  struct srv_state* state) {
38     port->priv = state;
39 }
40 
get_srv_state(const struct tipc_port * port)41 static inline struct srv_state* get_srv_state(const struct tipc_port* port) {
42     return (struct srv_state*)(port->priv);
43 }
44 
equal_uuid(const struct uuid * a,const struct uuid * b)45 static inline bool equal_uuid(const struct uuid* a, const struct uuid* b) {
46     return memcmp(a, b, sizeof(struct uuid)) == 0;
47 }
48 
49 __END_CDECLS
50 
51