1 // This file is autogenerated by: 2 // cbindgen --config cbindgen.toml src/lib.rs -o include/lib.rs.h 3 // Don't modify manually. 4 5 6 #pragma once 7 8 /* Generated with cbindgen:0.19.0 */ 9 10 #include <stdint.h> 11 #include <sys/types.h> 12 13 namespace test { 14 namespace rust { 15 16 static const uintptr_t DNS_HEADER_SIZE = 12; 17 18 static const uintptr_t MAX_UDP_PAYLOAD_SIZE = 1350; 19 20 /// Default value for max_idle_timeout transport parameter. 21 static const uint64_t QUICHE_IDLE_TIMEOUT_MS = 10000; 22 23 /// Default value for initial_max_streams_bidi transport parameter. 24 static const uint64_t MAX_STREAMS_BIDI = 100; 25 26 /// Frontend object. 27 struct DohFrontend; 28 29 struct Stats { 30 /// The number of accumulated DoH queries that are received. 31 uint32_t queries_received; 32 /// The number of accumulated QUIC connections accepted. 33 uint32_t connections_accepted; 34 /// The number of QUIC connections alive. 35 uint32_t alive_connections; 36 /// The number of QUIC connections using session resumption. 37 uint32_t resumed_connections; 38 }; 39 40 extern "C" { 41 42 /// Creates a DohFrontend object by the given IP addresss and ports. Returns the pointer of 43 /// the object if the creation succeeds; otherwise, returns a null pointer. 44 /// 45 /// # Safety 46 /// 47 /// The parameters `addr`, `port`, `backend_addr`, and `backend_port` must all point to null 48 /// terminated UTF-8 encoded strings. 49 DohFrontend *frontend_new(const char *addr, 50 const char *port, 51 const char *backend_addr, 52 const char *backend_port); 53 54 /// Starts the `DohFrontend` worker thread. Returns true if the worker thread is spawned 55 /// successfully; otherwise, it returns false. 56 bool frontend_start(DohFrontend *doh); 57 58 /// Stops the `DohFrontend` worker thread. 59 bool frontend_stop(DohFrontend *doh); 60 61 /// Deletes the `DohFrontend` created from `frontend_new`. 62 /// If the caller has called `frontend_start` to start `DohFrontend`, it has to call 63 /// call `frontend_stop` to stop the worker thread before deleting the object. 64 /// 65 /// # Safety 66 /// 67 /// The DohFrontend is not set to null pointer, caller needs to do it on its own. 68 void frontend_delete(DohFrontend *doh); 69 70 /// Sets server certificate to `DohFrontend`. 71 /// 72 /// # Safety 73 /// 74 /// The given certificate must be a null-terminated UTF-8 encoded string. 75 bool frontend_set_certificate(DohFrontend *doh, const char *certificate); 76 77 /// Sets server private key to `DohFrontend`. 78 /// 79 /// # Safety 80 /// 81 /// The given private key must be a null-terminated UTF-8 encoded string. 82 bool frontend_set_private_key(DohFrontend *doh, const char *private_key); 83 84 /// Configures the `DohFrontend` not to process DoH queries until a given number of DoH queries 85 /// are received. This function works even in the middle of the worker thread. 86 bool frontend_set_delay_queries(DohFrontend *doh, int32_t count); 87 88 /// Configures the `DohFrontend` to use the given value for max_idle_timeout transport parameter. 89 bool frontend_set_max_idle_timeout(DohFrontend *doh, uint64_t value); 90 91 /// Configures the `DohFrontend` to use the given value for these transport parameters. 92 /// - initial_max_data 93 /// - initial_max_stream_data_bidi_local 94 /// - initial_max_stream_data_bidi_remote 95 /// - initial_max_stream_data_uni 96 bool frontend_set_max_buffer_size(DohFrontend *doh, uint64_t value); 97 98 /// Configures the `DohFrontend` to use the given value for initial_max_streams_bidi transport 99 /// parameter. 100 bool frontend_set_max_streams_bidi(DohFrontend *doh, uint64_t value); 101 102 /// Sets the `DohFrontend` to block or unblock sending any data. 103 bool frontend_block_sending(DohFrontend *doh, bool block); 104 105 /// Gets the statistics of the `DohFrontend` and writes the result to |out|. 106 bool frontend_stats(DohFrontend *doh, Stats *out); 107 108 /// Resets `queries_received` field of `Stats` owned by the `DohFrontend`. 109 bool frontend_stats_clear_queries(const DohFrontend *doh); 110 111 /// Enable Rust debug logging. 112 void init_android_logger(); 113 114 } // extern "C" 115 116 } // namespace rust 117 } // namespace test 118