@dittolive/ditto 4.4.5 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/DittoReactNative.podspec +27 -0
  2. package/README.md +68 -51
  3. package/node/ditto.cjs.js +1639 -851
  4. package/node/ditto.darwin-arm64.node +0 -0
  5. package/node/ditto.darwin-x64.node +0 -0
  6. package/node/ditto.linux-arm.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/node/transports.darwin-arm64.node +0 -0
  10. package/node/transports.darwin-x64.node +0 -0
  11. package/package.json +34 -38
  12. package/react-native/android/CMakeLists.txt +37 -0
  13. package/react-native/android/build.gradle +203 -0
  14. package/react-native/android/cpp-adapter.cpp +254 -0
  15. package/react-native/android/gradle.properties +5 -0
  16. package/react-native/android/src/main/AndroidManifest.xml +4 -0
  17. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
  18. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
  19. package/react-native/boost/boost/assert.hpp +85 -0
  20. package/react-native/boost/boost/config/abi/borland_prefix.hpp +27 -0
  21. package/react-native/boost/boost/config/abi/borland_suffix.hpp +12 -0
  22. package/react-native/boost/boost/config/abi/msvc_prefix.hpp +22 -0
  23. package/react-native/boost/boost/config/abi/msvc_suffix.hpp +8 -0
  24. package/react-native/boost/boost/config/abi_prefix.hpp +25 -0
  25. package/react-native/boost/boost/config/abi_suffix.hpp +25 -0
  26. package/react-native/boost/boost/config/assert_cxx03.hpp +211 -0
  27. package/react-native/boost/boost/config/assert_cxx11.hpp +209 -0
  28. package/react-native/boost/boost/config/assert_cxx14.hpp +47 -0
  29. package/react-native/boost/boost/config/assert_cxx17.hpp +62 -0
  30. package/react-native/boost/boost/config/assert_cxx20.hpp +59 -0
  31. package/react-native/boost/boost/config/assert_cxx98.hpp +23 -0
  32. package/react-native/boost/boost/config/auto_link.hpp +525 -0
  33. package/react-native/boost/boost/config/compiler/borland.hpp +339 -0
  34. package/react-native/boost/boost/config/compiler/clang.hpp +366 -0
  35. package/react-native/boost/boost/config/compiler/clang_version.hpp +83 -0
  36. package/react-native/boost/boost/config/compiler/codegear.hpp +385 -0
  37. package/react-native/boost/boost/config/compiler/comeau.hpp +59 -0
  38. package/react-native/boost/boost/config/compiler/common_edg.hpp +183 -0
  39. package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +19 -0
  40. package/react-native/boost/boost/config/compiler/cray.hpp +446 -0
  41. package/react-native/boost/boost/config/compiler/diab.hpp +26 -0
  42. package/react-native/boost/boost/config/compiler/digitalmars.hpp +143 -0
  43. package/react-native/boost/boost/config/compiler/gcc.hpp +383 -0
  44. package/react-native/boost/boost/config/compiler/gcc_xml.hpp +114 -0
  45. package/react-native/boost/boost/config/compiler/greenhills.hpp +28 -0
  46. package/react-native/boost/boost/config/compiler/hp_acc.hpp +149 -0
  47. package/react-native/boost/boost/config/compiler/intel.hpp +577 -0
  48. package/react-native/boost/boost/config/compiler/kai.hpp +33 -0
  49. package/react-native/boost/boost/config/compiler/metrowerks.hpp +198 -0
  50. package/react-native/boost/boost/config/compiler/mpw.hpp +140 -0
  51. package/react-native/boost/boost/config/compiler/nvcc.hpp +61 -0
  52. package/react-native/boost/boost/config/compiler/pathscale.hpp +138 -0
  53. package/react-native/boost/boost/config/compiler/pgi.hpp +23 -0
  54. package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +29 -0
  55. package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +222 -0
  56. package/react-native/boost/boost/config/compiler/vacpp.hpp +186 -0
  57. package/react-native/boost/boost/config/compiler/visualc.hpp +391 -0
  58. package/react-native/boost/boost/config/compiler/xlcpp.hpp +299 -0
  59. package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +173 -0
  60. package/react-native/boost/boost/config/detail/cxx_composite.hpp +203 -0
  61. package/react-native/boost/boost/config/detail/posix_features.hpp +95 -0
  62. package/react-native/boost/boost/config/detail/select_compiler_config.hpp +157 -0
  63. package/react-native/boost/boost/config/detail/select_platform_config.hpp +147 -0
  64. package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +121 -0
  65. package/react-native/boost/boost/config/detail/suffix.hpp +1294 -0
  66. package/react-native/boost/boost/config/header_deprecated.hpp +26 -0
  67. package/react-native/boost/boost/config/helper_macros.hpp +37 -0
  68. package/react-native/boost/boost/config/no_tr1/cmath.hpp +28 -0
  69. package/react-native/boost/boost/config/no_tr1/complex.hpp +28 -0
  70. package/react-native/boost/boost/config/no_tr1/functional.hpp +28 -0
  71. package/react-native/boost/boost/config/no_tr1/memory.hpp +28 -0
  72. package/react-native/boost/boost/config/no_tr1/utility.hpp +28 -0
  73. package/react-native/boost/boost/config/platform/aix.hpp +33 -0
  74. package/react-native/boost/boost/config/platform/amigaos.hpp +15 -0
  75. package/react-native/boost/boost/config/platform/beos.hpp +26 -0
  76. package/react-native/boost/boost/config/platform/bsd.hpp +83 -0
  77. package/react-native/boost/boost/config/platform/cloudabi.hpp +18 -0
  78. package/react-native/boost/boost/config/platform/cray.hpp +18 -0
  79. package/react-native/boost/boost/config/platform/cygwin.hpp +71 -0
  80. package/react-native/boost/boost/config/platform/haiku.hpp +31 -0
  81. package/react-native/boost/boost/config/platform/hpux.hpp +87 -0
  82. package/react-native/boost/boost/config/platform/irix.hpp +31 -0
  83. package/react-native/boost/boost/config/platform/linux.hpp +106 -0
  84. package/react-native/boost/boost/config/platform/macos.hpp +87 -0
  85. package/react-native/boost/boost/config/platform/qnxnto.hpp +31 -0
  86. package/react-native/boost/boost/config/platform/solaris.hpp +31 -0
  87. package/react-native/boost/boost/config/platform/symbian.hpp +97 -0
  88. package/react-native/boost/boost/config/platform/vms.hpp +25 -0
  89. package/react-native/boost/boost/config/platform/vxworks.hpp +422 -0
  90. package/react-native/boost/boost/config/platform/wasm.hpp +23 -0
  91. package/react-native/boost/boost/config/platform/win32.hpp +90 -0
  92. package/react-native/boost/boost/config/platform/zos.hpp +32 -0
  93. package/react-native/boost/boost/config/pragma_message.hpp +31 -0
  94. package/react-native/boost/boost/config/requires_threads.hpp +92 -0
  95. package/react-native/boost/boost/config/stdlib/dinkumware.hpp +324 -0
  96. package/react-native/boost/boost/config/stdlib/libcomo.hpp +93 -0
  97. package/react-native/boost/boost/config/stdlib/libcpp.hpp +180 -0
  98. package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +482 -0
  99. package/react-native/boost/boost/config/stdlib/modena.hpp +79 -0
  100. package/react-native/boost/boost/config/stdlib/msl.hpp +98 -0
  101. package/react-native/boost/boost/config/stdlib/roguewave.hpp +208 -0
  102. package/react-native/boost/boost/config/stdlib/sgi.hpp +168 -0
  103. package/react-native/boost/boost/config/stdlib/stlport.hpp +258 -0
  104. package/react-native/boost/boost/config/stdlib/vacpp.hpp +74 -0
  105. package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +61 -0
  106. package/react-native/boost/boost/config/user.hpp +133 -0
  107. package/react-native/boost/boost/config/warning_disable.hpp +47 -0
  108. package/react-native/boost/boost/config/workaround.hpp +305 -0
  109. package/react-native/boost/boost/config.hpp +67 -0
  110. package/react-native/boost/boost/cstdint.hpp +556 -0
  111. package/react-native/boost/boost/intrusive_ptr.hpp +18 -0
  112. package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +103 -0
  113. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +79 -0
  114. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +63 -0
  115. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +88 -0
  116. package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +66 -0
  117. package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +104 -0
  118. package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +69 -0
  119. package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +67 -0
  120. package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +72 -0
  121. package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +70 -0
  122. package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +148 -0
  123. package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +91 -0
  124. package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +64 -0
  125. package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +23 -0
  126. package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +707 -0
  127. package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +92 -0
  128. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +92 -0
  129. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +163 -0
  130. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +152 -0
  131. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +185 -0
  132. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +148 -0
  133. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +170 -0
  134. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +200 -0
  135. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +194 -0
  136. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +179 -0
  137. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +186 -0
  138. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +119 -0
  139. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +147 -0
  140. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +174 -0
  141. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +141 -0
  142. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +147 -0
  143. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +165 -0
  144. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +163 -0
  145. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +140 -0
  146. package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +309 -0
  147. package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +40 -0
  148. package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +52 -0
  149. package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +27 -0
  150. package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +69 -0
  151. package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +173 -0
  152. package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +48 -0
  153. package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +45 -0
  154. package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +32 -0
  155. package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +51 -0
  156. package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +104 -0
  157. package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +100 -0
  158. package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +58 -0
  159. package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +49 -0
  160. package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +409 -0
  161. package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +188 -0
  162. package/react-native/cpp/include/Attachment.h +16 -0
  163. package/react-native/cpp/include/Authentication.h +23 -0
  164. package/react-native/cpp/include/Collection.h +13 -0
  165. package/react-native/cpp/include/DQL.h +21 -0
  166. package/react-native/cpp/include/Document.h +17 -0
  167. package/react-native/cpp/include/Identity.h +17 -0
  168. package/react-native/cpp/include/Lifecycle.h +16 -0
  169. package/react-native/cpp/include/LiveQuery.h +17 -0
  170. package/react-native/cpp/include/Logger.h +22 -0
  171. package/react-native/cpp/include/Misc.h +26 -0
  172. package/react-native/cpp/include/Presence.h +14 -0
  173. package/react-native/cpp/include/RetainableState.h +24 -0
  174. package/react-native/cpp/include/SmallPeerInfo.h +17 -0
  175. package/react-native/cpp/include/Transports.h +25 -0
  176. package/react-native/cpp/include/TypedArray.hpp +167 -0
  177. package/react-native/cpp/include/Utils.h +61 -0
  178. package/react-native/cpp/include/main.h +10 -0
  179. package/react-native/cpp/src/Attachment.cpp +86 -0
  180. package/react-native/cpp/src/Authentication.cpp +224 -0
  181. package/react-native/cpp/src/Collection.cpp +54 -0
  182. package/react-native/cpp/src/DQL.cpp +254 -0
  183. package/react-native/cpp/src/Document.cpp +146 -0
  184. package/react-native/cpp/src/Identity.cpp +123 -0
  185. package/react-native/cpp/src/Lifecycle.cpp +75 -0
  186. package/react-native/cpp/src/LiveQuery.cpp +64 -0
  187. package/react-native/cpp/src/Logger.cpp +200 -0
  188. package/react-native/cpp/src/Misc.cpp +271 -0
  189. package/react-native/cpp/src/Presence.cpp +77 -0
  190. package/react-native/cpp/src/RetainableState.cpp +15 -0
  191. package/react-native/cpp/src/SmallPeerInfo.cpp +108 -0
  192. package/react-native/cpp/src/Transports.cpp +270 -0
  193. package/react-native/cpp/src/TypedArray.cpp +303 -0
  194. package/react-native/cpp/src/Utils.cpp +138 -0
  195. package/react-native/cpp/src/main.cpp +149 -0
  196. package/react-native/dittoffi/dittoffi.h +4698 -0
  197. package/react-native/dittoffi/ifaddrs.cpp +385 -0
  198. package/react-native/dittoffi/ifaddrs.h +206 -0
  199. package/react-native/ios/DittoRNSDK.h +7 -0
  200. package/react-native/ios/DittoRNSDK.mm +107 -0
  201. package/react-native/ios/YeetJSIUtils.h +60 -0
  202. package/react-native/ios/YeetJSIUtils.mm +196 -0
  203. package/react-native/lib/commonjs/ditto.rn.js +93 -0
  204. package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
  205. package/react-native/lib/commonjs/index.js +14 -0
  206. package/react-native/lib/commonjs/index.js.map +1 -0
  207. package/react-native/lib/module/ditto.rn.js +83 -0
  208. package/react-native/lib/module/ditto.rn.js.map +1 -0
  209. package/react-native/lib/module/index.js +13 -0
  210. package/react-native/lib/module/index.js.map +1 -0
  211. package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
  212. package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
  213. package/react-native/lib/typescript/index.d.ts +1 -0
  214. package/react-native/lib/typescript/index.d.ts.map +1 -0
  215. package/react-native/scripts/ruby/include_local_boost.rb +78 -0
  216. package/react-native/src/ditto.rn.ts +91 -0
  217. package/react-native/src/environment/environment.fallback.ts +4 -0
  218. package/react-native/src/index.ts +26 -0
  219. package/react-native/src/sources/@cbor-redux.ts +2 -0
  220. package/react-native/src/sources/@ditto.core.ts +1 -0
  221. package/react-native/src/sources/@environment.ts +2 -0
  222. package/react-native/src/sources/attachment-fetch-event.ts +54 -0
  223. package/react-native/src/sources/attachment-fetcher-manager.ts +129 -0
  224. package/react-native/src/sources/attachment-fetcher.ts +124 -0
  225. package/react-native/src/sources/attachment-token.ts +48 -0
  226. package/react-native/src/sources/attachment.ts +59 -0
  227. package/react-native/src/sources/augment.ts +89 -0
  228. package/react-native/src/sources/authenticator.ts +314 -0
  229. package/react-native/src/sources/base-pending-cursor-operation.ts +237 -0
  230. package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
  231. package/react-native/src/sources/bridge.ts +549 -0
  232. package/react-native/src/sources/build-time-constants.ts +4 -0
  233. package/react-native/src/sources/cbor.ts +35 -0
  234. package/react-native/src/sources/collection-interface.ts +67 -0
  235. package/react-native/src/sources/collection.ts +212 -0
  236. package/react-native/src/sources/collections-event.ts +99 -0
  237. package/react-native/src/sources/counter.ts +77 -0
  238. package/react-native/src/sources/ditto.ts +945 -0
  239. package/react-native/src/sources/document-id.ts +159 -0
  240. package/react-native/src/sources/document-path.ts +303 -0
  241. package/react-native/src/sources/document.ts +192 -0
  242. package/react-native/src/sources/epilogue.ts +24 -0
  243. package/react-native/src/sources/error-codes.ts +52 -0
  244. package/react-native/src/sources/error.ts +203 -0
  245. package/react-native/src/sources/essentials.ts +53 -0
  246. package/react-native/src/sources/ffi-error.ts +117 -0
  247. package/react-native/src/sources/ffi.ts +1972 -0
  248. package/react-native/src/sources/identity.ts +163 -0
  249. package/react-native/src/sources/init.ts +70 -0
  250. package/react-native/src/sources/internal.ts +113 -0
  251. package/react-native/src/sources/keep-alive.ts +69 -0
  252. package/react-native/src/sources/key-path.ts +195 -0
  253. package/react-native/src/sources/live-query-event.ts +208 -0
  254. package/react-native/src/sources/live-query-manager.ts +101 -0
  255. package/react-native/src/sources/live-query.ts +164 -0
  256. package/react-native/src/sources/logger.ts +196 -0
  257. package/react-native/src/sources/observer-manager.ts +175 -0
  258. package/react-native/src/sources/observer.ts +77 -0
  259. package/react-native/src/sources/pending-collections-operation.ts +232 -0
  260. package/react-native/src/sources/pending-cursor-operation.ts +218 -0
  261. package/react-native/src/sources/pending-id-specific-operation.ts +216 -0
  262. package/react-native/src/sources/presence-manager.ts +160 -0
  263. package/react-native/src/sources/presence.ts +238 -0
  264. package/react-native/src/sources/query-result-item.ts +116 -0
  265. package/react-native/src/sources/query-result.ts +55 -0
  266. package/react-native/src/sources/register.ts +92 -0
  267. package/react-native/src/sources/small-peer-info.ts +176 -0
  268. package/react-native/src/sources/static-tcp-client.ts +6 -0
  269. package/react-native/src/sources/store-observer.ts +176 -0
  270. package/react-native/src/sources/store.ts +365 -0
  271. package/react-native/src/sources/subscription-manager.ts +98 -0
  272. package/react-native/src/sources/subscription.ts +88 -0
  273. package/react-native/src/sources/sync-subscription.ts +90 -0
  274. package/react-native/src/sources/sync.ts +495 -0
  275. package/react-native/src/sources/test-helpers.ts +24 -0
  276. package/react-native/src/sources/transport-conditions-manager.ts +104 -0
  277. package/react-native/src/sources/transport-config.ts +428 -0
  278. package/react-native/src/sources/update-result.ts +66 -0
  279. package/react-native/src/sources/update-results-map.ts +57 -0
  280. package/react-native/src/sources/websocket-client.ts +6 -0
  281. package/react-native/src/sources/write-transaction-collection.ts +122 -0
  282. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
  283. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +72 -0
  284. package/react-native/src/sources/write-transaction.ts +119 -0
  285. package/react-native.config.js +9 -0
  286. package/types/ditto.d.ts +1230 -798
  287. package/web/ditto.es6.js +1 -1
  288. package/web/ditto.umd.js +1 -1
  289. package/web/ditto.wasm +0 -0
