Mistake on this page? Email us
pt_client_api.h
Go to the documentation of this file.
1 /*
2  * ----------------------------------------------------------------------------
3  * Copyright 2019 ARM Ltd.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ----------------------------------------------------------------------------
19  */
20 
21 #ifndef PT_API_VERSION
22 #define PT_API_VERSION 2
23 #endif
24 #if PT_API_VERSION != 2
25 #error "Including mixed versions of Protocol API"
26 #endif
27 
28 #ifndef PT_CLIENT_API_H
29 #define PT_CLIENT_API_H
30 
32 
51 int pt_api_init();
52 
64 typedef void (*pt_response_handler)(void *userdata);
65 
74 typedef void (*pt_connection_ready_cb)(connection_id_t connection_id, const char *name, void *userdata);
75 
83 typedef void (*pt_disconnected_cb)(connection_id_t connection_id, void *userdata);
84 
92 typedef void (*pt_connection_shutdown_cb)(connection_id_t connection_id, void *userdata);
93 
107 typedef void (*pt_certificate_renewal_notification_handler)(const connection_id_t connection_id,
108  const char *name,
109  int32_t initiator,
110  int32_t status,
111  const char *description,
112  void *userdata);
113 
117 typedef struct protocol_translator_callbacks {
118  pt_connection_ready_cb connection_ready_cb;
119  pt_disconnected_cb disconnected_cb;
120  pt_connection_shutdown_cb connection_shutdown_cb;
121  pt_certificate_renewal_notification_handler certificate_renewal_notifier_cb;
123 
132 pt_client_t *pt_client_create(const char *socket_path,
133  const protocol_translator_callbacks_t *pt_cbs);
134 
140 void pt_client_free(pt_client_t *client);
141 
149 connection_id_t pt_client_get_connection_id(pt_client_t *client);
150 
170 int pt_client_start(pt_client_t *client,
171  pt_response_handler success_handler,
172  pt_response_handler failure_handler,
173  const char *name,
174  void *userdata);
175 
184 pt_status_t pt_client_shutdown(pt_client_t *client);
185 
191 #endif
void(* pt_connection_ready_cb)(connection_id_t connection_id, const char *name, void *userdata)
A function prototype for calling the client code when the connection is ready for passing messages...
Definition: pt_client_api.h:74
struct protocol_translator_callbacks protocol_translator_callbacks_t
A structure to hold the callbacks of the protocol translator.
void pt_client_free(pt_client_t *client)
Frees the PT API client.
void(* pt_certificate_renewal_notification_handler)(const connection_id_t connection_id, const char *name, int32_t initiator, int32_t status, const char *description, void *userdata)
Type definition for certificate renewal notification. This callback will be called to notify the stat...
Definition: pt_client_api.h:107
void(* pt_disconnected_cb)(connection_id_t connection_id, void *userdata)
A function prototype for calling the client code when the connection is disconnected.
Definition: pt_client_api.h:83
pt_status_t pt_client_shutdown(pt_client_t *client)
Gracefully shuts down the protocol translator client.
Contains common structures and definitions for the protocol translator client.
connection_id_t pt_client_get_connection_id(pt_client_t *client)
May be used to get the connection ID from the client.
A structure to hold the callbacks of the protocol translator.
Definition: pt_api.h:344
void(* pt_connection_shutdown_cb)(connection_id_t connection_id, void *userdata)
A function prototype for calling the client code when the connection is shutting down.
Definition: pt_client_api.h:92
int pt_client_start(pt_client_t *client, pt_response_handler success_handler, pt_response_handler failure_handler, const char *name, void *userdata)
Starts the protocol translator client event loop and tries to connect to a local instance of Device M...
int pt_api_init()
Use this function to initialize the PT API.
void(* pt_response_handler)(void *userdata)
A function pointer type definition for callbacks given in the protocol translator API functions as an...
Definition: pt_client_api.h:64
pt_client_t * pt_client_create(const char *socket_path, const protocol_translator_callbacks_t *pt_cbs)
Creates an instance of a PT API client.