2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 struct afb_binding_interface;
25 * Function for registering the binding
27 * A binding V1 MUST have an exported function of name
29 * afbBindingV1Register
31 * This function is called during loading of the binding. It
32 * receives an 'interface' that should be recorded for later access to
33 * functions provided by the framework.
35 * This function MUST return the address of a structure that describes
36 * the binding and its implemented verbs.
38 * In case of initialisation error, NULL must be returned.
40 * Be aware that the given 'interface' is not fully functionnal
41 * because no provision is given to the name and description
42 * of the binding. Check the function 'afbBindingV1ServiceInit'
43 * defined in the file <afb/afb-service-itf.h> because when
44 * the function 'afbBindingV1ServiceInit' is called, the 'interface'
45 * is fully functionnal.
47 extern const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *interface);
50 * When a binding have an exported implementation of the
51 * function 'afbBindingV1ServiceInit', defined below,
52 * the framework calls it for initialising the service after
53 * registration of all bindings.
55 * The object 'service' should be recorded. It has functions that
56 * allows the binding to call features with its own personality.
58 * The function should return 0 in case of success or, else, should return
61 extern int afbBindingV1ServiceInit(struct afb_service service);
64 * When a binding have an implementation of the function 'afbBindingV1ServiceEvent',
65 * defined below, the framework calls that function for any broadcasted event or for
66 * events that the service subscribed to in its name.
68 * It receive the 'event' name and its related data in 'object' (be aware that 'object'
71 extern void afbBindingV1ServiceEvent(const char *event, struct json_object *object);
75 * Enum for Session/Token/Assurance middleware.
76 * This enumeration is valid for bindings of type 1
80 AFB_SESSION_NONE = 0, /* nothing required */
81 AFB_SESSION_CREATE = 1, /* Obsolete */
82 AFB_SESSION_CLOSE = 2, /* After token authentification, closes the session at end */
83 AFB_SESSION_RENEW = 4, /* After token authentification, refreshes the token at end */
84 AFB_SESSION_CHECK = 8, /* Requires token authentification */
86 AFB_SESSION_LOA_GE = 16, /* check that the LOA is greater or equal to the given value */
87 AFB_SESSION_LOA_LE = 32, /* check that the LOA is lesser or equal to the given value */
88 AFB_SESSION_LOA_EQ = 48, /* check that the LOA is equal to the given value */
90 AFB_SESSION_LOA_SHIFT = 6, /* shift for LOA */
91 AFB_SESSION_LOA_MASK = 7, /* mask for LOA */
93 AFB_SESSION_LOA_0 = 0, /* value for LOA of 0 */
94 AFB_SESSION_LOA_1 = 64, /* value for LOA of 1 */
95 AFB_SESSION_LOA_2 = 128, /* value for LOA of 2 */
96 AFB_SESSION_LOA_3 = 192, /* value for LOA of 3 */
97 AFB_SESSION_LOA_4 = 256, /* value for LOA of 4 */
99 AFB_SESSION_LOA_LE_0 = AFB_SESSION_LOA_LE | AFB_SESSION_LOA_0, /* check LOA <= 0 */
100 AFB_SESSION_LOA_LE_1 = AFB_SESSION_LOA_LE | AFB_SESSION_LOA_1, /* check LOA <= 1 */
101 AFB_SESSION_LOA_LE_2 = AFB_SESSION_LOA_LE | AFB_SESSION_LOA_2, /* check LOA <= 2 */
102 AFB_SESSION_LOA_LE_3 = AFB_SESSION_LOA_LE | AFB_SESSION_LOA_3, /* check LOA <= 3 */
104 AFB_SESSION_LOA_GE_0 = AFB_SESSION_LOA_GE | AFB_SESSION_LOA_0, /* check LOA >= 0 */
105 AFB_SESSION_LOA_GE_1 = AFB_SESSION_LOA_GE | AFB_SESSION_LOA_1, /* check LOA >= 1 */
106 AFB_SESSION_LOA_GE_2 = AFB_SESSION_LOA_GE | AFB_SESSION_LOA_2, /* check LOA >= 2 */
107 AFB_SESSION_LOA_GE_3 = AFB_SESSION_LOA_GE | AFB_SESSION_LOA_3, /* check LOA >= 3 */
109 AFB_SESSION_LOA_EQ_0 = AFB_SESSION_LOA_EQ | AFB_SESSION_LOA_0, /* check LOA == 0 */
110 AFB_SESSION_LOA_EQ_1 = AFB_SESSION_LOA_EQ | AFB_SESSION_LOA_1, /* check LOA == 1 */
111 AFB_SESSION_LOA_EQ_2 = AFB_SESSION_LOA_EQ | AFB_SESSION_LOA_2, /* check LOA == 2 */
112 AFB_SESSION_LOA_EQ_3 = AFB_SESSION_LOA_EQ | AFB_SESSION_LOA_3 /* check LOA == 3 */
116 * Description of one verb of the API provided by the binding
117 * This enumeration is valid for bindings of type version 1
119 struct afb_verb_desc_v1
121 const char *name; /* name of the verb */
122 enum afb_session_v1 session; /* authorisation and session requirements of the verb */
123 void (*callback)(struct afb_req req); /* callback function implementing the verb */
124 const char *info; /* textual description of the verb */
128 * Description of the bindings of type version 1
130 struct afb_binding_desc_v1
132 const char *info; /* textual information about the binding */
133 const char *prefix; /* required prefix name for the binding */
134 const struct afb_verb_desc_v1 *verbs; /* array of descriptions of verbs terminated by a NULL name */
138 * Definition of the type+versions of the binding.
139 * The definition uses hashes.
141 enum afb_binding_type
143 AFB_BINDING_VERSION_1 = 123456789
147 * Description of a binding
151 enum afb_binding_type type; /* type of the binding */
153 struct afb_binding_desc_v1 v1; /* description of the binding of type 1 */