@@ -0,0 +1,385 @@
1
+ // DITTO VENDORING - bionic/ifaddrs.cpp, modified
2
+
3
+ /*
4
+ * Copyright (C) 2015 The Android Open Source Project
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions
9
+ * are met:
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in
14
+ * the documentation and/or other materials provided with the
15
+ * distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
+ * SUCH DAMAGE.
29
+ */
30
+
31
+ #include "ifaddrs.h"
32
+
33
+ #include <errno.h>
34
+ #include <linux/if_packet.h>
35
+ #include <net/if.h>
36
+ #include <netinet/in.h>
37
+ #include <stdint.h>
38
+ #include <stdio.h>
39
+ #include <stdlib.h>
40
+ #include <string.h>
41
+ #include <unistd.h>
42
+
43
+ // The public ifaddrs struct is full of pointers. Rather than track several
44
+ // different allocations, we use a maximally-sized structure with the public
45
+ // part at offset 0, and pointers into its hidden tail.
46
+ struct ifaddrs_storage {
47
+ // Must come first, so that `ifaddrs_storage` is-a `ifaddrs`.
48
+ ifaddrs ifa;
49
+
50
+ // The interface index, so we can match RTM_NEWADDR messages with
51
+ // earlier RTM_NEWLINK messages (to copy the interface flags).
52
+ int interface_index;
53
+
54
+ // Storage for the pointers in `ifa`.
55
+ sockaddr_storage addr;
56
+ sockaddr_storage netmask;
57
+ sockaddr_storage ifa_ifu;
58
+ char name[IFNAMSIZ + 1];
59
+
60
+ explicit ifaddrs_storage(ifaddrs** list) {
61
+ memset(this, 0, sizeof(*this));
62
+
63
+ // push_front onto `list`.
64
+ ifa.ifa_next = *list;
65
+ *list = reinterpret_cast<ifaddrs*>(this);
66
+ }
67
+
68
+ void SetAddress(int family, const void* data, size_t byteCount) {
69
+ // The kernel currently uses the order IFA_ADDRESS, IFA_LOCAL, IFA_BROADCAST
70
+ // in inet_fill_ifaddr, but let's not assume that will always be true...
71
+ if (ifa.ifa_addr == nullptr) {
72
+ // This is an IFA_ADDRESS and haven't seen an IFA_LOCAL yet, so assume this is the
73
+ // local address. SetLocalAddress will fix things if we later see an IFA_LOCAL.
74
+ ifa.ifa_addr = CopyAddress(family, data, byteCount, &addr);
75
+ } else {
76
+ // We already saw an IFA_LOCAL, which implies this is a destination address.
77
+ ifa.ifa_dstaddr = CopyAddress(family, data, byteCount, &ifa_ifu);
78
+ }
79
+ }
80
+
81
+ void SetBroadcastAddress(int family, const void* data, size_t byteCount) {
82
+ // ifa_broadaddr and ifa_dstaddr overlap in a union. Unfortunately, it's possible
83
+ // to have an interface with both. Keeping the last thing the kernel gives us seems
84
+ // to be glibc 2.19's behavior too, so our choice is being source compatible with
85
+ // badly-written code that assumes ifa_broadaddr and ifa_dstaddr are interchangeable
86
+ // or supporting interfaces with both addresses configured. My assumption is that
87
+ // bad code is more common than weird network interfaces...
88
+ ifa.ifa_broadaddr = CopyAddress(family, data, byteCount, &ifa_ifu);
89
+ }
90
+
91
+ void SetLocalAddress(int family, const void* data, size_t byteCount) {
92
+ // The kernel source says "for point-to-point IFA_ADDRESS is DESTINATION address,
93
+ // local address is supplied in IFA_LOCAL attribute".
94
+ // -- http://lxr.free-electrons.com/source/include/uapi/linux/if_addr.h#L17
95
+
96
+ // So copy any existing IFA_ADDRESS into ifa_dstaddr...
97
+ if (ifa.ifa_addr != nullptr) {
98
+ ifa.ifa_dstaddr = reinterpret_cast<sockaddr*>(memcpy(&ifa_ifu, &addr, sizeof(addr)));
99
+ }
100
+ // ...and then put this IFA_LOCAL into ifa_addr.
101
+ ifa.ifa_addr = CopyAddress(family, data, byteCount, &addr);
102
+ }
103
+
104
+ // Netlink gives us the prefix length as a bit count. We need to turn
105
+ // that into a BSD-compatible netmask represented by a sockaddr*.
106
+ void SetNetmask(int family, size_t prefix_length) {
107
+ // ...and work out the netmask from the prefix length.
108
+ netmask.ss_family = family;
109
+ uint8_t* dst = SockaddrBytes(family, &netmask);
110
+ memset(dst, 0xff, prefix_length / 8);
111
+ if ((prefix_length % 8) != 0) {
112
+ dst[prefix_length/8] = (0xff << (8 - (prefix_length % 8)));
113
+ }
114
+ ifa.ifa_netmask = reinterpret_cast<sockaddr*>(&netmask);
115
+ }
116
+
117
+ void SetPacketAttributes(int ifindex, unsigned short hatype, unsigned char halen) {
118
+ sockaddr_ll* sll = reinterpret_cast<sockaddr_ll*>(&addr);
119
+ sll->sll_ifindex = ifindex;
120
+ sll->sll_hatype = hatype;
121
+ sll->sll_halen = halen;
122
+ }
123
+
124
+ private:
125
+ sockaddr* CopyAddress(int family, const void* data, size_t byteCount, sockaddr_storage* ss) {
126
+ // Netlink gives us the address family in the header, and the
127
+ // sockaddr_in or sockaddr_in6 bytes as the payload. We need to
128
+ // stitch the two bits together into the sockaddr that's part of
129
+ // our portable interface.
130
+ ss->ss_family = family;
131
+ memcpy(SockaddrBytes(family, ss), data, byteCount);
132
+
133
+ // For IPv6 we might also have to set the scope id.
134
+ if (family == AF_INET6 && (IN6_IS_ADDR_LINKLOCAL(data) || IN6_IS_ADDR_MC_LINKLOCAL(data))) {
135
+ reinterpret_cast<sockaddr_in6*>(ss)->sin6_scope_id = interface_index;
136
+ }
137
+
138
+ return reinterpret_cast<sockaddr*>(ss);
139
+ }
140
+
141
+ // Returns a pointer to the first byte in the address data (which is
142
+ // stored in network byte order).
143
+ uint8_t* SockaddrBytes(int family, sockaddr_storage* ss) {
144
+ if (family == AF_INET) {
145
+ sockaddr_in* ss4 = reinterpret_cast<sockaddr_in*>(ss);
146
+ return reinterpret_cast<uint8_t*>(&ss4->sin_addr);
147
+ } else if (family == AF_INET6) {
148
+ sockaddr_in6* ss6 = reinterpret_cast<sockaddr_in6*>(ss);
149
+ return reinterpret_cast<uint8_t*>(&ss6->sin6_addr);
150
+ } else if (family == AF_PACKET) {
151
+ sockaddr_ll* sll = reinterpret_cast<sockaddr_ll*>(ss);
152
+ return reinterpret_cast<uint8_t*>(&sll->sll_addr);
153
+ }
154
+ return nullptr;
155
+ }
156
+ };
157
+
158
+ static void __getifaddrs_callback(void* context, nlmsghdr* hdr) {
159
+ ifaddrs** out = reinterpret_cast<ifaddrs**>(context);
160
+
161
+ if (hdr->nlmsg_type == RTM_NEWLINK) {
162
+ ifinfomsg* ifi = reinterpret_cast<ifinfomsg*>(NLMSG_DATA(hdr));
163
+
164
+ // Create a new ifaddr entry, and set the interface index and flags.
165
+ ifaddrs_storage* new_addr = new ifaddrs_storage(out);
166
+ new_addr->interface_index = ifi->ifi_index;
167
+ new_addr->ifa.ifa_flags = ifi->ifi_flags;
168
+
169
+ // Go through the various bits of information and find the name.
170
+ rtattr* rta = IFLA_RTA(ifi);
171
+ size_t rta_len = IFLA_PAYLOAD(hdr);
172
+ while (RTA_OK(rta, rta_len)) {
173
+ if (rta->rta_type == IFLA_ADDRESS) {
174
+ if (RTA_PAYLOAD(rta) < sizeof(new_addr->addr)) {
175
+ new_addr->SetAddress(AF_PACKET, RTA_DATA(rta), RTA_PAYLOAD(rta));
176
+ new_addr->SetPacketAttributes(ifi->ifi_index, ifi->ifi_type, RTA_PAYLOAD(rta));
177
+ }
178
+ } else if (rta->rta_type == IFLA_BROADCAST) {
179
+ if (RTA_PAYLOAD(rta) < sizeof(new_addr->ifa_ifu)) {
180
+ new_addr->SetBroadcastAddress(AF_PACKET, RTA_DATA(rta), RTA_PAYLOAD(rta));
181
+ new_addr->SetPacketAttributes(ifi->ifi_index, ifi->ifi_type, RTA_PAYLOAD(rta));
182
+ }
183
+ } else if (rta->rta_type == IFLA_IFNAME) {
184
+ if (RTA_PAYLOAD(rta) < sizeof(new_addr->name)) {
185
+ memcpy(new_addr->name, RTA_DATA(rta), RTA_PAYLOAD(rta));
186
+ new_addr->ifa.ifa_name = new_addr->name;
187
+ }
188
+ }
189
+ rta = RTA_NEXT(rta, rta_len);
190
+ }
191
+ } else if (hdr->nlmsg_type == RTM_NEWADDR) {
192
+ ifaddrmsg* msg = reinterpret_cast<ifaddrmsg*>(NLMSG_DATA(hdr));
193
+
194
+ // We might already know about this interface from an RTM_NEWLINK message.
195
+ const ifaddrs_storage* known_addr = reinterpret_cast<const ifaddrs_storage*>(*out);
196
+ while (known_addr != nullptr && known_addr->interface_index != static_cast<int>(msg->ifa_index)) {
197
+ known_addr = reinterpret_cast<const ifaddrs_storage*>(known_addr->ifa.ifa_next);
198
+ }
199
+
200
+ // Create a new ifaddr entry, and set the interface index.
201
+ ifaddrs_storage* new_addr = new ifaddrs_storage(out);
202
+ new_addr->interface_index = static_cast<int>(msg->ifa_index);
203
+
204
+ // If this is a known interface, copy what we already know.
205
+ // If we don't know about this interface yet, we try to resolve the name and flags using ioctl
206
+ // calls during postprocessing.
207
+ if (known_addr != nullptr) {
208
+ strcpy(new_addr->name, known_addr->name);
209
+ new_addr->ifa.ifa_name = new_addr->name;
210
+ new_addr->ifa.ifa_flags = known_addr->ifa.ifa_flags;
211
+ }
212
+
213
+ // Go through the various bits of information and find the name, address
214
+ // and any broadcast/destination address.
215
+ rtattr* rta = IFA_RTA(msg);
216
+ size_t rta_len = IFA_PAYLOAD(hdr);
217
+ while (RTA_OK(rta, rta_len)) {
218
+ if (rta->rta_type == IFA_ADDRESS) {
219
+ if (msg->ifa_family == AF_INET || msg->ifa_family == AF_INET6) {
220
+ new_addr->SetAddress(msg->ifa_family, RTA_DATA(rta), RTA_PAYLOAD(rta));
221
+ new_addr->SetNetmask(msg->ifa_family, msg->ifa_prefixlen);
222
+ }
223
+ } else if (rta->rta_type == IFA_BROADCAST) {
224
+ if (msg->ifa_family == AF_INET) {
225
+ new_addr->SetBroadcastAddress(msg->ifa_family, RTA_DATA(rta), RTA_PAYLOAD(rta));
226
+ if (known_addr == nullptr) {
227
+ // We did not read the broadcast flag from an RTM_NEWLINK message.
228
+ // Ensure that it is set.
229
+ new_addr->ifa.ifa_flags |= IFF_BROADCAST;
230
+ }
231
+ }
232
+ } else if (rta->rta_type == IFA_LOCAL) {
233
+ if (msg->ifa_family == AF_INET || msg->ifa_family == AF_INET6) {
234
+ new_addr->SetLocalAddress(msg->ifa_family, RTA_DATA(rta), RTA_PAYLOAD(rta));
235
+ }
236
+ } else if (rta->rta_type == IFA_LABEL) {
237
+ if (RTA_PAYLOAD(rta) < sizeof(new_addr->name)) {
238
+ memcpy(new_addr->name, RTA_DATA(rta), RTA_PAYLOAD(rta));
239
+ new_addr->ifa.ifa_name = new_addr->name;
240
+ }
241
+ }
242
+ rta = RTA_NEXT(rta, rta_len);
243
+ }
244
+ }
245
+ }
246
+
247
+ static void resolve_or_remove_nameless_interfaces(ifaddrs** list) {
248
+ ifaddrs_storage* addr = reinterpret_cast<ifaddrs_storage*>(*list);
249
+ ifaddrs_storage* prev_addr = nullptr;
250
+ while (addr != nullptr) {
251
+ ifaddrs* next_addr = addr->ifa.ifa_next;
252
+
253
+ // Try resolving interfaces without a name first.
254
+ if (strlen(addr->name) == 0) {
255
+ if (if_indextoname(addr->interface_index, addr->name) != nullptr) {
256
+ addr->ifa.ifa_name = addr->name;
257
+ }
258
+ }
259
+
260
+ // If the interface could not be resolved, remove it.
261
+ if (strlen(addr->name) == 0) {
262
+ if (prev_addr == nullptr) {
263
+ *list = next_addr;
264
+ } else {
265
+ prev_addr->ifa.ifa_next = next_addr;
266
+ }
267
+ free(addr);
268
+ } else {
269
+ prev_addr = addr;
270
+ }
271
+
272
+ addr = reinterpret_cast<ifaddrs_storage*>(next_addr);
273
+ }
274
+ }
275
+
276
+ static void get_interface_flags_via_ioctl(ifaddrs** list) {
277
+ ScopedFd s(socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0));
278
+ if (s.get() == -1) {
279
+ return;
280
+ }
281
+
282
+ for (ifaddrs_storage* addr = reinterpret_cast<ifaddrs_storage*>(*list); addr != nullptr;
283
+ addr = reinterpret_cast<ifaddrs_storage*>(addr->ifa.ifa_next)) {
284
+ ifreq ifr = {};
285
+ strlcpy(ifr.ifr_name, addr->ifa.ifa_name, sizeof(ifr.ifr_name));
286
+ if (ioctl(s.get(), SIOCGIFFLAGS, &ifr) != -1) {
287
+ addr->ifa.ifa_flags = ifr.ifr_flags;
288
+ }
289
+ }
290
+ }
291
+
292
+ int getifaddrs(ifaddrs** out) {
293
+ // We construct the result directly into `out`, so terminate the list.
294
+ *out = nullptr;
295
+
296
+ // Open the netlink socket and ask for all the links and addresses.
297
+ NetlinkConnection nc;
298
+ // SELinux policy only allows RTM_GETLINK messages to be sent by system apps.
299
+ bool getlink_success = false;
300
+ bool getaddr_success =
301
+ nc.SendRequest(RTM_GETADDR) && nc.ReadResponses(__getifaddrs_callback, out);
302
+
303
+ if (!getaddr_success) {
304
+ freeifaddrs(*out);
305
+ // Ensure that callers crash if they forget to check for success.
306
+ *out = nullptr;
307
+ return -1;
308
+ }
309
+
310
+ if (!getlink_success) {
311
+ // If we weren't able to depend on GETLINK messages, it's possible some
312
+ // interfaces never got their name set. Resolve them using if_indextoname or remove them.
313
+ resolve_or_remove_nameless_interfaces(out);
314
+ // Similarly, without GETLINK messages, interfaces will not have their flags set.
315
+ // Resolve them using the SIOCGIFFLAGS ioctl call.
316
+ get_interface_flags_via_ioctl(out);
317
+ }
318
+
319
+ return 0;
320
+ }
321
+
322
+ void freeifaddrs(ifaddrs* list) {
323
+ while (list != nullptr) {
324
+ ifaddrs* current = list;
325
+ list = list->ifa_next;
326
+ free(current);
327
+ }
328
+ }
329
+
330
+ // DITTO VENDORING - bionic/bionic_netlink.cpp, modified
331
+
332
+ NetlinkConnection::NetlinkConnection() {
333
+ // The kernel keeps packets under 8KiB (NLMSG_GOODSIZE),
334
+ // but that's a bit too large to go on the stack.
335
+ size_ = 8192;
336
+ data_ = new char[size_];
337
+ }
338
+
339
+ NetlinkConnection::~NetlinkConnection() {
340
+ delete[] data_;
341
+ }
342
+
343
+ bool NetlinkConnection::SendRequest(int type) {
344
+ // Rather than force all callers to check for the unlikely event of being
345
+ // unable to allocate 8KiB, check here.
346
+ if (data_ == nullptr) return false;
347
+
348
+ // Did we open a netlink socket yet?
349
+ if (fd_.get() == -1) {
350
+ fd_.reset(socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE));
351
+ if (fd_.get() == -1) return false;
352
+ }
353
+
354
+ // Construct and send the message.
355
+ struct NetlinkMessage {
356
+ nlmsghdr hdr;
357
+ rtgenmsg msg;
358
+ } request;
359
+ memset(&request, 0, sizeof(request));
360
+ request.hdr.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
361
+ request.hdr.nlmsg_type = type;
362
+ request.hdr.nlmsg_len = sizeof(request);
363
+ request.msg.rtgen_family = AF_UNSPEC; // All families.
364
+ return (TEMP_FAILURE_RETRY(send(fd_.get(), &request, sizeof(request), 0)) == sizeof(request));
365
+ }
366
+
367
+ bool NetlinkConnection::ReadResponses(void callback(void*, nlmsghdr*), void* context) {
368
+ // Read through all the responses, handing interesting ones to the callback.
369
+ ssize_t bytes_read;
370
+ while ((bytes_read = TEMP_FAILURE_RETRY(recv(fd_.get(), data_, size_, 0))) > 0) {
371
+ nlmsghdr* hdr = reinterpret_cast<nlmsghdr*>(data_);
372
+ for (; NLMSG_OK(hdr, static_cast<size_t>(bytes_read)); hdr = NLMSG_NEXT(hdr, bytes_read)) {
373
+ if (hdr->nlmsg_type == NLMSG_DONE) return true;
374
+ if (hdr->nlmsg_type == NLMSG_ERROR) {
375
+ nlmsgerr* err = reinterpret_cast<nlmsgerr*>(NLMSG_DATA(hdr));
376
+ errno = (hdr->nlmsg_len >= NLMSG_LENGTH(sizeof(nlmsgerr))) ? -err->error : EIO;
377
+ return false;
378
+ }
379
+ callback(context, hdr);
380
+ }
381
+ }
382
+
383
+ // We only get here if recv fails before we see a NLMSG_DONE.
384
+ return false;
385
+ }
@@ -0,0 +1,206 @@
1
+ // DITTO VENDORING - private/ScopedFd.h, modified
2
+
3
+ #include <sys/types.h>
4
+ #include <unistd.h>
5
+
6
+ #include <linux/netlink.h>
7
+ #include <linux/rtnetlink.h>
8
+
9
+ class ScopedFd final {
10
+ public:
11
+ explicit ScopedFd(int fd) : fd_(fd) {
12
+ }
13
+
14
+ ScopedFd() : fd_(-1) {
15
+ }
16
+
17
+ ~ScopedFd() {
18
+ reset(-1);
19
+ }
20
+
21
+ void reset(int fd = -1) {
22
+ if (fd_ != -1) {
23
+ close(fd_);
24
+ }
25
+ fd_ = fd;
26
+ }
27
+
28
+ int get() const {
29
+ return fd_;
30
+ }
31
+
32
+ private:
33
+ int fd_;
34
+
35
+ };
36
+
37
+ // DITTO VENDORING - bionic/ifaddrs.h, modified
38
+
39
+ /*
40
+ * Copyright (C) 2019 The Android Open Source Project
41
+ * All rights reserved.
42
+ *
43
+ * Redistribution and use in source and binary forms, with or without
44
+ * modification, are permitted provided that the following conditions
45
+ * are met:
46
+ * * Redistributions of source code must retain the above copyright
47
+ * notice, this list of conditions and the following disclaimer.
48
+ * * Redistributions in binary form must reproduce the above copyright
49
+ * notice, this list of conditions and the following disclaimer in
50
+ * the documentation and/or other materials provided with the
51
+ * distribution.
52
+ *
53
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
56
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
57
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
58
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
59
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
60
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
61
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
62
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
63
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64
+ * SUCH DAMAGE.
65
+ */
66
+
67
+
68
+ /*
69
+ * Copyright (C) 2015 The Android Open Source Project
70
+ * All rights reserved.
71
+ *
72
+ * Redistribution and use in source and binary forms, with or without
73
+ * modification, are permitted provided that the following conditions
74
+ * are met:
75
+ * * Redistributions of source code must retain the above copyright
76
+ * notice, this list of conditions and the following disclaimer.
77
+ * * Redistributions in binary form must reproduce the above copyright
78
+ * notice, this list of conditions and the following disclaimer in
79
+ * the documentation and/or other materials provided with the
80
+ * distribution.
81
+ *
82
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
83
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
84
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
85
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
86
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
87
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
88
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
89
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
90
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
91
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
92
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
93
+ * SUCH DAMAGE.
94
+ */
95
+
96
+ /**
97
+ * @file ifaddrs.h
98
+ * @brief Access to network interface addresses.
99
+ */
100
+
101
+ #include <sys/cdefs.h>
102
+ #include <netinet/in.h>
103
+ #include <sys/socket.h>
104
+
105
+ __BEGIN_DECLS
106
+
107
+ /**
108
+ * Returned by getifaddrs() and freed by freeifaddrs().
109
+ */
110
+ struct ifaddrs {
111
+ /** Pointer to the next element in the linked list. */
112
+ struct ifaddrs* ifa_next;
113
+
114
+ /** Interface name. */
115
+ char* ifa_name;
116
+ /** Interface flags (like `SIOCGIFFLAGS`). */
117
+ unsigned int ifa_flags;
118
+ /** Interface address. */
119
+ struct sockaddr* ifa_addr;
120
+ /** Interface netmask. */
121
+ struct sockaddr* ifa_netmask;
122
+
123
+ union {
124
+ /** Interface broadcast address (if IFF_BROADCAST is set). */
125
+ struct sockaddr* ifu_broadaddr;
126
+ /** Interface destination address (if IFF_POINTOPOINT is set). */
127
+ struct sockaddr* ifu_dstaddr;
128
+ } ifa_ifu;
129
+
130
+ /** Unused. */
131
+ void* ifa_data;
132
+ };
133
+
134
+ /** Synonym for `ifa_ifu.ifu_broadaddr` in `struct ifaddrs`. */
135
+ #define ifa_broadaddr ifa_ifu.ifu_broadaddr
136
+ /** Synonym for `ifa_ifu.ifu_dstaddr` in `struct ifaddrs`. */
137
+ #define ifa_dstaddr ifa_ifu.ifu_dstaddr
138
+
139
+ /**
140
+ * [getifaddrs(3)](http://man7.org/linux/man-pages/man3/getifaddrs.3.html) creates a linked list
141
+ * of `struct ifaddrs`. The list must be freed by freeifaddrs().
142
+ *
143
+ * Returns 0 and stores the list in `*__list_ptr` on success,
144
+ * and returns -1 and sets `errno` on failure.
145
+ *
146
+ * Available since API level 24.
147
+ */
148
+ int getifaddrs(struct ifaddrs** __list_ptr) __INTRODUCED_IN(24);
149
+
150
+ /**
151
+ * [freeifaddrs(3)](http://man7.org/linux/man-pages/man3/freeifaddrs.3.html) frees a linked list
152
+ * of `struct ifaddrs` returned by getifaddrs().
153
+ *
154
+ * Available since API level 24.
155
+ */
156
+ void freeifaddrs(struct ifaddrs* __ptr) __INTRODUCED_IN(24);
157
+
158
+ __END_DECLS
159
+
160
+
161
+ // DITTO VENDORING - bionic/bionic_netlink.h, modified
162
+
163
+ /*
164
+ * Copyright (C) 2016 The Android Open Source Project
165
+ * All rights reserved.
166
+ *
167
+ * Redistribution and use in source and binary forms, with or without
168
+ * modification, are permitted provided that the following conditions
169
+ * are met:
170
+ * * Redistributions of source code must retain the above copyright
171
+ * notice, this list of conditions and the following disclaimer.
172
+ * * Redistributions in binary form must reproduce the above copyright
173
+ * notice, this list of conditions and the following disclaimer in
174
+ * the documentation and/or other materials provided with the
175
+ * distribution.
176
+ *
177
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
178
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
179
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
180
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
181
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
182
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
183
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
184
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
185
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
186
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
187
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
188
+ * SUCH DAMAGE.
189
+ */
190
+
191
+
192
+ struct nlmsghdr;
193
+
194
+ class NetlinkConnection {
195
+ public:
196
+ NetlinkConnection();
197
+ ~NetlinkConnection();
198
+
199
+ bool SendRequest(int type);
200
+ bool ReadResponses(void callback(void*, nlmsghdr*), void* context);
201
+
202
+ private:
203
+ ScopedFd fd_;
204
+ char* data_;
205
+ size_t size_;
206
+ };
@@ -0,0 +1,7 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface DittoRNSDK : NSObject <RCTBridgeModule>
4
+
5
+ @property(nonatomic, assign) BOOL setBridgeOnMainQueue;
6
+
7
+ @end