libamxb  4.8.2
Bus Agnostic C API
amxb_be_intf.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** SPDX-License-Identifier: BSD-2-Clause-Patent
4 **
5 ** SPDX-FileCopyrightText: Copyright (c) 2023 SoftAtHome
6 **
7 ** Redistribution and use in source and binary forms, with or without modification,
8 ** are permitted provided that the following conditions are met:
9 **
10 ** 1. Redistributions of source code must retain the above copyright notice,
11 ** this list of conditions and the following disclaimer.
12 **
13 ** 2. Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each copyright holder
18 ** and contributor hereby grants to those receiving rights under this license
19 ** a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
20 ** (except for failure to satisfy the conditions of this license) patent license
21 ** to make, have made, use, offer to sell, sell, import, and otherwise transfer
22 ** this software, where such license applies only to those patent claims, already
23 ** acquired or hereafter acquired, licensable by such copyright holder or contributor
24 ** that are necessarily infringed by:
25 **
26 ** (a) their Contribution(s) (the licensed copyrights of copyright holders and
27 ** non-copyrightable additions of contributors, in source or binary form) alone;
28 ** or
29 **
30 ** (b) combination of their Contribution(s) with the work of authorship to which
31 ** such Contribution(s) was added by such copyright holder or contributor, if,
32 ** at the time the Contribution is added, such addition causes such combination
33 ** to be necessarily infringed. The patent license shall not apply to any other
34 ** combinations which include the Contribution.
35 **
36 ** Except as expressly stated above, no rights or licenses from any copyright
37 ** holder or contributor is granted under this license, whether expressly, by
38 ** implication, estoppel or otherwise.
39 **
40 ** DISCLAIMER
41 **
42 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
51 ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 **
53 ****************************************************************************/
54 
55 #if !defined(__AMXB_BE_INTF_H__)
56 #define __AMXB_BE_INTF_H__
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #include <amxb/amxb_types.h>
64 
65 typedef struct _amxb_bus_ctx amxb_bus_ctx_t;
66 typedef struct _amxb_request amxb_request_t;
67 typedef struct _amxb_invoke amxb_invoke_t;
68 
341 #define AMXB_BE_DISCOVER_DESCRIBE 0x0001
342 #define AMXB_BE_DISCOVER_LIST 0x0002
343 #define AMXB_BE_DISCOVER 0x0004
344 #define AMXB_BE_DISCOVER_RESOLVE 0x0008
345 
346 //-----------------------------------------------------------------------------
417 typedef void*(* amxb_be_connect_fn_t) (const char* host,
418  const char* port,
419  const char* path,
420  amxp_signal_mngr_t* sigmngr);
421 
457 typedef void*(* amxb_be_listen_fn_t) (const char* host,
458  const char* port,
459  const char* path,
460  amxp_signal_mngr_t* sigmngr);
461 
489 typedef void*(* amxb_be_accept_fn_t) (void* const ctx,
490  amxp_signal_mngr_t* sigmngr);
491 
529 typedef int (* amxb_be_disconnect_fn_t) (void* const ctx);
530 
565 typedef int (* amxb_be_get_fd_fn_t) (void* const ctx);
566 
609 typedef int (* amxb_be_read_fn_t) (void* const ctx);
610 
611 typedef int (* amxb_be_read_raw_fn_t) (void* const ctx, void* buf, size_t count);
612 //-----------------------------------------------------------------------------
613 
614 //-----------------------------------------------------------------------------
638 typedef int (* amxb_be_new_invoke_fn_t) (amxb_invoke_t* invoke_ctx);
639 
659 typedef void (* amxb_be_free_invoke_fn_t) (amxb_invoke_t* invoke_ctx);
660 
748 typedef int (* amxb_be_invoke_fn_t) (void* const ctx,
749  amxb_invoke_t* invoke_ctx,
750  amxc_var_t* args,
751  amxb_request_t* request,
752  int timeout);
753 
852 typedef int (* amxb_be_async_invoke_fn_t) (void* const ctx,
853  amxb_invoke_t* invoke_ctx,
854  amxc_var_t* args,
855  amxb_request_t* request);
856 
889 typedef int (* amxb_be_close_request_fn_t) (void* const ctx,
890  amxb_request_t* request);
891 
920 typedef int (* amxb_be_wait_request_fn_t) (void* const ctx,
921  amxb_request_t* request,
922  int timeout);
923 //-----------------------------------------------------------------------------
924 
925 //-----------------------------------------------------------------------------
1017 typedef int (* amxb_be_subscribe_fn_t) (void* const ctx,
1018  const char* object);
1019 
1079 typedef int (* amxb_be_unsubscribe_fn_t) (void* const ctx,
1080  const char* object);
1081 //-----------------------------------------------------------------------------
1082 
1083 //-----------------------------------------------------------------------------
1130 typedef int (* amxb_be_register_fn_t) (void* const ctx,
1131  amxd_dm_t* const dm);
1132 //-----------------------------------------------------------------------------
1133 
1134 //-----------------------------------------------------------------------------
1162 typedef void (* amxb_be_free_fn_t) (void* const ctx);
1163 //-----------------------------------------------------------------------------
1164 
1165 //-----------------------------------------------------------------------------
1247 typedef int (* amxb_be_get_t) (void* const ctx,
1248  const char* object,
1249  const char* search_path,
1250  int32_t depth,
1251  uint32_t access,
1252  amxc_var_t* ret,
1253  int timeout);
1292 typedef int (* amxb_be_get_filtered_t) (void* const ctx,
1293  const char* object,
1294  const char* search_path,
1295  const char* filter,
1296  int32_t depth,
1297  uint32_t access,
1298  amxc_var_t* ret,
1299  int timeout);
1300 
1395 typedef int (* amxb_be_set_t) (void* const ctx,
1396  const char* object,
1397  const char* search_path,
1398  uint32_t flags,
1399  amxc_var_t* values,
1400  amxc_var_t* ovalues,
1401  uint32_t access,
1402  amxc_var_t* ret,
1403  int timeout);
1404 
1484 typedef int (* amxb_be_add_t) (void* const ctx,
1485  const char* object,
1486  const char* search_path,
1487  uint32_t index,
1488  const char* name,
1489  amxc_var_t* values,
1490  uint32_t access,
1491  amxc_var_t* ret,
1492  int timeout);
1493 
1552 typedef int (* amxb_be_del_t) (void* const ctx,
1553  const char* object,
1554  const char* search_path,
1555  uint32_t index,
1556  const char* name,
1557  uint32_t access,
1558  amxc_var_t* ret,
1559  int timeout);
1560 
1637 typedef int (* amxb_be_get_supported_t) (void* const ctx,
1638  const char* object,
1639  const char* search_path,
1640  uint32_t flags,
1641  amxc_var_t* retval,
1642  int timeout);
1643 
1644 typedef int (* amxb_be_describe_t) (void* const ctx,
1645  const char* object,
1646  const char* search_path,
1647  uint32_t flags,
1648  uint32_t access,
1649  amxc_var_t* retval,
1650  int timeout);
1651 
1652 typedef int (* amxb_be_list_t) (void* const ctx,
1653  const char* object,
1654  uint32_t flags,
1655  uint32_t access,
1656  amxb_request_t* request);
1657 
1658 typedef int (* amxb_be_wait_for_fn_t) (void* const ctx,
1659  const char* object);
1660 
1661 typedef uint32_t (* amxb_be_capabilities_fn_t) (void* const ctx);
1662 
1663 typedef bool (* amxb_be_has_fn_t) (void* const ctx,
1664  const char* object);
1665 
1690 typedef int (* amxb_be_get_instances_t) (void* const ctx,
1691  const char* object,
1692  const char* search_path,
1693  int32_t depth,
1694  uint32_t access,
1695  amxc_var_t* ret,
1696  int timeout);
1697 
1698 
1699 //-----------------------------------------------------------------------------
1700 
1701 //-----------------------------------------------------------------------------
1720 typedef int (* amxb_be_set_config_t) (amxc_var_t* const configuration);
1721 //-----------------------------------------------------------------------------
1722 
1736  amxc_htable_it_t it;
1737  void* handle;
1738  amxc_llist_t connections;
1739  const char* name;
1740  size_t size;
1771 };
1772 
1773 #ifdef __cplusplus
1774 }
1775 #endif
1776 
1777 #endif // __AMXB_BE_INTF_H__
int(* amxb_be_wait_for_fn_t)(void *const ctx, const char *object)
bool(* amxb_be_has_fn_t)(void *const ctx, const char *object)
int(* amxb_be_describe_t)(void *const ctx, const char *object, const char *search_path, uint32_t flags, uint32_t access, amxc_var_t *retval, int timeout)
int(* amxb_be_list_t)(void *const ctx, const char *object, uint32_t flags, uint32_t access, amxb_request_t *request)
uint32_t(* amxb_be_capabilities_fn_t)(void *const ctx)
int(* amxb_be_read_raw_fn_t)(void *const ctx, void *buf, size_t count)
Definition: amxb_be_intf.h:611
void(* amxb_be_free_fn_t)(void *const ctx)
Frees allocated memory for bus connection.
int(* amxb_be_register_fn_t)(void *const ctx, amxd_dm_t *const dm)
Registers an ambiorix data model to the bus system.
void *(* amxb_be_connect_fn_t)(const char *host, const char *port, const char *path, amxp_signal_mngr_t *sigmngr)
Opens a bus connection or creates a socket connection.
Definition: amxb_be_intf.h:417
void(* amxb_be_free_invoke_fn_t)(amxb_invoke_t *invoke_ctx)
Frees the bus specific data from the invoke context.
Definition: amxb_be_intf.h:659
int(* amxb_be_set_t)(void *const ctx, const char *object, const char *search_path, uint32_t flags, amxc_var_t *values, amxc_var_t *ovalues, uint32_t access, amxc_var_t *ret, int timeout)
Performs a set operation on one or more objects in the data model tree.
int(* amxb_be_set_config_t)(amxc_var_t *const configuration)
Passes a hash table variant containing configuration options to the back-end.
int(* amxb_be_async_invoke_fn_t)(void *const ctx, amxb_invoke_t *invoke_ctx, amxc_var_t *args, amxb_request_t *request)
Invokes a remote procedure call in the data model and return immediately without waiting for reply.
Definition: amxb_be_intf.h:852
int(* amxb_be_close_request_fn_t)(void *const ctx, amxb_request_t *request)
Closes or cancels a pending asynchronous request.
Definition: amxb_be_intf.h:889
int(* amxb_be_invoke_fn_t)(void *const ctx, amxb_invoke_t *invoke_ctx, amxc_var_t *args, amxb_request_t *request, int timeout)
Invokes a remote procedure call in the data model and waits for the reply.
Definition: amxb_be_intf.h:748
int(* amxb_be_get_t)(void *const ctx, const char *object, const char *search_path, int32_t depth, uint32_t access, amxc_var_t *ret, int timeout)
Performs a get operation on one or more objects in the data model tree.
int(* amxb_be_add_t)(void *const ctx, const char *object, const char *search_path, uint32_t index, const char *name, amxc_var_t *values, uint32_t access, amxc_var_t *ret, int timeout)
Performs an add instance operation on one multi instance object in the data model tree.
int(* amxb_be_read_fn_t)(void *const ctx)
Read data from file descriptor and dispatch the request.
Definition: amxb_be_intf.h:609
int(* amxb_be_get_supported_t)(void *const ctx, const char *object, const char *search_path, uint32_t flags, amxc_var_t *retval, int timeout)
Performs a get supported data model operation on a data model (sub-)tree.
int(* amxb_be_unsubscribe_fn_t)(void *const ctx, const char *object)
Removes a subscription for a specific object.
int(* amxb_be_disconnect_fn_t)(void *const ctx)
Closes a bus connection or disconnects a socket.
Definition: amxb_be_intf.h:529
void *(* amxb_be_accept_fn_t)(void *const ctx, amxp_signal_mngr_t *sigmngr)
Accepts or drops an incoming connection.
Definition: amxb_be_intf.h:489
int(* amxb_be_wait_request_fn_t)(void *const ctx, amxb_request_t *request, int timeout)
Waits until an asynchronous request has finished.
Definition: amxb_be_intf.h:920
int(* amxb_be_del_t)(void *const ctx, const char *object, const char *search_path, uint32_t index, const char *name, uint32_t access, amxc_var_t *ret, int timeout)
Performs a delete instance operation on one object in the data model tree.
int(* amxb_be_get_fd_fn_t)(void *const ctx)
Get the file descriptor that represents the opened bus connection or the connected socket.
Definition: amxb_be_intf.h:565
int(* amxb_be_new_invoke_fn_t)(amxb_invoke_t *invoke_ctx)
Updates the invoke context with bus specific data.
Definition: amxb_be_intf.h:638
void *(* amxb_be_listen_fn_t)(const char *host, const char *port, const char *path, amxp_signal_mngr_t *sigmngr)
Creates a listen socket.
Definition: amxb_be_intf.h:457
int(* amxb_be_get_filtered_t)(void *const ctx, const char *object, const char *search_path, const char *filter, int32_t depth, uint32_t access, amxc_var_t *ret, int timeout)
Performs a get operation on one or more objects in the data model tree.
int(* amxb_be_get_instances_t)(void *const ctx, const char *object, const char *search_path, int32_t depth, uint32_t access, amxc_var_t *ret, int timeout)
Performs a get instances data model operation on multi-instance objects.
int(* amxb_be_subscribe_fn_t)(void *const ctx, const char *object)
Creates a subscription for a specific object.
The back-end interface structure.
amxb_be_connect_fn_t connect
amxb_be_free_invoke_fn_t free_invoke
amxb_be_has_fn_t has
amxb_be_new_invoke_fn_t new_invoke
amxb_be_read_fn_t read
amxb_be_wait_for_fn_t wait_for
amxb_be_get_instances_t get_instances
amxb_be_get_supported_t get_supported
amxb_be_capabilities_fn_t capabilities
amxb_be_add_t add
amxb_be_disconnect_fn_t disconnect
amxb_be_set_t set
const char * name
amxb_be_subscribe_fn_t subscribe
amxb_be_accept_fn_t accept
amxb_be_describe_t describe
amxb_be_free_fn_t free
amxb_be_listen_fn_t listen
amxb_be_read_raw_fn_t read_raw
amxb_be_close_request_fn_t close_request
amxb_be_register_fn_t register_dm
amxc_llist_t connections
amxb_be_get_t get
amxb_be_invoke_fn_t invoke
amxb_be_unsubscribe_fn_t unsubscribe
amxc_htable_it_t it
amxb_be_async_invoke_fn_t async_invoke
amxb_be_del_t del
amxb_be_set_config_t set_config
amxb_be_wait_request_fn_t wait_request
amxb_be_list_t list
amxb_be_get_fd_fn_t get_fd
amxb_be_get_filtered_t get_filtered
char * object
Definition: amxb_types.h:151
A request structure.
Definition: amxb_types.h:138
static amxd_dm_t dm
Definition: test_amxb_e2e.c:85