1 1.1 christos /* cti-services.h 2 1.1 christos * 3 1.1 christos * Copyright (c) 2020-2024 Apple Inc. All rights reserved. 4 1.1 christos * 5 1.1 christos * Licensed under the Apache License, Version 2.0 (the "License"); 6 1.1 christos * you may not use this file except in compliance with the License. 7 1.1 christos * You may obtain a copy of the License at 8 1.1 christos * 9 1.1 christos * http://www.apache.org/licenses/LICENSE-2.0 10 1.1 christos * 11 1.1 christos * Unless required by applicable law or agreed to in writing, software 12 1.1 christos * distributed under the License is distributed on an "AS IS" BASIS, 13 1.1 christos * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 1.1 christos * See the License for the specific language governing permissions and 15 1.1 christos * limitations under the License. 16 1.1 christos * 17 1.1 christos * This code adds border router support to 3rd party HomeKit Routers as part of Apples commitment to the CHIP project. 18 1.1 christos * 19 1.1 christos * Concise Thread Interface for Thread Border router control. 20 1.1 christos */ 21 1.1 christos 22 1.1 christos #ifndef __CTI_SERVICES_H__ 23 1.1 christos #define __CTI_SERVICES_H__ 24 1.1 christos 25 1.1 christos #include <netinet/in.h> 26 1.1 christos #include <arpa/inet.h> 27 1.1 christos typedef void *run_context_t; 28 1.1 christos #include "srp.h" 29 1.1 christos 30 1.1 christos #if (defined(__GNUC__) && (__GNUC__ >= 4)) 31 1.1 christos #define DNS_SERVICES_EXPORT __attribute__((visibility("default"))) 32 1.1 christos #else 33 1.1 christos #define DNS_SERVICES_EXPORT 34 1.1 christos #endif 35 1.1 christos 36 1.1 christos #include "cti-common.h" 37 1.1 christos 38 1.1 christos typedef enum _offmesh_route_origin { 39 1.1 christos offmesh_route_origin_user, 40 1.1 christos offmesh_route_origin_ncp, 41 1.1 christos } offmesh_route_origin_t; 42 1.1 christos 43 1.1 christos typedef enum _offmesh_route_preference { 44 1.1 christos offmesh_route_preference_low = -1, 45 1.1 christos offmesh_route_preference_medium, 46 1.1 christos offmesh_route_preference_high, 47 1.1 christos } offmesh_route_preference_t; 48 1.1 christos 49 1.1 christos typedef struct _cti_service { 50 1.1 christos uint64_t enterprise_number; 51 1.1 christos uint16_t service_type; 52 1.1 christos uint16_t service_version; 53 1.1 christos uint16_t rloc16; 54 1.1 christos uint16_t service_id; 55 1.1 christos uint8_t *NONNULL service; 56 1.1 christos uint8_t *NONNULL server; 57 1.1 christos size_t service_length; 58 1.1 christos size_t server_length; 59 1.1 christos int ref_count; 60 1.1 christos int flags; // E.g., kCTIFlag_NCP 61 1.1 christos } cti_service_t; 62 1.1 christos 63 1.1 christos typedef struct _cti_service_vec { 64 1.1 christos size_t num; 65 1.1 christos int ref_count; 66 1.1 christos cti_service_t *NULLABLE *NONNULL services; 67 1.1 christos } cti_service_vec_t; 68 1.1 christos 69 1.1 christos typedef struct _cti_prefix { 70 1.1 christos struct in6_addr prefix; 71 1.1 christos int prefix_length; 72 1.1 christos int metric; 73 1.1 christos int flags; 74 1.1 christos int rloc; 75 1.1 christos bool stable; 76 1.1 christos bool ncp; 77 1.1 christos int ref_count; 78 1.1 christos } cti_prefix_t; 79 1.1 christos 80 1.1 christos // Bits in the prefix flags 81 1.1 christos #define kCTIPriorityShift 14 82 1.1 christos #define kCTIPreferredShift 13 83 1.1 christos #define kCTISLAACShift 12 84 1.1 christos #define kCTIDHCPShift 11 85 1.1 christos #define kCTIConfigureShift 10 86 1.1 christos #define kCTIDefaultRouteShift 9 87 1.1 christos #define kCTIOnMeshShift 8 88 1.1 christos #define kCTIDNSShift 7 89 1.1 christos #define kCTIDPShift 6 90 1.1 christos 91 1.1 christos // Priority values 92 1.1 christos #define kCTIPriorityMedium 0 93 1.1 christos #define kCTIPriorityHigh 1 94 1.1 christos #define kCTIPriorityReserved 2 95 1.1 christos #define kCTIPriorityLow 3 96 1.1 christos 97 1.1 christos // Macros to fetch values from the prefix flags 98 1.1 christos #define CTI_PREFIX_FLAGS_PRIORITY(flags) (((flags) >> kCTIPriorityShift) & 3) 99 1.1 christos #define CTI_PREFIX_FLAGS_PREFERRED(flags) (((flags) >> kCTIPreferredShift) & 1) 100 1.1 christos #define CTI_PREFIX_FLAGS_SLAAC(flags) (((flags) >> kCTISLAACShift) & 1) 101 1.1 christos #define CTI_PREFIX_FLAGS_DHCP(flags) (((flags) >> kCTIDHCPShift) & 1) 102 1.1 christos #define CTI_PREFIX_FLAGS_CONFIGURE(flags) (((flags) >> kCTIConfigureShift) & 1) 103 1.1 christos #define CTI_PREFIX_FLAGS_DEFAULT_ROUTE(flags) (((flags) >> kCTIDefaultRouteShift) & 1) 104 1.1 christos #define CTI_PREFIX_FLAGS_ON_MESH(flags) (((flags) >> kCTIOnMeshShift) & 1) 105 1.1 christos #define CTI_PREFIX_FLAGS_DNS(flags) (((flags) >> kCTIDNSShift) & 1) 106 1.1 christos #define CTI_PREFIX_DLAGS_DP(flags) (((flags) >> kCTIDPShift) & 1) 107 1.1 christos 108 1.1 christos // Macros to set values in the prefix flags 109 1.1 christos #define CTI_PREFIX_FLAGS_PRIORITY_SET(flags, value) ((flags) = \ 110 1.1 christos (((flags) & ~(3 << kCTIPriorityShift)) | \ 111 1.1 christos (((value) & 3) << kCTIPriorityShift))) 112 1.1 christos #define CTI_PREFIX_FLAGS_PREFERRED_SET(flags, value) ((flags) = \ 113 1.1 christos (((flags) & ~(1 << kCTIPreferredShift)) | \ 114 1.1 christos (((value) & 1) << kCTIPreferredShift))) 115 1.1 christos #define CTI_PREFIX_FLAGS_SLAAC_SET(flags, value) ((flags) = \ 116 1.1 christos (((flags) & ~(1 << kCTISLAACShift)) | \ 117 1.1 christos (((value) & 1) << kCTISLAACShift))) 118 1.1 christos #define CTI_PREFIX_FLAGS_DHCP_SET(flags, value) ((flags) = \ 119 1.1 christos (((flags) & ~(1 << kCTIDHCPShift)) | \ 120 1.1 christos (((value) & 1) << kCTIDHCPShift))) 121 1.1 christos #define CTI_PREFIX_FLAGS_CONFIGURE_SET(flags, value) ((flags) = \ 122 1.1 christos (((flags) & ~(1 << kCTIConfigureShift)) | \ 123 1.1 christos (((value) & 1) << kCTIConfigureShift))) 124 1.1 christos #define CTI_PREFIX_FLAGS_DEFAULT_ROUTE_SET(flags, value) ((flags) = \ 125 1.1 christos (((flags) & ~(1 << kCTIDefaultRouteShift)) | \ 126 1.1 christos (((value) & 1) << kCTIDefaultRouteShift))) 127 1.1 christos #define CTI_PREFIX_FLAGS_ON_MESH_SET(flags, value) ((flags) = \ 128 1.1 christos (((flags) & ~(1 << kCTIOnMeshShift)) | \ 129 1.1 christos (((value) & 1) << kCTIOnMeshShift))) 130 1.1 christos #define CTI_PREFIX_FLAGS_DNS_SET(flags, value) ((flags) = \ 131 1.1 christos (((flags) & ~(1 << kCTIDNSShift)) | \ 132 1.1 christos (((value) & 1) << kCTIDNSShift))) 133 1.1 christos #define CTI_PREFIX_DLAGS_DP_SET(flags, value) ((flags) = \ 134 1.1 christos (((flags) & ~(1 << kCTIDPShift)) | \ 135 1.1 christos (((value) & 1) << kCTIDPShift))) 136 1.1 christos 137 1.1 christos typedef struct _cti_prefix_vec { 138 1.1 christos size_t num; 139 1.1 christos int ref_count; 140 1.1 christos cti_prefix_t *NULLABLE *NONNULL prefixes; 141 1.1 christos } cti_prefix_vec_t; 142 1.1 christos 143 1.1 christos typedef struct _cti_route { 144 1.1 christos struct in6_addr prefix; 145 1.1 christos int prefix_length; 146 1.1 christos offmesh_route_origin_t origin; 147 1.1 christos bool nat64; 148 1.1 christos bool stable; 149 1.1 christos offmesh_route_preference_t preference; 150 1.1 christos int rloc; 151 1.1 christos bool next_hop_is_host; 152 1.1 christos int ref_count; 153 1.1 christos } cti_route_t; 154 1.1 christos 155 1.1 christos typedef struct _cti_route_vec { 156 1.1 christos size_t num; 157 1.1 christos int ref_count; 158 1.1 christos cti_route_t *NULLABLE *NONNULL routes; 159 1.1 christos } cti_route_vec_t; 160 1.1 christos 161 1.1 christos typedef struct srp_server_state srp_server_t; 162 1.1 christos 163 1.1 christos /* cti_reply: 164 1.1 christos * 165 1.1 christos * A general reply mechanism to indicate success or failure for a cti call that doesn't 166 1.1 christos * return any data. 167 1.1 christos * 168 1.1 christos * cti_reply parameters: 169 1.1 christos * 170 1.1 christos * context: The context that was passed to the cti service call to which this is a callback. 171 1.1 christos * 172 1.1 christos * status: Will be kCTIStatus_NoError on success, otherwise will indicate the 173 1.1 christos * failure that occurred. 174 1.1 christos */ 175 1.1 christos 176 1.1 christos typedef void 177 1.1 christos (*cti_reply_t)(void *NULLABLE context, cti_status_t status); 178 1.1 christos 179 1.1 christos /* cti_string_property_reply: Callback for get calls that fetch a string property 180 1.1 christos * 181 1.1 christos * Called exactly once in response to (for example) a cti_get_tunnel_name() or cti_get_on_link_prefix() call, either 182 1.1 christos * with an error or with a string containing the response. 183 1.1 christos * 184 1.1 christos * cti_reply parameters: 185 1.1 christos * 186 1.1 christos * context: The context that was passed to the cti service call to which this is a callback. 187 1.1 christos * 188 1.1 christos * tunnel_name: If error is kCTIStatus_NoError, a string containing the name of the Thread 189 1.1 christos * interface. 190 1.1 christos * 191 1.1 christos * status: Will be kCTIStatus_NoError on success, otherwise will indicate the 192 1.1 christos * failure that occurred. 193 1.1 christos */ 194 1.1 christos 195 1.1 christos typedef void 196 1.1 christos (*cti_string_property_reply_t)(void *NULLABLE context, const char *NONNULL string, 197 1.1 christos cti_status_t status); 198 1.1 christos 199 1.1 christos /* cti_get_tunnel_name 200 1.1 christos * 201 1.1 christos * Get the name of the tunnel that wpantund is presenting as the Thread network interface. 202 1.1 christos * The tunnel name is passed to the reply callback if the request succeeds; otherwise an error 203 1.1 christos * is either returned immediately or returned to the callback. 204 1.1 christos * 205 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 206 1.1 christos * an event occurs. 207 1.1 christos * 208 1.1 christos * callback: CallBack function for the client that indicates success or failure. 209 1.1 christos * 210 1.1 christos * client_queue: Queue the client wants to schedule the callback on 211 1.1 christos * 212 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating the 213 1.1 christos * error that occurred. Note: A return value of kCTIStatus_NoError does not mean that the 214 1.1 christos * request succeeded, merely that it was successfully started. 215 1.1 christos */ 216 1.1 christos 217 1.1 christos #define cti_get_tunnel_name(server, context, callback, client_queue) \ 218 1.1 christos cti_get_tunnel_name_(server, context, callback, client_queue, __FILE__, __LINE__) 219 1.1 christos DNS_SERVICES_EXPORT cti_status_t 220 1.1 christos cti_get_tunnel_name_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_string_property_reply_t NONNULL callback, 221 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 222 1.1 christos 223 1.1 christos /* cti_track_neighbor_ml_eid 224 1.1 christos * 225 1.1 christos * Track changes in our neighbor's mesh-local address (ML-EID). This makes sense when acting as an end device, not as a 226 1.1 christos * router. The ML-EID tunnel is passed to the reply callback if the request succeeds; otherwise an error is either 227 1.1 christos * returned immediately or returned to the callback. 228 1.1 christos * 229 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 230 1.1 christos * an event occurs. 231 1.1 christos * 232 1.1 christos * callback: CallBack function for the client that indicates success or failure. 233 1.1 christos * 234 1.1 christos * client_queue: Queue the client wants to schedule the callback on 235 1.1 christos * 236 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating the 237 1.1 christos * error that occurred. Note: A return value of kCTIStatus_NoError does not mean that the 238 1.1 christos * request succeeded, merely that it was successfully started. 239 1.1 christos */ 240 1.1 christos 241 1.1 christos #define cti_track_neighbor_ml_eid(server, ref, context, callback, client_queue) \ 242 1.1 christos cti_track_neighbor_ml_eid_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 243 1.1 christos DNS_SERVICES_EXPORT cti_status_t 244 1.1 christos cti_track_neighbor_ml_eid_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, 245 1.1 christos void *NULLABLE context, cti_string_property_reply_t NONNULL callback, 246 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 247 1.1 christos 248 1.1 christos /* cti_get_mesh_local_prefix 249 1.1 christos * 250 1.1 christos * Get the mesh_local IPv6 prefix that is in use on the Thread mesh. The prefix is passed to the reply callback if the 251 1.1 christos * request succeeds; otherwise an error is either returned immediately or returned to the callback. 252 1.1 christos * 253 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 254 1.1 christos * an event occurs. 255 1.1 christos * 256 1.1 christos * callback: CallBack function for the client that indicates success or failure. 257 1.1 christos * 258 1.1 christos * client_queue: Queue the client wants to schedule the callback on 259 1.1 christos * 260 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating the 261 1.1 christos * error that occurred. Note: A return value of kCTIStatus_NoError does not mean that the 262 1.1 christos * request succeeded, merely that it was successfully started. 263 1.1 christos */ 264 1.1 christos 265 1.1 christos #define cti_get_mesh_local_prefix(server, context, callback, client_queue) \ 266 1.1 christos cti_get_mesh_local_prefix_(server, context, callback, client_queue, __FILE__, __LINE__) 267 1.1 christos DNS_SERVICES_EXPORT cti_status_t 268 1.1 christos cti_get_mesh_local_prefix_(srp_server_t *NULLABLE server, 269 1.1 christos void *NULLABLE context, cti_string_property_reply_t NONNULL callback, 270 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 271 1.1 christos 272 1.1 christos /* cti_get_mesh_local_address 273 1.1 christos * 274 1.1 christos * Get the mesh_local IPv6 address that is in use on this device on the Thread mesh. The address is passed to the reply 275 1.1 christos * callback if the request succeeds; otherwise an error is either returned immediately or returned to the callback. 276 1.1 christos * 277 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 278 1.1 christos * an event occurs. 279 1.1 christos * 280 1.1 christos * callback: CallBack function for the client that indicates success or failure. 281 1.1 christos * 282 1.1 christos * client_queue: Queue the client wants to schedule the callback on 283 1.1 christos * 284 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating the 285 1.1 christos * error that occurred. Note: A return value of kCTIStatus_NoError does not mean that the 286 1.1 christos * request succeeded, merely that it was successfully started. 287 1.1 christos */ 288 1.1 christos 289 1.1 christos #define cti_get_mesh_local_address(server, context, callback, client_queue) \ 290 1.1 christos cti_get_mesh_local_address_(server, context, callback, client_queue, __FILE__, __LINE__) 291 1.1 christos DNS_SERVICES_EXPORT cti_status_t 292 1.1 christos cti_get_mesh_local_address_(srp_server_t *NULLABLE server, 293 1.1 christos void *NULLABLE context, cti_string_property_reply_t NONNULL callback, 294 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 295 1.1 christos 296 1.1 christos /* 297 1.1 christos * cti_service_vec_create 298 1.1 christos * 299 1.1 christos * creates a service array vector of specified length 300 1.1 christos * 301 1.1 christos * num_services: Number of service slots available in the service vector. 302 1.1 christos * 303 1.1 christos * return value: NULL, if the call failed; otherwise a service vector capable of containing the requested number of 304 1.1 christos * services. 305 1.1 christos */ 306 1.1 christos cti_service_vec_t *NULLABLE 307 1.1 christos cti_service_vec_create_(size_t num_services, const char *NONNULL file, int line); 308 1.1 christos #define cti_service_vec_create(num_services) cti_service_vec_create_(num_services, __FILE__, __LINE__) 309 1.1 christos 310 1.1 christos /* 311 1.1 christos * cti_service_vec_release 312 1.1 christos * 313 1.1 christos * decrements the reference count on the provided service vector and, if it reaches zero, finalizes the service vector, 314 1.1 christos * which calls cti_service_release on each service in the vector, potentially also finalizing them. 315 1.1 christos * 316 1.1 christos * num_services: Number of service slots available in the service vector. 317 1.1 christos * 318 1.1 christos * return value: NULL, if the call failed; otherwise a service vector capable of containing the requested number of 319 1.1 christos * services. 320 1.1 christos */ 321 1.1 christos 322 1.1 christos void 323 1.1 christos cti_service_vec_release_(cti_service_vec_t *NONNULL services, const char *NONNULL file, int line); 324 1.1 christos #define cti_service_vec_release(services) cti_service_vec_release_(services, __FILE__, __LINE__) 325 1.1 christos 326 1.1 christos /* 327 1.1 christos * cti_service_create 328 1.1 christos * 329 1.1 christos * Creates a service containing the specified information. service and server are retained, and will be 330 1.1 christos * freed using free() when the service object is finalized. Caller must not retain or free these values, and 331 1.1 christos * they must be allocated on the malloc heap. 332 1.1 christos * 333 1.1 christos * enterprise_number: The enterprise number for this service. 334 1.1 christos * 335 1.1 christos * service_type: The service type, from the service data. 336 1.1 christos * 337 1.1 christos * service_version: The service version, from the service data. 338 1.1 christos * 339 1.1 christos * server: Server information for this service, stored in network byte order. Format depends on service type. 340 1.1 christos * 341 1.1 christos * server_length: Length of server information in bytes. 342 1.1 christos * 343 1.1 christos * flags: Thread network status flags, e.g. NCP versue User 344 1.1 christos * 345 1.1 christos * return value: NULL, if the call failed; otherwise a service object containing the specified state. 346 1.1 christos */ 347 1.1 christos 348 1.1 christos cti_service_t *NULLABLE 349 1.1 christos cti_service_create_(uint64_t enterprise_number, uint16_t rloc16, uint16_t service_type, uint16_t service_version, 350 1.1 christos uint8_t *NONNULL service, size_t service_length, uint8_t *NONNULL server, size_t server_length, 351 1.1 christos uint16_t service_id, int flags, const char *NONNULL file, int line); 352 1.1 christos #define cti_service_create(enterprise_number, rloc16, service_type, service_version, service, service_length, \ 353 1.1 christos server, server_length, service_id, flags) \ 354 1.1 christos cti_service_create_(enterprise_number, rloc16, service_type, service_version, service, service_length, \ 355 1.1 christos server, server_length, service_id, flags, __FILE__, __LINE__) 356 1.1 christos 357 1.1 christos /* 358 1.1 christos * cti_service_vec_release 359 1.1 christos * 360 1.1 christos * decrements the reference count on the provided service vector and, if it reaches zero, finalizes the service vector, 361 1.1 christos * which calls cti_service_release on each service in the vector, potentially also finalizing them. 362 1.1 christos * 363 1.1 christos * services: The service vector to release 364 1.1 christos * 365 1.1 christos * return value: NULL, if the call failed; otherwise a service vector capable of containing the requested number of 366 1.1 christos * services. 367 1.1 christos */ 368 1.1 christos 369 1.1 christos void 370 1.1 christos cti_service_release_(cti_service_t *NONNULL service, const char *NONNULL file, int line); 371 1.1 christos #define cti_service_release(services) cti_service_release(service, __FILE__, __LINE__) 372 1.1 christos 373 1.1 christos /* cti_service_reply: Callback from cti_get_service_list() 374 1.1 christos * 375 1.1 christos * Called when an error occurs during processing of the cti_get_service_list call, or when data 376 1.1 christos * is available in response to the call. 377 1.1 christos * 378 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 379 1.1 christos * releasing the connection state and restarting if needed. 380 1.1 christos * 381 1.1 christos * The callback will be called once immediately upon success, and once again each time the service list 382 1.1 christos * is updated. If the callback wishes to retain either the cti_service_vec_t or any of the elements 383 1.1 christos * of that vector, the appropriate retain function should be called; when the object is no longer needed, 384 1.1 christos * the corresponding release call must be called. 385 1.1 christos * 386 1.1 christos * cti_reply parameters: 387 1.1 christos * 388 1.1 christos * context: The context that was passed to the cti service call to which this is a callback. 389 1.1 christos * 390 1.1 christos * services: If status is kCTIStatus_NoError, a cti_service_vec_t containing the list of services 391 1.1 christos * provided in the update. 392 1.1 christos * 393 1.1 christos * status: Will be kCTIStatus_NoError if the service list request is successful, or 394 1.1 christos * will indicate the failure that occurred. 395 1.1 christos */ 396 1.1 christos 397 1.1 christos typedef void 398 1.1 christos (*cti_service_reply_t)(void *NULLABLE context, cti_service_vec_t *NULLABLE services, cti_status_t status); 399 1.1 christos 400 1.1 christos /* cti_get_service_list 401 1.1 christos * 402 1.1 christos * Requests wpantund to immediately send the current list of services published in the Thread network data. 403 1.1 christos * Whenever the service list is updated, the callback will be called again with the new information. A 404 1.1 christos * return value of kCTIStatus_NoError means that the caller can expect the reply callback to be called at least 405 1.1 christos * once. Any other error status means that the request could not be sent, and the callback will never be 406 1.1 christos * called. 407 1.1 christos * 408 1.1 christos * To discontinue receiving service add/remove callbacks, the calling program should call 409 1.1 christos * cti_connection_ref_deallocate on the conn_ref returned by a successful call to get_service_list(); 410 1.1 christos * 411 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 412 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 413 1.1 christos * 414 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 415 1.1 christos * an event occurs. 416 1.1 christos * 417 1.1 christos * callback: CallBack function for the client that indicates success or failure. 418 1.1 christos * If the get_services call fails, response will be NULL and status 419 1.1 christos * will indicate what went wrong. No further callbacks can be expected 420 1.1 christos * after this. If the request succeeds, then the callback will be called 421 1.1 christos * once immediately with the current service list, and then again whenever 422 1.1 christos * the service list is updated. 423 1.1 christos * 424 1.1 christos * client_queue: Queue the client wants to schedule the callback on 425 1.1 christos * 426 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 427 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 428 1.1 christos * that the request succeeded, merely that it was successfully started. 429 1.1 christos */ 430 1.1 christos 431 1.1 christos #define cti_get_service_list(server, ref, context, callback, client_queue) \ 432 1.1 christos cti_get_service_list_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 433 1.1 christos DNS_SERVICES_EXPORT cti_status_t 434 1.1 christos cti_get_service_list_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, void *NULLABLE context, 435 1.1 christos cti_service_reply_t NONNULL callback, run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 436 1.1 christos 437 1.1 christos /* 438 1.1 christos * cti_service_vec_create 439 1.1 christos * 440 1.1 christos * creates a service array vector of specified length 441 1.1 christos * 442 1.1 christos * num_prefixes: Number of prefix slots available in the prefix vector. 443 1.1 christos * 444 1.1 christos * return value: NULL, if the call failed; otherwise a prefix vector capable of containing the requested number of 445 1.1 christos * prefixes. 446 1.1 christos */ 447 1.1 christos cti_prefix_vec_t *NULLABLE 448 1.1 christos cti_prefix_vec_create_(size_t num_prefixes, const char *NONNULL file, int line); 449 1.1 christos #define cti_prefix_vec_create(num_prefixes) cti_prefix_vec_create_(num_prefixes, __FILE__, __LINE__) 450 1.1 christos 451 1.1 christos /* 452 1.1 christos * cti_prefix_vec_release 453 1.1 christos * 454 1.1 christos * decrements the reference count on the provided prefix vector and, if it reaches zero, finalizes the prefix vector, 455 1.1 christos * which calls cti_prefix_release on each prefix in the vector, potentially also finalizing them. 456 1.1 christos * 457 1.1 christos * num_prefixes: Number of prefix slots available in the prefix vector. 458 1.1 christos * 459 1.1 christos * return value: NULL, if the call failed; otherwise a prefix vector capable of containing the requested number of 460 1.1 christos * prefixes. 461 1.1 christos */ 462 1.1 christos 463 1.1 christos void 464 1.1 christos cti_prefix_vec_release_(cti_prefix_vec_t *NONNULL prefixes, const char *NONNULL file, int line); 465 1.1 christos #define cti_prefix_vec_release(prefixes) cti_prefix_vec_release_(prefixes, __FILE__, __LINE__) 466 1.1 christos 467 1.1 christos /* 468 1.1 christos * cti_prefix_create 469 1.1 christos * 470 1.1 christos * Creates a prefix containing the specified information. prefix and server are retained, and will be 471 1.1 christos * freed using free() when the prefix object is finalized. Caller must not retain or free these values, and 472 1.1 christos * they must be allocated on the malloc heap. 473 1.1 christos * 474 1.1 christos * enterprise_number: The enterprise number for this prefix. 475 1.1 christos * 476 1.1 christos * prefix_type: The prefix type, from the prefix data. 477 1.1 christos * 478 1.1 christos * prefix_version: The prefix version, from the prefix data. 479 1.1 christos * 480 1.1 christos * server: Server information for this prefix, stored in network byte order. Format depends on prefix type. 481 1.1 christos * 482 1.1 christos * server_length: Length of server information in bytes. 483 1.1 christos * 484 1.1 christos * flags: Thread network status flags, e.g. NCP versue User 485 1.1 christos * 486 1.1 christos * return value: NULL, if the call failed; otherwise a prefix object containing the specified state. 487 1.1 christos */ 488 1.1 christos 489 1.1 christos cti_prefix_t *NULLABLE 490 1.1 christos cti_prefix_create_(struct in6_addr *NONNULL prefix, int prefix_length, int metric, int flags, int rloc, bool stable, bool ncp, 491 1.1 christos const char *NONNULL file, int line); 492 1.1 christos #define cti_prefix_create(prefix, prefix_length, metric, flags, rloc, stable, ncp) \ 493 1.1 christos cti_prefix_create_(prefix, prefix_length, metric, flags, rloc, stable, ncp, __FILE__, __LINE__) 494 1.1 christos 495 1.1 christos /* 496 1.1 christos * cti_prefix_vec_release 497 1.1 christos * 498 1.1 christos * decrements the reference count on the provided prefix vector and, if it reaches zero, finalizes the prefix vector, 499 1.1 christos * which calls cti_prefix_release on each prefix in the vector, potentially also finalizing them. 500 1.1 christos * 501 1.1 christos * prefixes: The prefix vector to release. 502 1.1 christos * 503 1.1 christos * return value: NULL, if the call failed; otherwise a prefix vector capable of containing the requested number of 504 1.1 christos * prefixes. 505 1.1 christos */ 506 1.1 christos 507 1.1 christos void 508 1.1 christos cti_prefix_release_(cti_prefix_t *NONNULL prefix, const char *NONNULL file, int line); 509 1.1 christos #define cti_prefix_release(prefixes) cti_prefix_release(prefix, __FILE__, __LINE__) 510 1.1 christos 511 1.1 christos /* cti_prefix_reply: Callback from cti_get_prefix_list() 512 1.1 christos * 513 1.1 christos * Called when an error occurs during processing of the cti_get_prefix_list call, or when a prefix 514 1.1 christos * is added or removed. 515 1.1 christos * 516 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 517 1.1 christos * releasing the connection state and restarting if needed. 518 1.1 christos * 519 1.1 christos * The callback will be called once for each prefix present on the Thread network at the time 520 1.1 christos * get_prefix_list() is first called, and then again whenever a prefix is added or removed. 521 1.1 christos * 522 1.1 christos * cti_reply parameters: 523 1.1 christos * 524 1.1 christos * context: The context that was passed to the cti prefix call to which this is a callback. 525 1.1 christos * 526 1.1 christos * prefix_vec: If status is kCTIStatus_NoError, a vector containing all of the prefixes that were reported in 527 1.1 christos * this event. 528 1.1 christos * 529 1.1 christos * status: Will be kCTIStatus_NoError if the prefix list request is successful, or 530 1.1 christos * will indicate the failure that occurred. 531 1.1 christos */ 532 1.1 christos 533 1.1 christos typedef void 534 1.1 christos (*cti_prefix_reply_t)(void *NULLABLE context, cti_prefix_vec_t *NULLABLE prefixes, cti_status_t status); 535 1.1 christos 536 1.1 christos /* cti_get_prefix_list 537 1.1 christos * 538 1.1 christos * Requests wpantund to immediately send the current list of off-mesh prefixes configured in the Thread 539 1.1 christos * network data. Whenever the prefix list is updated, the callback will be called again with the new 540 1.1 christos * information. A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be 541 1.1 christos * called at least once. Any other error means that the request could not be sent, and the callback will 542 1.1 christos * never be called. 543 1.1 christos * 544 1.1 christos * To discontinue receiving prefix add/remove callbacks, the calling program should call 545 1.1 christos * cti_connection_ref_deallocate on the conn_ref returned by a successful call to get_prefix_list(); 546 1.1 christos * 547 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 548 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 549 1.1 christos * 550 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 551 1.1 christos * an event occurs. 552 1.1 christos * 553 1.1 christos * callback: CallBack function for the client that indicates success or failure. 554 1.1 christos * 555 1.1 christos * client_queue: Queue the client wants to schedule the callback on 556 1.1 christos * 557 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 558 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 559 1.1 christos * that the request succeeded, merely that it was successfully started. 560 1.1 christos */ 561 1.1 christos 562 1.1 christos #define cti_get_prefix_list(server, ref, context, callback, client_queue) \ 563 1.1 christos cti_get_prefix_list_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 564 1.1 christos DNS_SERVICES_EXPORT cti_status_t 565 1.1 christos cti_get_prefix_list_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, void *NULLABLE context, 566 1.1 christos cti_prefix_reply_t NONNULL callback, run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 567 1.1 christos 568 1.1 christos /* cti_state_reply: Callback from cti_get_state() 569 1.1 christos * 570 1.1 christos * Called when an error occurs during processing of the cti_get_state call, or when network state 571 1.1 christos * information is available. 572 1.1 christos * 573 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 574 1.1 christos * releasing the connection state and restarting if needed. 575 1.1 christos * 576 1.1 christos * The callback will be called initially to report the network state, and subsequently whenever the 577 1.1 christos * network state changes. 578 1.1 christos * 579 1.1 christos * cti_reply parameters: 580 1.1 christos * 581 1.1 christos * context: The context that was passed to the cti state call to which this is a callback. 582 1.1 christos * 583 1.1 christos * state: The network state. 584 1.1 christos * 585 1.1 christos * status: Will be kCTIStatus_NoError if the prefix list request is successful, or 586 1.1 christos * will indicate the failure that occurred. 587 1.1 christos */ 588 1.1 christos 589 1.1 christos typedef void 590 1.1 christos (*cti_state_reply_t)(void *NULLABLE context, cti_network_state_t state, cti_status_t status); 591 1.1 christos 592 1.1 christos /* cti_get_state 593 1.1 christos * 594 1.1 christos * Requests wpantund to immediately send the current state of the thread network. Whenever the thread 595 1.1 christos * network state changes, the callback will be called again with the new state. A return value of 596 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called at least once. Any 597 1.1 christos * other error means that the request could not be sent, and the callback will never be called. 598 1.1 christos * 599 1.1 christos * To discontinue receiving state change callbacks, the calling program should call 600 1.1 christos * cti_connection_ref_deallocate on the conn_ref returned by a successful call to cti_get_state(); 601 1.1 christos * 602 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 603 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 604 1.1 christos * 605 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 606 1.1 christos * an event occurs. 607 1.1 christos * 608 1.1 christos * callback: CallBack function for the client that indicates success or failure. 609 1.1 christos * 610 1.1 christos * client_queue: Queue the client wants to schedule the callback on 611 1.1 christos * 612 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 613 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 614 1.1 christos * that the request succeeded, merely that it was successfully started. 615 1.1 christos */ 616 1.1 christos 617 1.1 christos #define cti_get_state(server, ref, context, callback, client_queue) \ 618 1.1 christos cti_get_state_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 619 1.1 christos DNS_SERVICES_EXPORT cti_status_t 620 1.1 christos cti_get_state_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, void *NULLABLE context, 621 1.1 christos cti_state_reply_t NONNULL callback, run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 622 1.1 christos 623 1.1 christos /* cti_uint64_property_reply: Callback from cti_get_partition_id() or cti_get_xpanid() 624 1.1 christos * 625 1.1 christos * Called when an error occurs during processing of the cti_get_* call, or when a new value for the requested property 626 1.1 christos * is available. 627 1.1 christos * 628 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 629 1.1 christos * releasing the connection and restarting if needed. 630 1.1 christos * 631 1.1 christos * The callback will be called initially to report the current value for the property, and subsequently whenever the 632 1.1 christos * property changes. 633 1.1 christos * 634 1.1 christos * cti_uint64_property_reply parameters: 635 1.1 christos * 636 1.1 christos * context: The context that was passed to the cti prefix call to which this is a callback. 637 1.1 christos * 638 1.1 christos * property_value The value of the property (only valid if status is kCTIStatus_NoError). 639 1.1 christos * 640 1.1 christos * status: Will be kCTIStatus_NoError if the partition ID request is successful, or will indicate the failure 641 1.1 christos * that occurred. 642 1.1 christos */ 643 1.1 christos 644 1.1 christos typedef void 645 1.1 christos (*cti_uint64_property_reply_t)(void *NULLABLE context, uint64_t property_value, cti_status_t status); 646 1.1 christos 647 1.1 christos /* cti_get_partition_id 648 1.1 christos * 649 1.1 christos * Requests wpantund to immediately send the current partition_id of the thread network. Whenever the thread 650 1.1 christos * network partition_id changes, the callback will be called again with the new partition_id. A return value of 651 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called at least once. Any 652 1.1 christos * other error means that the request could not be sent, and the callback will never be called. 653 1.1 christos * 654 1.1 christos * To discontinue receiving partition_id change callbacks, the calling program should call 655 1.1 christos * cti_connection_ref_deallocate on the conn_ref returned by a successful call to cti_get_partition_id(); 656 1.1 christos * 657 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 658 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 659 1.1 christos * 660 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 661 1.1 christos * an event occurs. 662 1.1 christos * callback: CallBack function for the client that indicates success or failure. 663 1.1 christos * 664 1.1 christos * client_queue: Queue the client wants to schedule the callback on 665 1.1 christos * 666 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 667 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 668 1.1 christos * that the request succeeded, merely that it was successfully started. 669 1.1 christos */ 670 1.1 christos 671 1.1 christos #define cti_get_partition_id(server, ref, context, callback, client_queue) \ 672 1.1 christos cti_get_partition_id_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 673 1.1 christos DNS_SERVICES_EXPORT cti_status_t 674 1.1 christos cti_get_partition_id_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, void *NULLABLE context, 675 1.1 christos cti_uint64_property_reply_t NONNULL callback, run_context_t NULLABLE client_queue, 676 1.1 christos const char *NONNULL file, int line); 677 1.1 christos 678 1.1 christos /* cti_get_extended_pan_id 679 1.1 christos * 680 1.1 christos * Requests wpantund to immediately send the current extended_pan_id of the thread network. Whenever the thread 681 1.1 christos * network extended_pan_id changes, the callback will be called again with the new extended_pan_id. A return value of 682 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called at least once. Any 683 1.1 christos * other error means that the request could not be sent, and the callback will never be called. 684 1.1 christos * 685 1.1 christos * To discontinue receiving extended_pan_id change callbacks, the calling program should call 686 1.1 christos * cti_connection_ref_deallocate on the conn_ref returned by a successful call to cti_get_extended_pan_id(); 687 1.1 christos * 688 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 689 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 690 1.1 christos * 691 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 692 1.1 christos * an event occurs. 693 1.1 christos * callback: CallBack function for the client that indicates success or failure. 694 1.1 christos * 695 1.1 christos * client_queue: Queue the client wants to schedule the callback on 696 1.1 christos * 697 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 698 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 699 1.1 christos * that the request succeeded, merely that it was successfully started. 700 1.1 christos */ 701 1.1 christos 702 1.1 christos #define cti_get_extended_pan_id(server, ref, context, callback, client_queue) \ 703 1.1 christos cti_get_extended_pan_id_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 704 1.1 christos DNS_SERVICES_EXPORT cti_status_t 705 1.1 christos cti_get_extended_pan_id_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, void *NULLABLE context, 706 1.1 christos cti_uint64_property_reply_t NONNULL callback, run_context_t NULLABLE client_queue, 707 1.1 christos const char *NONNULL file, int line); 708 1.1 christos 709 1.1 christos /* cti_network_node_type_reply: Callback from cti_get_network_node_type() 710 1.1 christos * 711 1.1 christos * Called when an error occurs during processing of the cti_get_network_node_type call, or when network partition ID 712 1.1 christos * information is available. 713 1.1 christos * 714 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for releasing the 715 1.1 christos * connection network_node_type and restarting if needed. 716 1.1 christos * 717 1.1 christos * The callback will be called initially to report the network partition ID, and subsequently whenever the network 718 1.1 christos * partition ID changes. 719 1.1 christos * 720 1.1 christos * cti_reply parameters: 721 1.1 christos * 722 1.1 christos * context: The context that was passed to the cti prefix call to which this is a callback. 723 1.1 christos * 724 1.1 christos * network_node_type: The network node type, kCTI_NetworkNodeType_Unknown if it is not known. 725 1.1 christos * 726 1.1 christos * status: Will be kCTIStatus_NoError if the partition ID request is successful, or will indicate the failure 727 1.1 christos * that occurred. 728 1.1 christos */ 729 1.1 christos 730 1.1 christos typedef void 731 1.1 christos (*cti_network_node_type_reply_t)(void *NULLABLE context, cti_network_node_type_t network_node_type, cti_status_t status); 732 1.1 christos 733 1.1 christos /* cti_get_network_node_type 734 1.1 christos * 735 1.1 christos * Requests wpantund to immediately send the current network_node_type of the thread network. Whenever the thread 736 1.1 christos * network network_node_type changes, the callback will be called again with the new network_node_type. A return value of 737 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called at least once. Any 738 1.1 christos * other error means that the request could not be sent, and the callback will never be called. 739 1.1 christos * 740 1.1 christos * To discontinue receiving network_node_type change callbacks, the calling program should call 741 1.1 christos * cti_connection_ref_deallocate on the conn_ref returned by a successful call to cti_get_network_node_type(); 742 1.1 christos * 743 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 744 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 745 1.1 christos * 746 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 747 1.1 christos * an event occurs. 748 1.1 christos * callback: CallBack function for the client that indicates success or failure. 749 1.1 christos * 750 1.1 christos * client_queue: Queue the client wants to schedule the callback on 751 1.1 christos * 752 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 753 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 754 1.1 christos * that the request succeeded, merely that it was successfully started. 755 1.1 christos */ 756 1.1 christos 757 1.1 christos #define cti_get_network_node_type(server, ref, context, callback, client_queue) \ 758 1.1 christos cti_get_network_node_type_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 759 1.1 christos DNS_SERVICES_EXPORT cti_status_t 760 1.1 christos cti_get_network_node_type_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, void *NULLABLE context, 761 1.1 christos cti_network_node_type_reply_t NONNULL callback, run_context_t NULLABLE client_queue, 762 1.1 christos const char *NONNULL file, int line); 763 1.1 christos 764 1.1 christos /* cti_add_service 765 1.1 christos * 766 1.1 christos * Requests wpantund to add the specified service to the thread network data. A return value of 767 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called with a success or fail 768 1.1 christos * status exactly one time. Any other error means that the request could not be sent, and the callback will 769 1.1 christos * never be called. 770 1.1 christos * 771 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 772 1.1 christos * an event occurs. 773 1.1 christos * 774 1.1 christos * callback: CallBack function for the client that indicates success or failure. 775 1.1 christos * 776 1.1 christos * client_queue: Queue the client wants to schedule the callback on 777 1.1 christos * 778 1.1 christos * enterprise_number: Contains the enterprise number of the service. 779 1.1 christos * 780 1.1 christos * service_data: Typically four bytes, in network byte order, the first two bytes indicate 781 1.1 christos * the type of service within the enterprise' number space, and the second 782 1.1 christos * two bytes indicate the version number. 783 1.1 christos * 784 1.1 christos * service_data_len: The length of the service data in bytes. 785 1.1 christos * 786 1.1 christos * server_data: Typically four bytes, in network byte order, the first two bytes indicate 787 1.1 christos * the type of service within the enterprise' number space, and the second 788 1.1 christos * two bytes indicate the version number. 789 1.1 christos * 790 1.1 christos * server_data_len: The length of the service data in bytes. 791 1.1 christos * 792 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 793 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 794 1.1 christos * that the request succeeded, merely that it was successfully started. 795 1.1 christos */ 796 1.1 christos 797 1.1 christos #define cti_add_service(server, context, callback, client_queue, \ 798 1.1 christos enterprise_number, service_data, service_data_length, server_data, server_data_length) \ 799 1.1 christos cti_add_service_(server, context, callback, client_queue, enterprise_number, \ 800 1.1 christos service_data, service_data_length, server_data, server_data_length, __FILE__, __LINE__) 801 1.1 christos DNS_SERVICES_EXPORT cti_status_t 802 1.1 christos cti_add_service_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_reply_t NONNULL callback, 803 1.1 christos run_context_t NULLABLE client_queue, uint32_t enterprise_number, const uint8_t *NONNULL service_data, 804 1.1 christos size_t service_data_length, const uint8_t *NULLABLE server_data, size_t server_data_length, 805 1.1 christos const char *NONNULL file, int line); 806 1.1 christos 807 1.1 christos /* cti_remove_service 808 1.1 christos * 809 1.1 christos * Requests wpantund to remove the specified service from the thread network data. A return value of 810 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called with a success or fail 811 1.1 christos * status exactly one time. Any other error means that the request could not be sent, and the callback will 812 1.1 christos * never be called. 813 1.1 christos * 814 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 815 1.1 christos * an event occurs. 816 1.1 christos * 817 1.1 christos * callback: callback function for the client that indicates success or failure. 818 1.1 christos * 819 1.1 christos * client_queue: Queue the client wants to schedule the callback on 820 1.1 christos * 821 1.1 christos * enterprise_number: Contains the enterprise number of the service. 822 1.1 christos * 823 1.1 christos * service_data: Typically four bytes, in network byte order, the first two bytes indicate 824 1.1 christos * the type of service within the enterprise' number space, and the second 825 1.1 christos * two bytes indicate the version number. 826 1.1 christos * 827 1.1 christos * service_data_len: The length of the service data in bytes. 828 1.1 christos * 829 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 830 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 831 1.1 christos * that the request succeeded, merely that it was successfully started. 832 1.1 christos */ 833 1.1 christos 834 1.1 christos #define cti_remove_service(server, context, callback, client_queue, \ 835 1.1 christos enterprise_number, service_data, service_data_length) \ 836 1.1 christos cti_remove_service_(server, context, callback, client_queue, \ 837 1.1 christos enterprise_number, service_data, service_data_length, __FILE__, __LINE__) 838 1.1 christos DNS_SERVICES_EXPORT cti_status_t 839 1.1 christos cti_remove_service_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_reply_t NONNULL callback, 840 1.1 christos run_context_t NULLABLE client_queue, uint32_t enterprise_number, const uint8_t *NONNULL service_data, 841 1.1 christos size_t service_data_length, const char *NONNULL file, int line); 842 1.1 christos 843 1.1 christos /* cti_add_prefix 844 1.1 christos * 845 1.1 christos * Requests wpantund to add the specified prefix to the set of off-mesh prefixes configured on the thread 846 1.1 christos * network. A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be 847 1.1 christos * called with a success or fail status exactly one time. Any other error means that the request could not 848 1.1 christos * be sent, and the callback will never be called. 849 1.1 christos * 850 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 851 1.1 christos * an event occurs. 852 1.1 christos * 853 1.1 christos * callback: CallBack function for the client that indicates success or failure. 854 1.1 christos * 855 1.1 christos * client_queue: Queue the client wants to schedule the callback on 856 1.1 christos * 857 1.1 christos * prefix: A pointer to a struct in6_addr. Must not be reatained by the callback. 858 1.1 christos * 859 1.1 christos * prefix_len: The length of the prefix in bits. 860 1.1 christos * 861 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 862 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 863 1.1 christos * that the request succeeded, merely that it was successfully started. 864 1.1 christos */ 865 1.1 christos 866 1.1 christos #define cti_add_prefix(server, context, callback, client_queue, \ 867 1.1 christos prefix, prefix_length, on_mesh, preferred, slaac, stable, priority) \ 868 1.1 christos cti_add_prefix_(server, context, callback, client_queue, prefix, prefix_length, \ 869 1.1 christos on_mesh, preferred, slaac, stable, priority, __FILE__, __LINE__) 870 1.1 christos DNS_SERVICES_EXPORT cti_status_t 871 1.1 christos cti_add_prefix_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_reply_t NONNULL callback, run_context_t NULLABLE client_queue, 872 1.1 christos struct in6_addr *NONNULL prefix, int prefix_length, bool on_mesh, bool preferred, bool slaac, 873 1.1 christos bool stable, int priority, const char *NONNULL file, int line); 874 1.1 christos 875 1.1 christos /* cti_remove_prefix 876 1.1 christos * 877 1.1 christos * Requests wpantund to remove the specified prefix from the set of off-mesh prefixes configured on the thread network. 878 1.1 christos * A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be called with a success 879 1.1 christos * or fail status exactly one time. Any other error means that the request could not be sent, and the callback will 880 1.1 christos * never be called. 881 1.1 christos * 882 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 883 1.1 christos * an event occurs. 884 1.1 christos * 885 1.1 christos * callback: CallBack function for the client that indicates success or failure. 886 1.1 christos * 887 1.1 christos * client_queue: Queue the client wants to schedule the callback on 888 1.1 christos * 889 1.1 christos * prefix: A pointer to a struct in6_addr. Must not be reatained by the callback. 890 1.1 christos * 891 1.1 christos * prefix_len: The length of the prefix in bits. 892 1.1 christos * 893 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 894 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 895 1.1 christos * that the request succeeded, merely that it was successfully started. 896 1.1 christos */ 897 1.1 christos 898 1.1 christos #define cti_remove_prefix(server, context, callback, client_queue, prefix, prefix_length) \ 899 1.1 christos cti_remove_prefix_(server, context, callback, client_queue, prefix, prefix_length, __FILE__, __LINE__) 900 1.1 christos DNS_SERVICES_EXPORT cti_status_t 901 1.1 christos cti_remove_prefix_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_reply_t NONNULL callback, 902 1.1 christos run_context_t NULLABLE client_queue, struct in6_addr *NONNULL prefix, int prefix_length, 903 1.1 christos const char *NONNULL file, int line); 904 1.1 christos 905 1.1 christos /* cti_add_route 906 1.1 christos * 907 1.1 christos * Requests wpantund to add the specified route on the thread network. 908 1.1 christos * A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be 909 1.1 christos * called with a success or fail status exactly one time. Any other error means that the request could not 910 1.1 christos * be sent, and the callback will never be called. 911 1.1 christos * 912 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 913 1.1 christos * an event occurs. 914 1.1 christos * 915 1.1 christos * callback: CallBack function for the client that indicates success or failure. 916 1.1 christos * 917 1.1 christos * client_queue: Queue the client wants to schedule the callback on 918 1.1 christos * 919 1.1 christos * prefix: A pointer to a struct in6_addr. 920 1.1 christos * 921 1.1 christos * prefix_len: The length of the prefix in bits. 922 1.1 christos * 923 1.1 christos * priority: Route priority (>0 for high, 0 for medium, <0 for low). 924 1.1 christos * 925 1.1 christos * domain_id: Domain id for the route (default is zero). 926 1.1 christos * 927 1.1 christos * stable: True if the route is part of stable network data. 928 1.1 christos * 929 1.1 christos * nat64: True if this is NAT64 prefix. 930 1.1 christos * 931 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 932 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 933 1.1 christos * that the request succeeded, merely that it was successfully started. 934 1.1 christos */ 935 1.1 christos 936 1.1 christos #define cti_add_route(server, context, callback, client_queue, \ 937 1.1 christos prefix, prefix_length, priority, domain_id, stable, nat64) \ 938 1.1 christos cti_add_route_(server, context, callback, client_queue, prefix, prefix_length, \ 939 1.1 christos priority, domain_id, stable, nat64, __FILE__, __LINE__) 940 1.1 christos DNS_SERVICES_EXPORT cti_status_t 941 1.1 christos cti_add_route_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_reply_t NONNULL callback, 942 1.1 christos run_context_t NULLABLE client_queue, struct in6_addr *NONNULL prefix, int prefix_length, 943 1.1 christos int priority, int domain_id, bool stable, bool nat64, const char *NONNULL file, int line); 944 1.1 christos 945 1.1 christos /* cti_remove_route 946 1.1 christos * 947 1.1 christos * Requests wpantund to remove the specified route on the thread network. 948 1.1 christos * A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be called with a success 949 1.1 christos * or fail status exactly one time. Any other error means that the request could not be sent, and the callback will 950 1.1 christos * never be called. 951 1.1 christos * 952 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 953 1.1 christos * an event occurs. 954 1.1 christos * 955 1.1 christos * callback: CallBack function for the client that indicates success or failure. 956 1.1 christos * 957 1.1 christos * client_queue: Queue the client wants to schedule the callback on 958 1.1 christos * 959 1.1 christos * prefix: A pointer to a struct in6_addr. 960 1.1 christos * 961 1.1 christos * prefix_len: The length of the prefix in bits. 962 1.1 christos * 963 1.1 christos * domain_id: Domain id for the route (default is zero). 964 1.1 christos * 965 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 966 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 967 1.1 christos * that the request succeeded, merely that it was successfully started. 968 1.1 christos */ 969 1.1 christos 970 1.1 christos #define cti_remove_route(server, context, callback, client_queue, prefix, prefix_length, domain_id) \ 971 1.1 christos cti_remove_route_(server, context, callback, client_queue, prefix, prefix_length, domain_id, __FILE__, __LINE__) 972 1.1 christos DNS_SERVICES_EXPORT cti_status_t 973 1.1 christos cti_remove_route_(srp_server_t *NULLABLE server, void *NULLABLE context, cti_reply_t NONNULL callback, 974 1.1 christos run_context_t NULLABLE client_queue, struct in6_addr *NONNULL prefix, int prefix_length, 975 1.1 christos int domain_id, const char *NONNULL file, int line); 976 1.1 christos 977 1.1 christos /* 978 1.1 christos * cti_route_vec_create 979 1.1 christos * 980 1.1 christos * creates a route array vector of specified length 981 1.1 christos * 982 1.1 christos * num_routes: Number of route slots available in the route vector. 983 1.1 christos * 984 1.1 christos * return value: NULL, if the call failed; otherwise a prefix vector capable of containing the 985 1.1 christos * requested number of routes. 986 1.1 christos */ 987 1.1 christos cti_route_vec_t *NULLABLE 988 1.1 christos cti_route_vec_create_(size_t num_routes, const char *NONNULL file, int line); 989 1.1 christos #define cti_route_vec_create(num_routes) cti_route_vec_create_(num_routes, __FILE__, __LINE__) 990 1.1 christos 991 1.1 christos /* 992 1.1 christos * cti_route_vec_release 993 1.1 christos * 994 1.1 christos * decrements the reference count on the provided route vector and, if it reaches zero, finalizes the route vector, 995 1.1 christos * which calls cti_route_release on each route in the vector, potentially also finalizing them. 996 1.1 christos * 997 1.1 christos * num_routes: Number of route slots available in the route vector. 998 1.1 christos * 999 1.1 christos * return value: NULL, if the call failed; otherwise a route vector capable of containing the 1000 1.1 christos * requested number of routes. 1001 1.1 christos */ 1002 1.1 christos 1003 1.1 christos void 1004 1.1 christos cti_route_vec_release_(cti_route_vec_t *NONNULL routes, const char *NONNULL file, int line); 1005 1.1 christos #define cti_route_vec_release(routes) cti_route_vec_release_(routes, __FILE__, __LINE__) 1006 1.1 christos 1007 1.1 christos /* 1008 1.1 christos * cti_route_create 1009 1.1 christos * 1010 1.1 christos * Creates a cti_route_t containing the specified information. The route is retained, and will be 1011 1.1 christos * freed using free() when the route object is finalized. Caller must not retain or free these values, and 1012 1.1 christos * they must be allocated on the malloc heap. 1013 1.1 christos * 1014 1.1 christos * prefix: A pointer to a struct in6_addr. 1015 1.1 christos * 1016 1.1 christos * prefix_len: The length of the prefix in bits. 1017 1.1 christos * 1018 1.1 christos * origin: User or ncp. 1019 1.1 christos * 1020 1.1 christos * nat64: True if this is NAT64 prefix. 1021 1.1 christos * 1022 1.1 christos * stable: True if the route is part of stable network data. 1023 1.1 christos * 1024 1.1 christos * preference: Route priority. 1025 1.1 christos * 1026 1.1 christos * rloc: Routing locator. 1027 1.1 christos * 1028 1.1 christos * next_hop_is_host: True if next hop is host. 1029 1.1 christos * 1030 1.1 christos * return value: NULL, if the call failed; otherwise a route object containing the specified state. 1031 1.1 christos */ 1032 1.1 christos 1033 1.1 christos cti_route_t *NULLABLE 1034 1.1 christos cti_route_create_(struct in6_addr *NONNULL prefix, int prefix_length, offmesh_route_origin_t origin, 1035 1.1 christos bool nat64, bool stable, offmesh_route_preference_t preference, int rloc, 1036 1.1 christos bool next_hop_is_host, const char *NONNULL file, int line); 1037 1.1 christos #define cti_route_create(prefix, prefix_length, origin, nat64, stable, preference, rloc, next_hop_is_host) \ 1038 1.1 christos cti_route_create_(prefix, prefix_length, origin, nat64, stable, preference, rloc, next_hop_is_host, __FILE__, __LINE__) 1039 1.1 christos 1040 1.1 christos /* 1041 1.1 christos * cti_route_release 1042 1.1 christos * 1043 1.1 christos * Decrements the reference count on the provided route vector and, if it reaches zero, finalizes the route vector, 1044 1.1 christos * which calls cti_route_release on each route in the vector, potentially also finalizing them. 1045 1.1 christos * 1046 1.1 christos * routes: The route vector to release. 1047 1.1 christos * 1048 1.1 christos * return value: NULL, if the call failed; otherwise a route vector capable of containing the requested number of 1049 1.1 christos * routes. 1050 1.1 christos */ 1051 1.1 christos 1052 1.1 christos void 1053 1.1 christos cti_route_release_(cti_route_t *NONNULL route, const char *NONNULL file, int line); 1054 1.1 christos #define cti_route_release(routes) cti_route_release(route, __FILE__, __LINE__) 1055 1.1 christos 1056 1.1 christos /* cti_offmesh_route_reply: Callback from cti_get_offmesh_route_list() 1057 1.1 christos * 1058 1.1 christos * Called when an error occurs during processing of the cti_get_offmesh_route_list call, or when a route 1059 1.1 christos * is added or removed. 1060 1.1 christos * 1061 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 1062 1.1 christos * releasing the connection state and restarting if needed. 1063 1.1 christos * 1064 1.1 christos * The callback will be called once for each offmesh route present on the Thread network at the time 1065 1.1 christos * cti_get_offmesh_prefix_list() is first called, and then again whenever a route is added or removed. 1066 1.1 christos * 1067 1.1 christos * cti_offmesh_route_reply parameters: 1068 1.1 christos * 1069 1.1 christos * context: The context that was passed to the cti_get_offmesh_route_list call to which this is a callback. 1070 1.1 christos * 1071 1.1 christos * route_vec: If status is kCTIStatus_NoError, a vector containing all of the routes that were reported in 1072 1.1 christos * this event. 1073 1.1 christos * 1074 1.1 christos * status: Will be kCTIStatus_NoError if the offmesh route list request is successful, or 1075 1.1 christos * will indicate the failure that occurred. 1076 1.1 christos */ 1077 1.1 christos 1078 1.1 christos typedef void 1079 1.1 christos (*cti_offmesh_route_reply_t)(void *NULLABLE context, cti_route_vec_t *NULLABLE routes, cti_status_t status); 1080 1.1 christos 1081 1.1 christos /* cti_get_offmesh_route_list 1082 1.1 christos * 1083 1.1 christos * Requests wpantund to immediately send the current list of off-mesh routes configured in the Thread 1084 1.1 christos * network data. Whenever the route list is updated, the callback will be called again with the new 1085 1.1 christos * information. A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be 1086 1.1 christos * called at least once. Any other error means that the request could not be sent, and the callback will 1087 1.1 christos * never be called. 1088 1.1 christos * 1089 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 1090 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 1091 1.1 christos * 1092 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 1093 1.1 christos * an event occurs. 1094 1.1 christos * 1095 1.1 christos * callback: CallBack function for the client that indicates success or failure. 1096 1.1 christos * 1097 1.1 christos * client_queue: Queue the client wants to schedule the callback on 1098 1.1 christos * 1099 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 1100 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 1101 1.1 christos * that the request succeeded, merely that it was successfully started. 1102 1.1 christos */ 1103 1.1 christos 1104 1.1 christos #define cti_get_offmesh_route_list(server, ref, context, callback, client_queue) \ 1105 1.1 christos cti_get_offmesh_route_list_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 1106 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1107 1.1 christos cti_get_offmesh_route_list_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, 1108 1.1 christos void *NULLABLE context, cti_offmesh_route_reply_t NONNULL callback, 1109 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 1110 1.1 christos 1111 1.1 christos /* cti_onmesh_prefix_reply: Callback from cti_get_onmesh_prefix_list() 1112 1.1 christos * 1113 1.1 christos * Called when an error occurs during processing of the cti_get_onmesh_prefix_list call, or when a route 1114 1.1 christos * is added or removed. 1115 1.1 christos * 1116 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 1117 1.1 christos * releasing the connection state and restarting if needed. 1118 1.1 christos * 1119 1.1 christos * The callback will be called once for each offmesh route present on the Thread network at the time 1120 1.1 christos * cti_get_offmesh_prefix_list() is first called, and then again whenever a route is added or removed. 1121 1.1 christos * 1122 1.1 christos * cti_onmesh_prefix_reply parameters: 1123 1.1 christos * 1124 1.1 christos * context: The context that was passed to the cti_get_onmesh_prefix_list call to which this is a callback. 1125 1.1 christos * 1126 1.1 christos * prefix_vec: If status is kCTIStatus_NoError, a vector containing all of the prefixes that were reported in 1127 1.1 christos * this event. 1128 1.1 christos * 1129 1.1 christos * status: Will be kCTIStatus_NoError if the onmesh prefix list request is successful, or 1130 1.1 christos * will indicate the failure that occurred. 1131 1.1 christos */ 1132 1.1 christos 1133 1.1 christos typedef void 1134 1.1 christos (*cti_onmesh_prefix_reply_t)(void *NULLABLE context, cti_prefix_vec_t *NULLABLE routes, cti_status_t status); 1135 1.1 christos 1136 1.1 christos /* cti_get_onmesh_prefix_list 1137 1.1 christos * 1138 1.1 christos * Requests wpantund to immediately send the current list of on-mesh prefixes configured in the Thread 1139 1.1 christos * network data. Whenever the prefix list is updated, the callback will be called again with the new 1140 1.1 christos * information. A return value of kCTIStatus_NoError means that the caller can expect the reply callback to be 1141 1.1 christos * called at least once. Any other error means that the request could not be sent, and the callback will 1142 1.1 christos * never be called. 1143 1.1 christos * 1144 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 1145 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 1146 1.1 christos * 1147 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 1148 1.1 christos * an event occurs. 1149 1.1 christos * 1150 1.1 christos * callback: CallBack function for the client that indicates success or failure. 1151 1.1 christos * 1152 1.1 christos * client_queue: Queue the client wants to schedule the callback on 1153 1.1 christos * 1154 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 1155 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 1156 1.1 christos * that the request succeeded, merely that it was successfully started. 1157 1.1 christos */ 1158 1.1 christos 1159 1.1 christos #define cti_get_onmesh_prefix_list(server, ref, context, callback, client_queue) \ 1160 1.1 christos cti_get_onmesh_prefix_list_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 1161 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1162 1.1 christos cti_get_onmesh_prefix_list_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, 1163 1.1 christos void *NULLABLE context, cti_onmesh_prefix_reply_t NONNULL callback, 1164 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 1165 1.1 christos 1166 1.1 christos /* cti_rloc16_reply: Callback from cti_get_rloc16() 1167 1.1 christos * 1168 1.1 christos * Called when an error occurs during processing of the cti_get_rloc16 call, or when rloc16 1169 1.1 christos * is updated. 1170 1.1 christos * 1171 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 1172 1.1 christos * releasing the connection state and restarting if needed. 1173 1.1 christos * 1174 1.1 christos * The callback will be called initially to report the current value for the property, and subsequently 1175 1.1 christos * whenever the property changes. 1176 1.1 christos * 1177 1.1 christos * cti_rloc16_reply parameters: 1178 1.1 christos * 1179 1.1 christos * context: The context that was passed to the cti call to which this is a callback. 1180 1.1 christos * 1181 1.1 christos * rloc16: The rloc16 value(only valid if status is kCTIStatus_NoError). 1182 1.1 christos * 1183 1.1 christos * status: Will be kCTIStatus_NoError if the rloc16 request is successful, or will indicate the failure 1184 1.1 christos * that occurred. 1185 1.1 christos */ 1186 1.1 christos typedef void 1187 1.1 christos (*cti_rloc16_reply_t)(void *NULLABLE context, uint16_t rloc16, cti_status_t status); 1188 1.1 christos 1189 1.1 christos /* cti_get_rloc16 1190 1.1 christos * 1191 1.1 christos * Requests wpantund to immediately send the rloc16 of the local device. Whenever the RLOC16 1192 1.1 christos * changes, the callback will be called again with the new RLOC16. A return value of 1193 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called at least once. Any 1194 1.1 christos * other error means that the request could not be sent, and the callback will never be called. 1195 1.1 christos * 1196 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 1197 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 1198 1.1 christos * 1199 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 1200 1.1 christos * an event occurs. 1201 1.1 christos * callback: CallBack function for the client that indicates success or failure. 1202 1.1 christos * 1203 1.1 christos * client_queue: Queue the client wants to schedule the callback on 1204 1.1 christos * 1205 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 1206 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 1207 1.1 christos * that the request succeeded, merely that it was successfully started. 1208 1.1 christos */ 1209 1.1 christos #define cti_get_rloc16(server, ref, context, callback, client_queue) \ 1210 1.1 christos cti_get_rloc16_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 1211 1.1 christos 1212 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1213 1.1 christos cti_get_rloc16_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, 1214 1.1 christos void *NULLABLE context, cti_rloc16_reply_t NONNULL callback, 1215 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 1216 1.1 christos 1217 1.1 christos /* cti_active_data_set_change_reply: Callback from cti_get_active_data_set_change() 1218 1.1 christos * 1219 1.1 christos * Called when an error occurs during processing of the cti_get_active_data_set_change call, or when the active data set 1220 1.1 christos * is updated. 1221 1.1 christos * 1222 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 1223 1.1 christos * releasing the connection state and restarting if needed. 1224 1.1 christos * 1225 1.1 christos * The callback will be called whenever the active data set changes. 1226 1.1 christos * 1227 1.1 christos * cti_active_data_set_change_reply parameters: 1228 1.1 christos * 1229 1.1 christos * context: The context that was passed to the cti call to which this is a callback. 1230 1.1 christos * 1231 1.1 christos * status: Will be kCTIStatus_NoError if the active_data_set_change request is successful, or will indicate the failure 1232 1.1 christos * that occurred. 1233 1.1 christos */ 1234 1.1 christos typedef void 1235 1.1 christos (*cti_reply_t)(void *NULLABLE context, cti_status_t status); 1236 1.1 christos 1237 1.1 christos /* cti_get_active_data_set_change 1238 1.1 christos * 1239 1.1 christos * Requests wpantund to immediately send the active_data_set_change of the local device. Whenever the ACTIVE_DATA_SET_CHANGE 1240 1.1 christos * changes, the callback will be called again with the new ACTIVE_DATA_SET_CHANGE. A return value of 1241 1.1 christos * kCTIStatus_NoError means that the caller can expect the reply callback to be called at least once. Any 1242 1.1 christos * other error means that the request could not be sent, and the callback will never be called. 1243 1.1 christos * 1244 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 1245 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 1246 1.1 christos * 1247 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 1248 1.1 christos * an event occurs. 1249 1.1 christos * callback: CallBack function for the client that indicates success or failure. 1250 1.1 christos * 1251 1.1 christos * client_queue: Queue the client wants to schedule the callback on 1252 1.1 christos * 1253 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 1254 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 1255 1.1 christos * that the request succeeded, merely that it was successfully started. 1256 1.1 christos */ 1257 1.1 christos #define cti_track_active_data_set(server, ref, context, callback, client_queue) \ 1258 1.1 christos cti_track_active_data_set_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 1259 1.1 christos 1260 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1261 1.1 christos cti_track_active_data_set_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, 1262 1.1 christos void *NULLABLE context, cti_reply_t NONNULL callback, 1263 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 1264 1.1 christos 1265 1.1 christos /* cti_wed_change_reply: Callback from cti_get_wed_change() 1266 1.1 christos * 1267 1.1 christos * Called when an error occurs during processing of the cti_get_wed_change call, or when the active data set 1268 1.1 christos * is updated. 1269 1.1 christos * 1270 1.1 christos * In the case of an error, the callback will not be called again, and the caller is responsible for 1271 1.1 christos * releasing the connection state and restarting if needed. 1272 1.1 christos * 1273 1.1 christos * The callback will be called whenever the active data set changes. 1274 1.1 christos * 1275 1.1 christos * cti_wed_change_reply parameters: 1276 1.1 christos * 1277 1.1 christos * context: The context that was passed to the cti call to which this is a callback. 1278 1.1 christos * 1279 1.1 christos * status: Will be kCTIStatus_NoError if the wed_change request is successful, or will indicate the failure 1280 1.1 christos * that occurred. 1281 1.1 christos */ 1282 1.1 christos typedef void 1283 1.1 christos (*cti_reply_t)(void *NULLABLE context, cti_status_t status); 1284 1.1 christos 1285 1.1 christos /* cti_wed_reply: Callback for get calls that fetch the current WED status 1286 1.1 christos * 1287 1.1 christos * Called one or more times in response to a cti_track_wed_status() call, either with an error or with the current WED status. 1288 1.1 christos * 1289 1.1 christos * cti_wed_reply parameters: 1290 1.1 christos * 1291 1.1 christos * context: The context that was passed to the cti service call to which this is a callback. 1292 1.1 christos * 1293 1.1 christos * ext_address: If error is kCTIStatus_NoError, a string containing the name of the ext address. 1294 1.1 christos * 1295 1.1 christos * ml_eid: If error is kCTIStatus_NoError, a string containing the ML-EID 1296 1.1 christos * 1297 1.1 christos * added: If true, this was added; otherwise it was removed. 1298 1.1 christos * 1299 1.1 christos * status: Will be kCTIStatus_NoError on success, otherwise will indicate the 1300 1.1 christos * failure that occurred. 1301 1.1 christos */ 1302 1.1 christos 1303 1.1 christos typedef void 1304 1.1 christos (*cti_wed_reply_t)(void *NULLABLE context, const char *NULLABLE ext_address, const char *NULLABLE ml_eid, bool added, 1305 1.1 christos cti_status_t status); 1306 1.1 christos 1307 1.1 christos /* cti_get_wed_change 1308 1.1 christos * 1309 1.1 christos * Requests wpantund to immediately send the WED attachment status of the local device. Whenever the WED attachment 1310 1.1 christos * status changes, the callback will be called again with the new status. A return value of kCTIStatus_NoError means 1311 1.1 christos * that the caller can expect the reply callback to be called at least once. Any other error means that the request 1312 1.1 christos * could not be sent, and the callback will never be called. 1313 1.1 christos * 1314 1.1 christos * ref: A pointer to a reference to the connection is stored through ref if ref is not NULL. 1315 1.1 christos * When events are no longer needed, call cti_discontinue_events() on the returned pointer. 1316 1.1 christos * 1317 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 1318 1.1 christos * an event occurs. 1319 1.1 christos * 1320 1.1 christos * callback: CallBack function for the client that indicates success or failure, and on success 1321 1.1 christos * indicates attachment to a Wake-on End Device (WED). 1322 1.1 christos * 1323 1.1 christos * client_queue: Queue the client wants to schedule the callback on 1324 1.1 christos * 1325 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 1326 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 1327 1.1 christos * that the request succeeded, merely that it was successfully started. 1328 1.1 christos */ 1329 1.1 christos #define cti_track_wed_status(server, ref, context, callback, client_queue) \ 1330 1.1 christos cti_track_wed_status_(server, ref, context, callback, client_queue, __FILE__, __LINE__) 1331 1.1 christos 1332 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1333 1.1 christos cti_track_wed_status_(srp_server_t *NULLABLE server, cti_connection_t NULLABLE *NULLABLE ref, 1334 1.1 christos void *NULLABLE context, cti_wed_reply_t NONNULL callback, 1335 1.1 christos run_context_t NULLABLE client_queue, const char *NONNULL file, int line); 1336 1.1 christos 1337 1.1 christos /* cti_add_ml_eid_mapping 1338 1.1 christos * 1339 1.1 christos * Provides the thread daemon with a mapping between an IP address registered by an SRP client and 1340 1.1 christos * the source address from which the registration was received, which will be the client's ml-eid. 1341 1.1 christos * Additionally provides the client's hostname. 1342 1.1 christos * 1343 1.1 christos * context: An anonymous pointer that will be passed along to the callback when 1344 1.1 christos * an event occurs. 1345 1.1 christos * 1346 1.1 christos * callback: CallBack function for the client that indicates success or failure, and on success 1347 1.1 christos * indicates that the update was accepted by the thread daemon. 1348 1.1 christos * 1349 1.1 christos * omr_addr: IP address on the OMR prefix registered by the client. 1350 1.1 christos * 1351 1.1 christos * ml_eid: IP address on the mesh-local prefix of the client. 1352 1.1 christos * 1353 1.1 christos * client_queue: Queue the client wants to schedule the callback on 1354 1.1 christos * 1355 1.1 christos * 1356 1.1 christos * return value: Returns kCTIStatus_NoError when no error otherwise returns an error code indicating 1357 1.1 christos * the error that occurred. Note: A return value of kCTIStatus_NoError does not mean 1358 1.1 christos * that the request succeeded, merely that it was successfully started. 1359 1.1 christos */ 1360 1.1 christos #define cti_add_ml_eid_mapping(server, context, callback, client_queue, omr_addr, ml_eid, hostname) \ 1361 1.1 christos cti_add_ml_eid_mapping_(server, context, callback, client_queue, omr_addr, ml_eid, hostname, __FILE__, __LINE__) 1362 1.1 christos 1363 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1364 1.1 christos cti_add_ml_eid_mapping_(srp_server_t *NULLABLE server, void *NULLABLE context, 1365 1.1 christos cti_reply_t NONNULL callback, run_context_t NULLABLE client_queue, 1366 1.1 christos struct in6_addr *NONNULL omr_addr, struct in6_addr *NONNULL ml_eid, 1367 1.1 christos const char *NONNULL hostname, const char *NONNULL file, int line); 1368 1.1 christos 1369 1.1 christos /* cti_events_discontinue 1370 1.1 christos * 1371 1.1 christos * Requests that the CTI library stop delivering events on the specified connection. The connection will have 1372 1.1 christos * been returned by a CTI library call that subscribes to events. 1373 1.1 christos */ 1374 1.1 christos DNS_SERVICES_EXPORT cti_status_t 1375 1.1 christos cti_events_discontinue(cti_connection_t NONNULL ref); 1376 1.1 christos 1377 1.1 christos typedef union cti_callback { 1378 1.1 christos cti_reply_t NULLABLE reply; 1379 1.1 christos cti_string_property_reply_t NONNULL string_property_reply; 1380 1.1 christos cti_service_reply_t NONNULL service_reply; 1381 1.1 christos cti_prefix_reply_t NONNULL prefix_reply; 1382 1.1 christos cti_state_reply_t NONNULL state_reply; 1383 1.1 christos cti_uint64_property_reply_t NONNULL uint64_property_reply; 1384 1.1 christos cti_network_node_type_reply_t NONNULL network_node_type_reply; 1385 1.1 christos cti_offmesh_route_reply_t NONNULL offmesh_route_reply; 1386 1.1 christos cti_onmesh_prefix_reply_t NONNULL onmesh_prefix_reply; 1387 1.1 christos cti_rloc16_reply_t NONNULL rloc16_reply; 1388 1.1 christos cti_wed_reply_t NONNULL wed_reply; 1389 1.1 christos } cti_callback_t; 1390 1.1 christos 1391 1.1 christos #endif /* __CTI_SERVICES_H__ */ 1392 1.1 christos 1393 1.1 christos // Local Variables: 1394 1.1 christos // mode: C 1395 1.1 christos // tab-width: 4 1396 1.1 christos // c-file-style: "bsd" 1397 1.1 christos // c-basic-offset: 4 1398 1.1 christos // fill-column: 120 1399 1.1 christos // indent-tabs-mode: nil 1400 1.1 christos // End: 1401