├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── cargo.yml ├── .gitignore ├── Cargo.toml ├── LICENSE.md ├── README.md ├── build.rs ├── build ├── ci.sh └── ubuntu_gen_bindings.sh ├── examples └── smoketest.rs ├── src ├── bccapi │ ├── mod.rs │ ├── v0_10_0.rs │ ├── v0_11_0.rs │ ├── v0_12_0.rs │ ├── v0_13_0.rs │ ├── v0_14_0.rs │ ├── v0_15_0.rs │ ├── v0_16_0.rs │ ├── v0_17_0.rs │ ├── v0_18_0.rs │ ├── v0_19_0.rs │ ├── v0_20_0.rs │ ├── v0_21_0.rs │ ├── v0_22_0.rs │ ├── v0_23_0.rs │ ├── v0_4_0.rs │ ├── v0_5_0.rs │ ├── v0_6_0.rs │ ├── v0_6_1.rs │ ├── v0_7_0.rs │ ├── v0_8_0.rs │ └── v0_9_0.rs └── lib.rs └── wrapper.h /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | One line summary of the issue here 2 | 3 | briefly answer these questions: 4 | 5 | * what did you expect? 6 | * what actually happened? 7 | * what steps can we take to reproduce the behaviour you saw? 8 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | briefly answer these questions: 2 | 3 | * what problem are you trying to solve? (or if there's no problem, what's the motivation for this 4 | change?) 5 | * what changes does this pull request make? 6 | * are there any non-obvious implications of these changes? (does it break compatibility with previous 7 | versions, etc) 8 | -------------------------------------------------------------------------------- /.github/workflows/cargo.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: [ master ] 4 | pull_request: 5 | branches: [ master ] 6 | 7 | env: 8 | CARGO_TERM_COLOR: always 9 | 10 | jobs: 11 | focal-llvm_9-bcc_v0_12_0: 12 | name: focal / llvm 9 / bcc 0.12.0 13 | runs-on: ubuntu-20.04 14 | env: 15 | BCC: "0.12.0" 16 | DIST: focal 17 | FEATURES: v0_12_0 18 | LLVM: 9 19 | steps: 20 | - uses: actions/checkout@v2 21 | - name: BCC Build Cache 22 | uses: actions/cache@v2 23 | with: 24 | path: | 25 | deps 26 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 27 | - name: Run CI 28 | run: bash -e build/ci.sh 29 | focal-llvm_9-bcc_v0_13_0: 30 | name: focal / llvm 9 / bcc 0.13.0 31 | runs-on: ubuntu-20.04 32 | env: 33 | BCC: "0.13.0" 34 | DIST: focal 35 | FEATURES: v0_13_0 36 | LLVM: 9 37 | steps: 38 | - uses: actions/checkout@v2 39 | - name: BCC Build Cache 40 | uses: actions/cache@v2 41 | with: 42 | path: | 43 | deps 44 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 45 | - name: Run CI 46 | run: bash -e build/ci.sh 47 | focal-llvm_9-bcc_v0_14_0: 48 | name: focal / llvm 9 / bcc 0.14.0 49 | runs-on: ubuntu-20.04 50 | env: 51 | BCC: "0.14.0" 52 | DIST: focal 53 | FEATURES: v0_14_0 54 | LLVM: 9 55 | steps: 56 | - uses: actions/checkout@v2 57 | - name: Run CI 58 | run: bash -e build/ci.sh 59 | focal-llvm_9-bcc_v0_15_0: 60 | name: focal / llvm 9 / bcc 0.15.0 61 | runs-on: ubuntu-20.04 62 | env: 63 | BCC: "0.15.0" 64 | DIST: focal 65 | FEATURES: v0_15_0 66 | LLVM: 9 67 | steps: 68 | - uses: actions/checkout@v2 69 | - name: BCC Build Cache 70 | uses: actions/cache@v2 71 | with: 72 | path: | 73 | deps 74 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 75 | - name: Run CI 76 | run: bash -e build/ci.sh 77 | focal-llvm_9-bcc_v0_16_0: 78 | name: focal / llvm 9 / bcc 0.16.0 79 | runs-on: ubuntu-20.04 80 | env: 81 | BCC: "0.16.0" 82 | DIST: focal 83 | FEATURES: v0_16_0 84 | LLVM: 9 85 | steps: 86 | - uses: actions/checkout@v2 87 | - name: BCC Build Cache 88 | uses: actions/cache@v2 89 | with: 90 | path: | 91 | deps 92 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 93 | - name: Run CI 94 | run: bash -e build/ci.sh 95 | focal-llvm_9-bcc_v0_17_0: 96 | name: focal / llvm 9 / bcc 0.17.0 97 | runs-on: ubuntu-20.04 98 | env: 99 | BCC: "0.17.0" 100 | DIST: focal 101 | FEATURES: v0_17_0 102 | LLVM: 9 103 | steps: 104 | - uses: actions/checkout@v2 105 | - name: BCC Build Cache 106 | uses: actions/cache@v2 107 | with: 108 | path: | 109 | deps 110 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 111 | - name: Run CI 112 | run: bash -e build/ci.sh 113 | focal-llvm_9-bcc_v0_17_0-static: 114 | name: focal / llvm 9 / bcc 0.17.0 / static 115 | runs-on: ubuntu-20.04 116 | env: 117 | BCC: "0.17.0" 118 | DIST: focal 119 | FEATURES: v0_17_0 static 120 | LLVM: 9 121 | STATIC: true 122 | steps: 123 | - uses: actions/checkout@v2 124 | - name: BCC Build Cache 125 | uses: actions/cache@v2 126 | with: 127 | path: | 128 | deps 129 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 130 | - name: Run CI 131 | run: bash -e build/ci.sh 132 | focal-llvm_9-bcc_v0_18_0: 133 | name: focal / llvm 9 / bcc 0.18.0 134 | runs-on: ubuntu-20.04 135 | env: 136 | BCC: "0.18.0" 137 | DIST: focal 138 | FEATURES: v0_18_0 139 | LLVM: 9 140 | steps: 141 | - uses: actions/checkout@v2 142 | - name: BCC Build Cache 143 | uses: actions/cache@v2 144 | with: 145 | path: | 146 | deps 147 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 148 | - name: Run CI 149 | run: bash -e build/ci.sh 150 | focal-llvm_9-bcc_v0_18_0-static: 151 | name: focal / llvm 9 / bcc 0.18.0 / static 152 | runs-on: ubuntu-20.04 153 | env: 154 | BCC: "0.18.0" 155 | DIST: focal 156 | FEATURES: v0_18_0 static 157 | LLVM: 9 158 | STATIC: true 159 | steps: 160 | - uses: actions/checkout@v2 161 | - name: BCC Build Cache 162 | uses: actions/cache@v2 163 | with: 164 | path: | 165 | deps 166 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 167 | - name: Run CI 168 | run: bash -e build/ci.sh 169 | focal-llvm_9-bcc_v0_19_0: 170 | name: focal / llvm 9 / bcc 0.19.0 171 | runs-on: ubuntu-20.04 172 | env: 173 | BCC: "0.19.0" 174 | DIST: focal 175 | FEATURES: v0_19_0 176 | LLVM: 9 177 | steps: 178 | - uses: actions/checkout@v2 179 | - name: BCC Build Cache 180 | uses: actions/cache@v2 181 | with: 182 | path: | 183 | deps 184 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 185 | - name: Run CI 186 | run: bash -e build/ci.sh 187 | focal-llvm_9-bcc_v0_19_0-static: 188 | name: focal / llvm 9 / bcc 0.19.0 / static 189 | runs-on: ubuntu-20.04 190 | env: 191 | BCC: "0.19.0" 192 | DIST: focal 193 | FEATURES: v0_19_0 static 194 | LLVM: 9 195 | STATIC: true 196 | steps: 197 | - uses: actions/checkout@v2 198 | - name: BCC Build Cache 199 | uses: actions/cache@v2 200 | with: 201 | path: | 202 | deps 203 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 204 | - name: Run CI 205 | run: bash -e build/ci.sh 206 | focal-llvm_9-bcc_v0_20_0: 207 | name: focal / llvm 9 / bcc 0.20.0 208 | runs-on: ubuntu-20.04 209 | env: 210 | BCC: "0.20.0" 211 | DIST: focal 212 | FEATURES: v0_20_0 213 | LLVM: 9 214 | steps: 215 | - uses: actions/checkout@v2 216 | - name: BCC Build Cache 217 | uses: actions/cache@v2 218 | with: 219 | path: | 220 | deps 221 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 222 | - name: Run CI 223 | run: bash -e build/ci.sh 224 | focal-llvm_9-bcc_v0_20_0-static: 225 | name: focal / llvm 9 / bcc 0.20.0 / static 226 | runs-on: ubuntu-20.04 227 | env: 228 | BCC: "0.20.0" 229 | DIST: focal 230 | FEATURES: v0_20_0 static 231 | LLVM: 9 232 | STATIC: true 233 | steps: 234 | - uses: actions/checkout@v2 235 | - name: BCC Build Cache 236 | uses: actions/cache@v2 237 | with: 238 | path: | 239 | deps 240 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 241 | - name: Run CI 242 | run: bash -e build/ci.sh 243 | focal-llvm_9-bcc_v0_21_0: 244 | name: focal / llvm 9 / bcc 0.21.0 245 | runs-on: ubuntu-20.04 246 | env: 247 | BCC: "0.21.0" 248 | DIST: focal 249 | FEATURES: v0_21_0 250 | LLVM: 9 251 | steps: 252 | - uses: actions/checkout@v2 253 | - name: BCC Build Cache 254 | uses: actions/cache@v2 255 | with: 256 | path: | 257 | deps 258 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 259 | - name: Run CI 260 | run: bash -e build/ci.sh 261 | focal-llvm_9-bcc_v0_21_0-static: 262 | name: focal / llvm 9 / bcc 0.21.0 / static 263 | runs-on: ubuntu-20.04 264 | env: 265 | BCC: "0.21.0" 266 | DIST: focal 267 | FEATURES: v0_21_0 static 268 | LLVM: 9 269 | STATIC: true 270 | steps: 271 | - uses: actions/checkout@v2 272 | - name: BCC Build Cache 273 | uses: actions/cache@v2 274 | with: 275 | path: | 276 | deps 277 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 278 | - name: Run CI 279 | run: bash -e build/ci.sh 280 | focal-llvm_9-bcc_v0_22_0: 281 | name: focal / llvm 9 / bcc 0.22.0 282 | runs-on: ubuntu-20.04 283 | env: 284 | BCC: "0.22.0" 285 | DIST: focal 286 | FEATURES: v0_22_0 287 | LLVM: 9 288 | steps: 289 | - uses: actions/checkout@v2 290 | - name: BCC Build Cache 291 | uses: actions/cache@v2 292 | with: 293 | path: | 294 | deps 295 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 296 | - name: Run CI 297 | run: bash -e build/ci.sh 298 | focal-llvm_9-bcc_v0_22_0-static: 299 | name: focal / llvm 9 / bcc 0.22.0 / static 300 | runs-on: ubuntu-20.04 301 | env: 302 | BCC: "0.22.0" 303 | DIST: focal 304 | FEATURES: v0_22_0 static 305 | LLVM: 9 306 | STATIC: true 307 | steps: 308 | - uses: actions/checkout@v2 309 | - name: BCC Build Cache 310 | uses: actions/cache@v2 311 | with: 312 | path: | 313 | deps 314 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 315 | - name: Run CI 316 | run: bash -e build/ci.sh 317 | focal-llvm_9-bcc_v0_23_0: 318 | name: focal / llvm 9 / bcc 0.23.0 319 | runs-on: ubuntu-20.04 320 | env: 321 | BCC: "0.23.0" 322 | DIST: focal 323 | FEATURES: v0_23_0 324 | LLVM: 9 325 | steps: 326 | - uses: actions/checkout@v2 327 | - name: BCC Build Cache 328 | uses: actions/cache@v2 329 | with: 330 | path: | 331 | deps 332 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }} 333 | - name: Run CI 334 | run: bash -e build/ci.sh 335 | focal-llvm_9-bcc_v0_23_0-static: 336 | name: focal / llvm 9 / bcc 0.23.0 / static 337 | runs-on: ubuntu-20.04 338 | env: 339 | BCC: "0.23.0" 340 | DIST: focal 341 | FEATURES: v0_23_0 static 342 | LLVM: 9 343 | STATIC: true 344 | steps: 345 | - uses: actions/checkout@v2 346 | - name: BCC Build Cache 347 | uses: actions/cache@v2 348 | with: 349 | path: | 350 | deps 351 | key: ${{ env.DIST }}-${{ env.LLVM }}-${{ env.BCC }}-static 352 | - name: Run CI 353 | run: bash -e build/ci.sh 354 | rustfmt: 355 | runs-on: ubuntu-latest 356 | steps: 357 | - uses: actions/checkout@v2 358 | - name: install rustfmt 359 | run: rustup component add rustfmt 360 | - name: rustfmt 361 | run: cargo fmt -- --check 362 | clippy: 363 | runs-on: ubuntu-latest 364 | steps: 365 | - uses: actions/checkout@v2 366 | - name: install clippy 367 | run: rustup component add clippy 368 | - name: clippy 369 | run: cargo clippy || cargo clippy 370 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | **/*.rs.bk 3 | Cargo.lock 4 | bcc/ 5 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bcc-sys" 3 | version = "0.23.0" 4 | authors = ["Zhiting Zhu ", "Brian Martin "] 5 | description = "Rust binding to BPF Compiler Collection (BCC)" 6 | keywords = ["bpf", "bindings"] 7 | license = "Apache-2.0" 8 | repository = "https://github.com/rust-bpf/bcc-sys" 9 | build = "build.rs" 10 | readme = "README.md" 11 | links = "bcc" 12 | documentation = "https://docs.rs/bcc-sys" 13 | homepage = "https://github.com/rust-bpf/bcc-sys" 14 | edition = '2018' 15 | 16 | [build-dependencies.bindgen] 17 | version = "0.59.1" 18 | optional = true 19 | 20 | [lib] 21 | name = "bcc_sys" 22 | 23 | [features] 24 | generate = ["bindgen"] 25 | llvm_8 = ["specific_llvm"] 26 | llvm_9 = ["specific_llvm"] 27 | specific = [] 28 | specific_llvm = [] 29 | static = [] 30 | v0_4_0 = ["specific"] 31 | v0_5_0 = ["specific"] 32 | v0_6_0 = ["specific"] 33 | v0_6_1 = ["specific"] 34 | v0_7_0 = ["specific"] 35 | v0_8_0 = ["specific"] 36 | v0_9_0 = ["specific"] 37 | v0_10_0 = ["specific"] 38 | v0_11_0 = ["specific"] 39 | v0_12_0 = ["specific"] 40 | v0_13_0 = ["specific"] 41 | v0_14_0 = ["specific"] 42 | v0_15_0 = ["specific"] 43 | v0_16_0 = ["specific"] 44 | v0_17_0 = ["specific"] 45 | v0_18_0 = ["specific"] 46 | v0_19_0 = ["specific"] 47 | v0_20_0 = ["specific"] 48 | v0_21_0 = ["specific"] 49 | v0_22_0 = ["specific"] 50 | v0_23_0 = ["specific"] 51 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/rust-bpf/bcc-sys.svg?branch=master)](https://travis-ci.org/rust-bpf/bcc-sys) 2 | 3 | Rust binding for [bcc](https://github.com/iovisor/bcc). 4 | 5 | # Pre-requisites 6 | * bcc must be installed before using this binding. 7 | 8 | # Supported bcc versions 9 | 10 | bcc 0.4.0 - 0.23.0 are supported via feature flags. 11 | 12 | **Note:** If you do not specify a version of bcc using feature flags, the 13 | library will expect the latest version of bcc supported by the release of this 14 | library. You must specify a version using the matching feature flag to override 15 | this behavior. 16 | 17 | # Static linking 18 | 19 | This library allows static linking of bcc and other libraries required to write 20 | BPF utilities in Rust without needing to have bpf/bcc libraries available at 21 | runtime. This requires matching the llvm feature flag to your installed version 22 | and having specific prerequisites available. See the [GitHub Workflow config] 23 | for more details. 24 | 25 | # Generating new bindings 26 | 27 | Freshly generated bindings will sometimes be required: 28 | * to support new versions of bcc 29 | * to regenerate older bindings with a newer version of bindgen 30 | 31 | ## How to generate new bindings 32 | 33 | Before you generate fresh bindings, you should have `rustfmt` installed on your 34 | system. Install `rustfmt` with: 35 | ``` 36 | $ rustup component add rustfmt 37 | $ rustup update 38 | ``` 39 | 40 | You may then build this crate using: 41 | ```cargo build --features generate``` 42 | 43 | The fresh bindings will be placed into `src/bccapi/generated.rs` 44 | 45 | **NOTE:** you may need to make changes to `build.rs` and/or `wrapper.h` 46 | to add support for a new version of bcc 47 | 48 | ## Adding newly generated bindings 49 | 50 | To use the newly generated bindings, we must add them to the library. 51 | 52 | * Move your generated bindings to a version specific module under `src/bccapi`. 53 | Follow existing naming conventions. 54 | * If you've added bindings for a new version: 55 | * Modify `src/bccapi/mod.rs` to add the new module to this library. 56 | * Modify `Cargo.toml` to define a feature for the new bcc version. 57 | 58 | `rustfmt` is required to generate new bindings. 59 | 60 | [GitHub Workflow config]: https://github.com/rust-bpf/bcc-sys/tree/.github/workflows/cargo.yml -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | #[allow(unused)] 2 | const ALLOWLIST_FUNCTION: &'static [&'static str] = &["bpf_.*", "bcc_.*", "perf_reader_.*"]; 3 | 4 | #[allow(unused)] 5 | const ALLOWLIST_TYPES: &'static [&'static str] = &[ 6 | "bcc_symbol", 7 | "perf_reader", 8 | "__sk_buff", 9 | "xdp_action", 10 | "xdp_md", 11 | "sk_action", 12 | "bpf_.*", 13 | ]; 14 | 15 | #[allow(unused)] 16 | const ALLOWLIST_VARS: &'static [&'static str] = &[ 17 | "LOG_BUF_SIZE", 18 | "BPF_.*", 19 | "MAX_BPF_REG", 20 | "MAX_BPF_ATTACH_TYPE", 21 | "__BPF_FUNC_MAPPER", 22 | "__BPF_ENUM_FN", 23 | "XDP_PACKET_HEADROOM", 24 | "TCP_BPF_IW", 25 | "TCP_BPF_SNDCWND_CLAMP", 26 | "STT_GNU_IFUNC", 27 | ]; 28 | 29 | #[allow(unused)] 30 | const BLOCKLIST_TYPES: &'static [&'static str] = &[ 31 | // bindgen generates a misaligned type for this struct 32 | "bpf_raw_tracepoint_args", 33 | ]; 34 | 35 | fn main() { 36 | linking_info(); 37 | 38 | #[cfg(feature = "generate")] 39 | { 40 | build_bcc_bindings(); 41 | } 42 | } 43 | 44 | // define the function for when we will generate bindings 45 | #[cfg(feature = "generate")] 46 | fn build_bcc_bindings() { 47 | let mut bindings = bindgen::Builder::default() 48 | .header("wrapper.h") 49 | .clang_arg("-I") 50 | .clang_arg(concat!(env!("CARGO_MANIFEST_DIR"), "/include")); 51 | 52 | if cfg!(any( 53 | feature = "v0_4_0", 54 | feature = "v0_5_0", 55 | feature = "v0_6_0", 56 | feature = "v0_6_1", 57 | feature = "v0_7_0", 58 | feature = "v0_8_0", 59 | )) { 60 | bindings = bindings.clang_arg("-D__BPF_COMMON__"); 61 | } else { 62 | bindings = bindings.clang_arg("-D__BCC_COMMON__"); 63 | } 64 | 65 | for func in ALLOWLIST_FUNCTION { 66 | bindings = bindings.allowlist_function(func); 67 | } 68 | 69 | for ty in ALLOWLIST_TYPES { 70 | bindings = bindings.allowlist_type(ty); 71 | } 72 | 73 | for var in ALLOWLIST_VARS { 74 | bindings = bindings.allowlist_var(var); 75 | } 76 | 77 | for ty in BLOCKLIST_TYPES { 78 | bindings = bindings.blocklist_type(ty); 79 | } 80 | 81 | bindings = bindings 82 | .size_t_is_usize(true) 83 | .derive_debug(true) 84 | .impl_debug(true) 85 | .derive_default(true) 86 | .derive_partialeq(true) 87 | .impl_partialeq(true) 88 | .derive_eq(true) 89 | .derive_partialord(true) 90 | .derive_ord(true) 91 | .derive_hash(true) 92 | .rustfmt_bindings(true); 93 | 94 | let builder = bindings 95 | .generate() 96 | .expect("Should generate BCC API bindings OK"); 97 | 98 | builder 99 | .write_to_file("src/generated.rs") 100 | .expect("Couldn't write bcc bindings!"); 101 | let have_working_rustfmt = std::process::Command::new("rustup") 102 | .args(&["run", "rustfmt", "--version"]) 103 | .stdout(std::process::Stdio::null()) 104 | .stderr(std::process::Stdio::null()) 105 | .status() 106 | .ok() 107 | .map_or(false, |status| status.success()); 108 | 109 | if !have_working_rustfmt { 110 | println!( 111 | " 112 | The latest `rustfmt` is required to format the generated bindings. Install 113 | `rustfmt` with: 114 | $ rustup component add rustfmt 115 | $ rustup update 116 | " 117 | ); 118 | } 119 | } 120 | 121 | #[cfg(not(feature = "static"))] 122 | fn linking_info() { 123 | println!("cargo:rustc-link-lib=bcc"); 124 | } 125 | 126 | #[cfg(feature = "static")] 127 | fn linking_info() { 128 | println!("cargo:rustc-link-lib=static=z"); 129 | println!("cargo:rustc-link-lib=static=elf"); 130 | println!("cargo:rustc-link-lib=static=xml2"); 131 | println!("cargo:rustc-link-lib=static=lzma"); 132 | println!("cargo:rustc-link-lib=static=tinfo"); 133 | 134 | println!("cargo:rustc-link-lib=stdc++"); 135 | 136 | println!("cargo:rustc-link-lib=static=bcc"); 137 | println!("cargo:rustc-link-lib=static=bcc-loader-static"); 138 | if cfg!(any( 139 | feature = "v0_4_0", 140 | feature = "v0_5_0", 141 | feature = "v0_6_0", 142 | feature = "v0_6_1", 143 | feature = "v0_7_0", 144 | feature = "v0_8_0", 145 | feature = "v0_9_0", 146 | )) { 147 | println!("cargo:rustc-link-lib=static=bpf"); 148 | } else { 149 | println!("cargo:rustc-link-lib=static=bcc_bpf"); 150 | } 151 | println!("cargo:rustc-link-lib=static=b_frontend"); 152 | println!("cargo:rustc-link-lib=static=clang_frontend"); 153 | println!("cargo:rustc-link-lib=static=usdt-static"); 154 | 155 | println!("cargo:rustc-link-lib=static=LLVMLTO"); 156 | println!("cargo:rustc-link-lib=static=LLVMPasses"); 157 | println!("cargo:rustc-link-lib=static=LLVMObjCARCOpts"); 158 | println!("cargo:rustc-link-lib=static=LLVMSymbolize"); 159 | println!("cargo:rustc-link-lib=static=LLVMDebugInfoPDB"); 160 | println!("cargo:rustc-link-lib=static=LLVMDebugInfoDWARF"); 161 | println!("cargo:rustc-link-lib=static=LLVMFuzzMutate"); 162 | println!("cargo:rustc-link-lib=static=LLVMMCA"); 163 | println!("cargo:rustc-link-lib=static=LLVMTableGen"); 164 | println!("cargo:rustc-link-lib=static=LLVMDlltoolDriver"); 165 | println!("cargo:rustc-link-lib=static=LLVMLineEditor"); 166 | println!("cargo:rustc-link-lib=static=LLVMXRay"); 167 | println!("cargo:rustc-link-lib=static=LLVMOrcJIT"); 168 | println!("cargo:rustc-link-lib=static=LLVMCoverage"); 169 | println!("cargo:rustc-link-lib=static=LLVMMIRParser"); 170 | println!("cargo:rustc-link-lib=static=LLVMBPFDisassembler"); 171 | println!("cargo:rustc-link-lib=static=LLVMBPFCodeGen"); 172 | println!("cargo:rustc-link-lib=static=LLVMBPFAsmParser"); 173 | println!("cargo:rustc-link-lib=static=LLVMBPFDesc"); 174 | println!("cargo:rustc-link-lib=static=LLVMBPFInfo"); 175 | if cfg!(any(feature = "llvm_8")) { 176 | println!("cargo:rustc-link-lib=static=LLVMBPFAsmPrinter"); 177 | } 178 | println!("cargo:rustc-link-lib=static=LLVMObjectYAML"); 179 | println!("cargo:rustc-link-lib=static=LLVMLibDriver"); 180 | println!("cargo:rustc-link-lib=static=LLVMOption"); 181 | println!("cargo:rustc-link-lib=static=LLVMWindowsManifest"); 182 | println!("cargo:rustc-link-lib=static=LLVMTextAPI"); 183 | println!("cargo:rustc-link-lib=static=LLVMX86Disassembler"); 184 | println!("cargo:rustc-link-lib=static=LLVMX86AsmParser"); 185 | println!("cargo:rustc-link-lib=static=LLVMX86CodeGen"); 186 | if cfg!(any(feature = "llvm_8")) { 187 | println!("cargo:rustc-link-lib=static=LLVMX86AsmPrinter"); 188 | } 189 | println!("cargo:rustc-link-lib=static=LLVMGlobalISel"); 190 | println!("cargo:rustc-link-lib=static=LLVMSelectionDAG"); 191 | println!("cargo:rustc-link-lib=static=LLVMAsmPrinter"); 192 | println!("cargo:rustc-link-lib=static=LLVMX86Desc"); 193 | println!("cargo:rustc-link-lib=static=LLVMMCDisassembler"); 194 | println!("cargo:rustc-link-lib=static=LLVMX86Info"); 195 | println!("cargo:rustc-link-lib=static=LLVMX86Utils"); 196 | println!("cargo:rustc-link-lib=static=LLVMMCJIT"); 197 | println!("cargo:rustc-link-lib=static=LLVMInterpreter"); 198 | println!("cargo:rustc-link-lib=static=LLVMExecutionEngine"); 199 | println!("cargo:rustc-link-lib=static=LLVMRuntimeDyld"); 200 | println!("cargo:rustc-link-lib=static=LLVMCodeGen"); 201 | println!("cargo:rustc-link-lib=static=LLVMTarget"); 202 | println!("cargo:rustc-link-lib=static=LLVMCoroutines"); 203 | println!("cargo:rustc-link-lib=static=LLVMipo"); 204 | println!("cargo:rustc-link-lib=static=LLVMInstrumentation"); 205 | println!("cargo:rustc-link-lib=static=LLVMVectorize"); 206 | println!("cargo:rustc-link-lib=static=LLVMScalarOpts"); 207 | println!("cargo:rustc-link-lib=static=LLVMLinker"); 208 | println!("cargo:rustc-link-lib=static=LLVMIRReader"); 209 | println!("cargo:rustc-link-lib=static=LLVMAsmParser"); 210 | println!("cargo:rustc-link-lib=static=LLVMInstCombine"); 211 | println!("cargo:rustc-link-lib=static=LLVMBitWriter"); 212 | println!("cargo:rustc-link-lib=static=LLVMAggressiveInstCombine"); 213 | println!("cargo:rustc-link-lib=static=LLVMTransformUtils"); 214 | println!("cargo:rustc-link-lib=static=LLVMAnalysis"); 215 | println!("cargo:rustc-link-lib=static=LLVMProfileData"); 216 | println!("cargo:rustc-link-lib=static=LLVMObject"); 217 | println!("cargo:rustc-link-lib=static=LLVMMCParser"); 218 | println!("cargo:rustc-link-lib=static=LLVMMC"); 219 | println!("cargo:rustc-link-lib=static=LLVMDebugInfoCodeView"); 220 | println!("cargo:rustc-link-lib=static=LLVMDebugInfoMSF"); 221 | println!("cargo:rustc-link-lib=static=LLVMBitReader"); 222 | if cfg!(any(feature = "llvm_9", not(feature = "specific_llvm"),)) { 223 | println!("cargo:rustc-link-lib=static=LLVMBitstreamReader"); 224 | } 225 | println!("cargo:rustc-link-lib=static=LLVMCore"); 226 | println!("cargo:rustc-link-lib=static=LLVMBinaryFormat"); 227 | println!("cargo:rustc-link-lib=static=LLVMSupport"); 228 | println!("cargo:rustc-link-lib=static=LLVMDemangle"); 229 | if cfg!(any(feature = "llvm_9", not(feature = "specific_llvm"),)) { 230 | println!("cargo:rustc-link-lib=static=LLVMRemarks"); 231 | } 232 | 233 | println!("cargo:rustc-link-lib=static=clangAnalysis"); 234 | println!("cargo:rustc-link-lib=static=clangARCMigrate"); 235 | println!("cargo:rustc-link-lib=static=clangAST"); 236 | println!("cargo:rustc-link-lib=static=clangASTMatchers"); 237 | println!("cargo:rustc-link-lib=static=clangBasic"); 238 | println!("cargo:rustc-link-lib=static=clangCodeGen"); 239 | println!("cargo:rustc-link-lib=static=clangDriver"); 240 | println!("cargo:rustc-link-lib=static=clangDynamicASTMatchers"); 241 | println!("cargo:rustc-link-lib=static=clangEdit"); 242 | println!("cargo:rustc-link-lib=static=clangFormat"); 243 | println!("cargo:rustc-link-lib=static=clangFrontend"); 244 | println!("cargo:rustc-link-lib=static=clangFrontendTool"); 245 | println!("cargo:rustc-link-lib=static=clangIndex"); 246 | println!("cargo:rustc-link-lib=static=clangLex"); 247 | println!("cargo:rustc-link-lib=static=clangParse"); 248 | println!("cargo:rustc-link-lib=static=clangRewrite"); 249 | println!("cargo:rustc-link-lib=static=clangRewriteFrontend"); 250 | println!("cargo:rustc-link-lib=static=clangSema"); 251 | println!("cargo:rustc-link-lib=static=clangSerialization"); 252 | println!("cargo:rustc-link-lib=static=clangStaticAnalyzerCheckers"); 253 | println!("cargo:rustc-link-lib=static=clangStaticAnalyzerCore"); 254 | println!("cargo:rustc-link-lib=static=clangStaticAnalyzerFrontend"); 255 | println!("cargo:rustc-link-lib=static=clangTooling"); 256 | println!("cargo:rustc-link-lib=static=clangToolingCore"); 257 | } 258 | -------------------------------------------------------------------------------- /build/ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ev 2 | 3 | set -e 4 | 5 | ## Update apt 6 | sudo apt-get update >/dev/null 2>&1 7 | 8 | ## Install kernel headers for matching version 9 | sudo apt-get install linux-headers-"$(uname -r)" >/dev/null 2>&1 10 | sudo apt-get remove *llvm* *clang* *gtk* >/dev/null 2>&1 11 | sudo apt-get --yes install clang-"${LLVM}" libclang-"${LLVM}"-dev libelf-dev \ 12 | libfl-dev llvm-"${LLVM}"-dev libz-dev llvm-"${LLVM}" >/dev/null 2>&1 13 | 14 | # For static builds, we need to compile the following 15 | if [[ $STATIC == true ]]; then 16 | export CPPFLAGS="-P" 17 | export CFLAGS="-fPIC" 18 | 19 | BINUTILS_VERSION="2.34.90" 20 | ZLIB_VERSION="1.2.11" 21 | XZ_VERSION="5.2.5" 22 | NCURSES_VERSION="6.2" 23 | LIBXML2_SHA="41a34e1f4ffae2ce401600dbb5fe43f8fe402641" 24 | ELFUTILS_VERSION="0.180" 25 | 26 | echo "build binutils" 27 | date -u 28 | if [ ! -d binutils-2.34.90 ]; then 29 | curl -L -O ftp://sourceware.org/pub/binutils/snapshots/binutils-${BINUTILS_VERSION}.tar.xz 30 | tar xf binutils-${BINUTILS_VERSION}.tar.xz 31 | fi 32 | cd binutils-${BINUTILS_VERSION} 33 | if [ ! -f Makefile ]; then 34 | ./configure --prefix=/usr >/dev/null 2>&1 35 | fi 36 | make -j2 >/dev/null 2>&1 37 | sudo make install >/dev/null 2>&1 38 | cd .. 39 | 40 | echo "build zlib" 41 | date -u 42 | if [ ! -d zlib-${ZLIB_VERSION} ]; then 43 | curl -L -O https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz 44 | tar xzf zlib-${ZLIB_VERSION}.tar.gz 45 | fi 46 | cd zlib-${ZLIB_VERSION} 47 | ./configure --prefix=/usr >/dev/null 2>&1 48 | make -j2 >/dev/null 2>&1 49 | sudo make install >/dev/null 2>&1 50 | cd .. 51 | 52 | echo "build xz" 53 | date -u 54 | if [ ! -d xz-${XZ_VERSION} ]; then 55 | curl -L -O https://tukaani.org/xz/xz-${XZ_VERSION}.tar.gz 56 | tar xzf xz-${XZ_VERSION}.tar.gz 57 | fi 58 | cd xz-${XZ_VERSION} 59 | if [ ! -f Makefile ]; then 60 | ./configure --prefix=/usr >/dev/null 2>&1 61 | fi 62 | make -j2 >/dev/null 2>&1 63 | sudo make install >/dev/null 2>&1 64 | cd .. 65 | 66 | echo "build ncurses" 67 | date -u 68 | if [ ! -d ncurses-${NCURSES_VERSION} ]; then 69 | curl -L -O ftp://ftp.invisible-island.net/ncurses/ncurses-${NCURSES_VERSION}.tar.gz 70 | tar xzf ncurses-${NCURSES_VERSION}.tar.gz 71 | fi 72 | cd ncurses-${NCURSES_VERSION} 73 | if [ ! -f Makefile ]; then 74 | ./configure --prefix=/usr --with-termlib >/dev/null 2>&1 75 | fi 76 | make -j2 >/dev/null 2>&1 77 | sudo make install >/dev/null 2>&1 78 | cd .. 79 | 80 | echo "build libxml2" 81 | date -u 82 | if [ ! -d libxml2 ]; then 83 | git clone https://gitlab.gnome.org/GNOME/libxml2 84 | fi 85 | cd libxml2 86 | git checkout ${LIBXML2_SHA} 87 | if [ ! -f Makefile ]; then 88 | autoreconf -fvi >/dev/null 2>&1 89 | ./configure --prefix=/usr --without-python >/dev/null 2>&1 90 | fi 91 | make -j2 >/dev/null 2>&1 92 | sudo make install >/dev/null 2>&1 93 | cd .. 94 | 95 | echo "build elfutils" 96 | date -u 97 | if [ ! -d elfutils-${ELFUTILS_VERSION} ]; then 98 | curl -L -O ftp://sourceware.org/pub/elfutils/0.180/elfutils-${ELFUTILS_VERSION}.tar.bz2 99 | tar xjf elfutils-${ELFUTILS_VERSION}.tar.bz2 100 | fi 101 | cd elfutils-${ELFUTILS_VERSION} 102 | if [ ! -f Makefile ]; then 103 | ./configure --prefix=/usr --disable-debuginfod >/dev/null 2>&1 104 | fi 105 | make -j2 >/dev/null 2>&1 106 | sudo make install >/dev/null 2>&1 107 | cd .. 108 | fi 109 | 110 | ## build/install BCC 111 | echo "build bcc" 112 | date -u 113 | git clone https://github.com/iovisor/bcc || true 114 | cd bcc 115 | git checkout master 116 | git pull 117 | if [[ "${BCC}" == "0.4.0" ]]; then 118 | git checkout remotes/origin/tag_v0.4.0 119 | elif [[ "${BCC}" == "0.5.0" ]]; then 120 | git checkout remotes/origin/tag_v0.5.0 121 | elif [[ "${BCC}" == "0.6.0" ]]; then 122 | git checkout remotes/origin/tag_v0.6.0 123 | elif [[ "${BCC}" == "0.6.1" ]]; then 124 | git checkout remotes/origin/tag_v0.6.1 125 | elif [[ "${BCC}" == "0.7.0" ]]; then 126 | git checkout remotes/origin/tag_v0.7.0 127 | elif [[ "${BCC}" == "0.8.0" ]]; then 128 | git checkout remotes/origin/tag_v0.8.0 129 | elif [[ "${BCC}" == "0.9.0" ]]; then 130 | git checkout remotes/origin/tag_v0.9.0 131 | elif [[ "${BCC}" == "0.10.0" ]]; then 132 | git checkout remotes/origin/tag_v0.10.0 133 | elif [[ "${BCC}" == "0.11.0" ]]; then 134 | git checkout 0fa419a64e71984d42f107c210d3d3f0cc82d59a 135 | elif [[ "${BCC}" == "0.12.0" ]]; then 136 | git checkout 368a5b0714961953f3e3f61607fa16cb71449c1b 137 | elif [[ "${BCC}" == "0.13.0" ]]; then 138 | git checkout 942227484d3207f6a42103674001ef01fb5335a0 139 | elif [[ "${BCC}" == "0.14.0" ]]; then 140 | git checkout ceb458d6a07a42d8d6d3c16a3b8e387b5131d610 141 | elif [[ "${BCC}" == "0.15.0" ]]; then 142 | git checkout e41f7a3be5c8114ef6a0990e50c2fbabea0e928e 143 | elif [[ "${BCC}" == "0.16.0" ]]; then 144 | git checkout fecd934a9c0ff581890d218ff6c5101694e9b326 145 | elif [[ "${BCC}" == "0.17.0" ]]; then 146 | git checkout ad5b82a5196b222ed2cdc738d8444e8c9546a77f 147 | elif [[ "${BCC}" == "0.18.0" ]]; then 148 | git checkout b1ab869032611d9fcdaea56851cd6126cca2eba8 149 | elif [[ "${BCC}" == "0.19.0" ]]; then 150 | git checkout 4c561d037e2798563c2e87edcc5a406b020a458c 151 | elif [[ "${BCC}" == "0.20.0" ]]; then 152 | git checkout 14278bf1a52dd76ff66eed02cc9db7c7ec240da6 153 | elif [[ "${BCC}" == "0.21.0" ]]; then 154 | git checkout 321c9c979889abce48d0844b3d539ec9a01e6f3c 155 | elif [[ "${BCC}" == "0.22.0" ]]; then 156 | git checkout 44fc17fc8ca0a53f37e82aa82a6a000ec28384c4 157 | elif [[ "${BCC}" == "0.23.0" ]]; then 158 | git checkout 67f59ee80fcf5deedaacba1436d9fa09d32a16a0 159 | else 160 | echo "unsupported bcc version: ${BCC}" 161 | exit 1 162 | fi 163 | mkdir -p _build 164 | cd _build 165 | if [ ! -f Makefile ]; then 166 | cmake .. -DCMAKE_INSTALL_PREFIX=/usr >/dev/null 2>&1 167 | fi 168 | make -j2 >/dev/null 2>&1 169 | sudo make install >/dev/null 2>&1 170 | find . -name "*.a" -exec sudo cp -v {} /usr/lib/ \; 171 | cd ../.. 172 | 173 | echo "prerequisite build complete" 174 | date -u 175 | 176 | ## Build and test 177 | if [ -n "${FEATURES}" ]; then 178 | if [[ $STATIC != true ]]; then 179 | cargo build --release --features "${FEATURES}" 180 | cargo test --release --features "${FEATURES}" 181 | else 182 | export RUSTFLAGS="-L /usr/lib -L /usr/lib64 -L /usr/lib/llvm-${LLVM}/lib" 183 | fi 184 | cargo run --release --features "${FEATURES}" --example smoketest 185 | else 186 | if [[ $STATIC != true ]]; then 187 | cargo build --release 188 | cargo test --release 189 | else 190 | export RUSTFLAGS="-L /usr/lib -L /usr/lib64 -L /usr/lib/llvm-${LLVM}/lib" 191 | fi 192 | cargo run --release --example smoketest 193 | fi 194 | -------------------------------------------------------------------------------- /build/ubuntu_gen_bindings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Generates BCC bindings when used on Ubuntu. 4 | # 5 | # Usage: ubuntu_gen_bindings.sh 6 | # 7 | # The `version` should be the Git tag for the given version, as it's also used for the feature flag 8 | # that gets passed to Cargo, etc. For example, `v0.6.1` is transformed into `v0_6_1` when required 9 | # to generate the binding filename, etc. 10 | # 11 | # CAVEATS: 12 | # - must be run from the root of the repository 13 | # - written against Ubuntu 20.04 LTS 14 | # - uses LLVM 7 by default, which can be tweaked below 15 | # - forcefully tries to remove BCC libraries/headers (won't play nice with system-managed BCC) 16 | 17 | LLVM="7" 18 | VERSION=$1 19 | VERSION_SAFE=$(echo "$VERSION" | tr . _) 20 | 21 | # Install some pre-requisites. 22 | sudo apt-get install linux-headers-"$(uname -r)" 23 | sudo apt-get remove *llvm* *clang* *gtk* 24 | sudo apt-get --yes install clang-"${LLVM}" libclang-"${LLVM}"-dev libelf-dev \ 25 | libfl-dev llvm-"${LLVM}"-dev libz-dev llvm-"${LLVM}" cmake flex bison build-essential 26 | 27 | # Clone/update to the correct version of BCC, including the libbpf submodule. 28 | test -d bcc || git clone https://github.com/iovisor/bcc 29 | pushd bcc && git checkout $VERSION && git submodule update 30 | 31 | # Remove any installed versions of BCC. 32 | sudo rm -rf /usr/include/bcc /usr/share/bcc \ 33 | /usr/lib/python3/dist-packages/bcc \ 34 | /usr/lib/python3/dist-packages/bcc* \ 35 | /usr/lib/libbcc* \ 36 | /usr/lib/x86_64-linux-gnu/libbcc* \ 37 | /usr/lib/x86_64-linux-gnu/pkgconfig/libbcc.pc 38 | 39 | # Build BCC. 40 | sudo rm -rf _build; mkdir _build; pushd _build 41 | cmake .. -DCMAKE_INSTALL_PREFIX=/usr 42 | make -j24 43 | sudo make install 44 | popd 45 | 46 | # Now generate the bindings, move them into place, and make sure tests pass. 47 | popd 48 | cargo build --features generate,${VERSION_SAFE} && mv src/generated.rs src/bccapi/${VERSION_SAFE}.rs 49 | cargo test --features $VERSION_SAFE -------------------------------------------------------------------------------- /examples/smoketest.rs: -------------------------------------------------------------------------------- 1 | use bcc_sys::bccapi::*; 2 | use std::ffi::CString; 3 | use std::ptr; 4 | 5 | fn main() { 6 | #[cfg(any( 7 | feature = "v0_4_0", 8 | feature = "v0_5_0", 9 | feature = "v0_6_0", 10 | feature = "v0_6_1", 11 | feature = "v0_7_0", 12 | feature = "v0_8_0", 13 | ))] 14 | { 15 | let cs = CString::new("".to_string()).unwrap(); 16 | let ptr = unsafe { bpf_module_create_c_from_string(cs.as_ptr(), 2, ptr::null_mut(), 0) }; 17 | assert!(!ptr.is_null()); 18 | } 19 | 20 | #[cfg(any(feature = "v0_9_0", feature = "v0_10_0",))] 21 | { 22 | let cs = CString::new("".to_string()).unwrap(); 23 | let ptr = 24 | unsafe { bpf_module_create_c_from_string(cs.as_ptr(), 2, ptr::null_mut(), 0, true) }; 25 | assert!(!ptr.is_null()); 26 | } 27 | 28 | #[cfg(any( 29 | feature = "v0_11_0", 30 | feature = "v0_12_0", 31 | feature = "v0_13_0", 32 | feature = "v0_14_0", 33 | feature = "v0_15_0", 34 | feature = "v0_16_0", 35 | feature = "v0_17_0", 36 | feature = "v0_18_0", 37 | feature = "v0_19_0", 38 | feature = "v0_20_0", 39 | feature = "v0_21_0", 40 | feature = "v0_22_0", 41 | feature = "v0_23_0", 42 | not(feature = "specific"), 43 | ))] 44 | { 45 | let cs = CString::new("".to_string()).unwrap(); 46 | let ptr = unsafe { 47 | bpf_module_create_c_from_string( 48 | cs.as_ptr(), 49 | 2, 50 | ptr::null_mut(), 51 | 0, 52 | true, 53 | ptr::null_mut(), 54 | ) 55 | }; 56 | assert!(!ptr.is_null()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/bccapi/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "v0_4_0")] 2 | mod v0_4_0; 3 | 4 | #[cfg(feature = "v0_5_0")] 5 | mod v0_5_0; 6 | 7 | #[cfg(feature = "v0_6_0")] 8 | mod v0_6_0; 9 | 10 | #[cfg(feature = "v0_6_1")] 11 | mod v0_6_1; 12 | 13 | #[cfg(feature = "v0_7_0")] 14 | mod v0_7_0; 15 | 16 | #[cfg(feature = "v0_8_0")] 17 | mod v0_8_0; 18 | 19 | #[cfg(feature = "v0_9_0")] 20 | mod v0_9_0; 21 | 22 | #[cfg(feature = "v0_10_0")] 23 | mod v0_10_0; 24 | 25 | #[cfg(feature = "v0_11_0")] 26 | mod v0_11_0; 27 | 28 | #[cfg(feature = "v0_12_0")] 29 | mod v0_12_0; 30 | 31 | #[cfg(feature = "v0_13_0")] 32 | mod v0_13_0; 33 | 34 | #[cfg(feature = "v0_14_0")] 35 | mod v0_14_0; 36 | 37 | #[cfg(feature = "v0_15_0")] 38 | mod v0_15_0; 39 | 40 | #[cfg(feature = "v0_16_0")] 41 | mod v0_16_0; 42 | 43 | #[cfg(feature = "v0_17_0")] 44 | mod v0_17_0; 45 | 46 | #[cfg(feature = "v0_18_0")] 47 | mod v0_18_0; 48 | 49 | #[cfg(feature = "v0_19_0")] 50 | mod v0_19_0; 51 | 52 | #[cfg(feature = "v0_20_0")] 53 | mod v0_20_0; 54 | 55 | #[cfg(feature = "v0_21_0")] 56 | mod v0_21_0; 57 | 58 | #[cfg(feature = "v0_22_0")] 59 | mod v0_22_0; 60 | 61 | #[cfg(feature = "v0_23_0")] 62 | mod v0_23_0; 63 | 64 | // without a specified version, use latest version supported 65 | #[cfg(not(feature = "specific"))] 66 | mod v0_23_0; 67 | 68 | #[cfg(feature = "v0_4_0")] 69 | pub use v0_4_0::*; 70 | 71 | #[cfg(feature = "v0_5_0")] 72 | pub use v0_5_0::*; 73 | 74 | #[cfg(feature = "v0_6_0")] 75 | pub use v0_6_0::*; 76 | 77 | #[cfg(feature = "v0_6_1")] 78 | pub use v0_6_1::*; 79 | 80 | #[cfg(feature = "v0_7_0")] 81 | pub use v0_7_0::*; 82 | 83 | #[cfg(feature = "v0_8_0")] 84 | pub use v0_8_0::*; 85 | 86 | #[cfg(feature = "v0_9_0")] 87 | pub use v0_9_0::*; 88 | 89 | #[cfg(feature = "v0_10_0")] 90 | pub use v0_10_0::*; 91 | 92 | #[cfg(feature = "v0_11_0")] 93 | pub use v0_11_0::*; 94 | 95 | #[cfg(feature = "v0_12_0")] 96 | pub use v0_12_0::*; 97 | 98 | #[cfg(feature = "v0_13_0")] 99 | pub use v0_13_0::*; 100 | 101 | #[cfg(feature = "v0_14_0")] 102 | pub use v0_14_0::*; 103 | 104 | #[cfg(feature = "v0_15_0")] 105 | pub use v0_15_0::*; 106 | 107 | #[cfg(feature = "v0_16_0")] 108 | pub use v0_16_0::*; 109 | 110 | #[cfg(feature = "v0_17_0")] 111 | pub use v0_17_0::*; 112 | 113 | #[cfg(feature = "v0_18_0")] 114 | pub use v0_18_0::*; 115 | 116 | #[cfg(feature = "v0_19_0")] 117 | pub use v0_19_0::*; 118 | 119 | #[cfg(feature = "v0_20_0")] 120 | pub use v0_20_0::*; 121 | 122 | #[cfg(feature = "v0_21_0")] 123 | pub use v0_21_0::*; 124 | 125 | #[cfg(feature = "v0_22_0")] 126 | pub use v0_22_0::*; 127 | 128 | #[cfg(feature = "v0_23_0")] 129 | pub use v0_23_0::*; 130 | 131 | // without a specified version, use latest version supported 132 | #[cfg(not(feature = "specific"))] 133 | pub use v0_23_0::*; 134 | -------------------------------------------------------------------------------- /src/bccapi/v0_4_0.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen */ 2 | 3 | #[repr(C)] 4 | #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] 5 | pub struct __BindgenBitfieldUnit 6 | where 7 | Storage: AsRef<[u8]> + AsMut<[u8]>, 8 | { 9 | storage: Storage, 10 | align: [Align; 0], 11 | } 12 | impl __BindgenBitfieldUnit 13 | where 14 | Storage: AsRef<[u8]> + AsMut<[u8]>, 15 | { 16 | #[inline] 17 | pub fn new(storage: Storage) -> Self { 18 | Self { storage, align: [] } 19 | } 20 | #[inline] 21 | pub fn get_bit(&self, index: usize) -> bool { 22 | debug_assert!(index / 8 < self.storage.as_ref().len()); 23 | let byte_index = index / 8; 24 | let byte = self.storage.as_ref()[byte_index]; 25 | let bit_index = if cfg!(target_endian = "big") { 26 | 7 - (index % 8) 27 | } else { 28 | index % 8 29 | }; 30 | let mask = 1 << bit_index; 31 | byte & mask == mask 32 | } 33 | #[inline] 34 | pub fn set_bit(&mut self, index: usize, val: bool) { 35 | debug_assert!(index / 8 < self.storage.as_ref().len()); 36 | let byte_index = index / 8; 37 | let byte = &mut self.storage.as_mut()[byte_index]; 38 | let bit_index = if cfg!(target_endian = "big") { 39 | 7 - (index % 8) 40 | } else { 41 | index % 8 42 | }; 43 | let mask = 1 << bit_index; 44 | if val { 45 | *byte |= mask; 46 | } else { 47 | *byte &= !mask; 48 | } 49 | } 50 | #[inline] 51 | pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { 52 | debug_assert!(bit_width <= 64); 53 | debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); 54 | debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); 55 | let mut val = 0; 56 | for i in 0..(bit_width as usize) { 57 | if self.get_bit(i + bit_offset) { 58 | let index = if cfg!(target_endian = "big") { 59 | bit_width as usize - 1 - i 60 | } else { 61 | i 62 | }; 63 | val |= 1 << index; 64 | } 65 | } 66 | val 67 | } 68 | #[inline] 69 | pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { 70 | debug_assert!(bit_width <= 64); 71 | debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); 72 | debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); 73 | for i in 0..(bit_width as usize) { 74 | let mask = 1 << i; 75 | let val_bit_is_set = val & mask == mask; 76 | let index = if cfg!(target_endian = "big") { 77 | bit_width as usize - 1 - i 78 | } else { 79 | i 80 | }; 81 | self.set_bit(index + bit_offset, val_bit_is_set); 82 | } 83 | } 84 | } 85 | #[repr(C)] 86 | #[derive(Default)] 87 | pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); 88 | impl __IncompleteArrayField { 89 | #[inline] 90 | pub fn new() -> Self { 91 | __IncompleteArrayField(::std::marker::PhantomData, []) 92 | } 93 | #[inline] 94 | pub unsafe fn as_ptr(&self) -> *const T { 95 | ::std::mem::transmute(self) 96 | } 97 | #[inline] 98 | pub unsafe fn as_mut_ptr(&mut self) -> *mut T { 99 | ::std::mem::transmute(self) 100 | } 101 | #[inline] 102 | pub unsafe fn as_slice(&self, len: usize) -> &[T] { 103 | ::std::slice::from_raw_parts(self.as_ptr(), len) 104 | } 105 | #[inline] 106 | pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { 107 | ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) 108 | } 109 | } 110 | impl ::std::fmt::Debug for __IncompleteArrayField { 111 | fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 112 | fmt.write_str("__IncompleteArrayField") 113 | } 114 | } 115 | impl ::std::clone::Clone for __IncompleteArrayField { 116 | #[inline] 117 | fn clone(&self) -> Self { 118 | Self::new() 119 | } 120 | } 121 | pub const BPF_LD: u32 = 0; 122 | pub const BPF_LDX: u32 = 1; 123 | pub const BPF_ST: u32 = 2; 124 | pub const BPF_STX: u32 = 3; 125 | pub const BPF_ALU: u32 = 4; 126 | pub const BPF_JMP: u32 = 5; 127 | pub const BPF_RET: u32 = 6; 128 | pub const BPF_MISC: u32 = 7; 129 | pub const BPF_W: u32 = 0; 130 | pub const BPF_H: u32 = 8; 131 | pub const BPF_B: u32 = 16; 132 | pub const BPF_IMM: u32 = 0; 133 | pub const BPF_ABS: u32 = 32; 134 | pub const BPF_IND: u32 = 64; 135 | pub const BPF_MEM: u32 = 96; 136 | pub const BPF_LEN: u32 = 128; 137 | pub const BPF_MSH: u32 = 160; 138 | pub const BPF_ADD: u32 = 0; 139 | pub const BPF_SUB: u32 = 16; 140 | pub const BPF_MUL: u32 = 32; 141 | pub const BPF_DIV: u32 = 48; 142 | pub const BPF_OR: u32 = 64; 143 | pub const BPF_AND: u32 = 80; 144 | pub const BPF_LSH: u32 = 96; 145 | pub const BPF_RSH: u32 = 112; 146 | pub const BPF_NEG: u32 = 128; 147 | pub const BPF_MOD: u32 = 144; 148 | pub const BPF_XOR: u32 = 160; 149 | pub const BPF_JA: u32 = 0; 150 | pub const BPF_JEQ: u32 = 16; 151 | pub const BPF_JGT: u32 = 32; 152 | pub const BPF_JGE: u32 = 48; 153 | pub const BPF_JSET: u32 = 64; 154 | pub const BPF_K: u32 = 0; 155 | pub const BPF_X: u32 = 8; 156 | pub const BPF_MAXINSNS: u32 = 4096; 157 | pub const BPF_ALU64: u32 = 7; 158 | pub const BPF_DW: u32 = 24; 159 | pub const BPF_XADD: u32 = 192; 160 | pub const BPF_MOV: u32 = 176; 161 | pub const BPF_ARSH: u32 = 192; 162 | pub const BPF_END: u32 = 208; 163 | pub const BPF_TO_LE: u32 = 0; 164 | pub const BPF_TO_BE: u32 = 8; 165 | pub const BPF_FROM_LE: u32 = 0; 166 | pub const BPF_FROM_BE: u32 = 8; 167 | pub const BPF_JNE: u32 = 80; 168 | pub const BPF_JLT: u32 = 160; 169 | pub const BPF_JLE: u32 = 176; 170 | pub const BPF_JSGT: u32 = 96; 171 | pub const BPF_JSGE: u32 = 112; 172 | pub const BPF_JSLT: u32 = 192; 173 | pub const BPF_JSLE: u32 = 208; 174 | pub const BPF_CALL: u32 = 128; 175 | pub const BPF_EXIT: u32 = 144; 176 | pub const BPF_F_ALLOW_OVERRIDE: u32 = 1; 177 | pub const BPF_F_ALLOW_MULTI: u32 = 2; 178 | pub const BPF_F_STRICT_ALIGNMENT: u32 = 1; 179 | pub const BPF_PSEUDO_MAP_FD: u32 = 1; 180 | pub const BPF_ANY: u32 = 0; 181 | pub const BPF_NOEXIST: u32 = 1; 182 | pub const BPF_EXIST: u32 = 2; 183 | pub const BPF_F_NO_PREALLOC: u32 = 1; 184 | pub const BPF_F_NO_COMMON_LRU: u32 = 2; 185 | pub const BPF_F_NUMA_NODE: u32 = 4; 186 | pub const BPF_F_QUERY_EFFECTIVE: u32 = 1; 187 | pub const BPF_OBJ_NAME_LEN: u32 = 16; 188 | pub const BPF_F_RECOMPUTE_CSUM: u32 = 1; 189 | pub const BPF_F_INVALIDATE_HASH: u32 = 2; 190 | pub const BPF_F_HDR_FIELD_MASK: u32 = 15; 191 | pub const BPF_F_PSEUDO_HDR: u32 = 16; 192 | pub const BPF_F_MARK_MANGLED_0: u32 = 32; 193 | pub const BPF_F_MARK_ENFORCE: u32 = 64; 194 | pub const BPF_F_INGRESS: u32 = 1; 195 | pub const BPF_F_TUNINFO_IPV6: u32 = 1; 196 | pub const BPF_F_SKIP_FIELD_MASK: u32 = 255; 197 | pub const BPF_F_USER_STACK: u32 = 256; 198 | pub const BPF_F_FAST_STACK_CMP: u32 = 512; 199 | pub const BPF_F_REUSE_STACKID: u32 = 1024; 200 | pub const BPF_F_ZERO_CSUM_TX: u32 = 2; 201 | pub const BPF_F_DONT_FRAGMENT: u32 = 4; 202 | pub const BPF_F_INDEX_MASK: u32 = 4294967295; 203 | pub const BPF_F_CURRENT_CPU: u32 = 4294967295; 204 | pub const BPF_F_CTXLEN_MASK: u64 = 4503595332403200; 205 | pub const XDP_PACKET_HEADROOM: u32 = 256; 206 | pub const BPF_TAG_SIZE: u32 = 8; 207 | pub const TCP_BPF_IW: u32 = 1001; 208 | pub const TCP_BPF_SNDCWND_CLAMP: u32 = 1002; 209 | pub const LOG_BUF_SIZE: u32 = 65536; 210 | pub const BPF_FN_PREFIX: &'static [u8; 9usize] = b".bpf.fn.\0"; 211 | pub const STT_GNU_IFUNC: u32 = 10; 212 | pub type __pid_t = ::std::os::raw::c_int; 213 | pub type pid_t = __pid_t; 214 | extern "C" { 215 | pub fn bpf_module_create_b( 216 | filename: *const ::std::os::raw::c_char, 217 | proto_filename: *const ::std::os::raw::c_char, 218 | flags: ::std::os::raw::c_uint, 219 | ) -> *mut ::std::os::raw::c_void; 220 | } 221 | extern "C" { 222 | pub fn bpf_module_create_c( 223 | filename: *const ::std::os::raw::c_char, 224 | flags: ::std::os::raw::c_uint, 225 | cflags: *mut *const ::std::os::raw::c_char, 226 | ncflags: ::std::os::raw::c_int, 227 | ) -> *mut ::std::os::raw::c_void; 228 | } 229 | extern "C" { 230 | pub fn bpf_module_create_c_from_string( 231 | text: *const ::std::os::raw::c_char, 232 | flags: ::std::os::raw::c_uint, 233 | cflags: *mut *const ::std::os::raw::c_char, 234 | ncflags: ::std::os::raw::c_int, 235 | ) -> *mut ::std::os::raw::c_void; 236 | } 237 | extern "C" { 238 | pub fn bpf_module_destroy(program: *mut ::std::os::raw::c_void); 239 | } 240 | extern "C" { 241 | pub fn bpf_module_license(program: *mut ::std::os::raw::c_void) -> *mut ::std::os::raw::c_char; 242 | } 243 | extern "C" { 244 | pub fn bpf_module_kern_version(program: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_uint; 245 | } 246 | extern "C" { 247 | pub fn bpf_num_functions(program: *mut ::std::os::raw::c_void) -> usize; 248 | } 249 | extern "C" { 250 | pub fn bpf_function_name( 251 | program: *mut ::std::os::raw::c_void, 252 | id: usize, 253 | ) -> *const ::std::os::raw::c_char; 254 | } 255 | extern "C" { 256 | pub fn bpf_function_start_id( 257 | program: *mut ::std::os::raw::c_void, 258 | id: usize, 259 | ) -> *mut ::std::os::raw::c_void; 260 | } 261 | extern "C" { 262 | pub fn bpf_function_start( 263 | program: *mut ::std::os::raw::c_void, 264 | name: *const ::std::os::raw::c_char, 265 | ) -> *mut ::std::os::raw::c_void; 266 | } 267 | extern "C" { 268 | pub fn bpf_function_size_id(program: *mut ::std::os::raw::c_void, id: usize) -> usize; 269 | } 270 | extern "C" { 271 | pub fn bpf_function_size( 272 | program: *mut ::std::os::raw::c_void, 273 | name: *const ::std::os::raw::c_char, 274 | ) -> usize; 275 | } 276 | extern "C" { 277 | pub fn bpf_num_tables(program: *mut ::std::os::raw::c_void) -> usize; 278 | } 279 | extern "C" { 280 | pub fn bpf_table_id( 281 | program: *mut ::std::os::raw::c_void, 282 | table_name: *const ::std::os::raw::c_char, 283 | ) -> usize; 284 | } 285 | extern "C" { 286 | pub fn bpf_table_fd( 287 | program: *mut ::std::os::raw::c_void, 288 | table_name: *const ::std::os::raw::c_char, 289 | ) -> ::std::os::raw::c_int; 290 | } 291 | extern "C" { 292 | pub fn bpf_table_fd_id( 293 | program: *mut ::std::os::raw::c_void, 294 | id: usize, 295 | ) -> ::std::os::raw::c_int; 296 | } 297 | extern "C" { 298 | pub fn bpf_table_type( 299 | program: *mut ::std::os::raw::c_void, 300 | table_name: *const ::std::os::raw::c_char, 301 | ) -> ::std::os::raw::c_int; 302 | } 303 | extern "C" { 304 | pub fn bpf_table_type_id( 305 | program: *mut ::std::os::raw::c_void, 306 | id: usize, 307 | ) -> ::std::os::raw::c_int; 308 | } 309 | extern "C" { 310 | pub fn bpf_table_max_entries( 311 | program: *mut ::std::os::raw::c_void, 312 | table_name: *const ::std::os::raw::c_char, 313 | ) -> usize; 314 | } 315 | extern "C" { 316 | pub fn bpf_table_max_entries_id(program: *mut ::std::os::raw::c_void, id: usize) -> usize; 317 | } 318 | extern "C" { 319 | pub fn bpf_table_flags( 320 | program: *mut ::std::os::raw::c_void, 321 | table_name: *const ::std::os::raw::c_char, 322 | ) -> ::std::os::raw::c_int; 323 | } 324 | extern "C" { 325 | pub fn bpf_table_flags_id( 326 | program: *mut ::std::os::raw::c_void, 327 | id: usize, 328 | ) -> ::std::os::raw::c_int; 329 | } 330 | extern "C" { 331 | pub fn bpf_table_name( 332 | program: *mut ::std::os::raw::c_void, 333 | id: usize, 334 | ) -> *const ::std::os::raw::c_char; 335 | } 336 | extern "C" { 337 | pub fn bpf_table_key_desc( 338 | program: *mut ::std::os::raw::c_void, 339 | table_name: *const ::std::os::raw::c_char, 340 | ) -> *const ::std::os::raw::c_char; 341 | } 342 | extern "C" { 343 | pub fn bpf_table_key_desc_id( 344 | program: *mut ::std::os::raw::c_void, 345 | id: usize, 346 | ) -> *const ::std::os::raw::c_char; 347 | } 348 | extern "C" { 349 | pub fn bpf_table_leaf_desc( 350 | program: *mut ::std::os::raw::c_void, 351 | table_name: *const ::std::os::raw::c_char, 352 | ) -> *const ::std::os::raw::c_char; 353 | } 354 | extern "C" { 355 | pub fn bpf_table_leaf_desc_id( 356 | program: *mut ::std::os::raw::c_void, 357 | id: usize, 358 | ) -> *const ::std::os::raw::c_char; 359 | } 360 | extern "C" { 361 | pub fn bpf_table_key_size( 362 | program: *mut ::std::os::raw::c_void, 363 | table_name: *const ::std::os::raw::c_char, 364 | ) -> usize; 365 | } 366 | extern "C" { 367 | pub fn bpf_table_key_size_id(program: *mut ::std::os::raw::c_void, id: usize) -> usize; 368 | } 369 | extern "C" { 370 | pub fn bpf_table_leaf_size( 371 | program: *mut ::std::os::raw::c_void, 372 | table_name: *const ::std::os::raw::c_char, 373 | ) -> usize; 374 | } 375 | extern "C" { 376 | pub fn bpf_table_leaf_size_id(program: *mut ::std::os::raw::c_void, id: usize) -> usize; 377 | } 378 | extern "C" { 379 | pub fn bpf_table_key_snprintf( 380 | program: *mut ::std::os::raw::c_void, 381 | id: usize, 382 | buf: *mut ::std::os::raw::c_char, 383 | buflen: usize, 384 | key: *const ::std::os::raw::c_void, 385 | ) -> ::std::os::raw::c_int; 386 | } 387 | extern "C" { 388 | pub fn bpf_table_leaf_snprintf( 389 | program: *mut ::std::os::raw::c_void, 390 | id: usize, 391 | buf: *mut ::std::os::raw::c_char, 392 | buflen: usize, 393 | leaf: *const ::std::os::raw::c_void, 394 | ) -> ::std::os::raw::c_int; 395 | } 396 | extern "C" { 397 | pub fn bpf_table_key_sscanf( 398 | program: *mut ::std::os::raw::c_void, 399 | id: usize, 400 | buf: *const ::std::os::raw::c_char, 401 | key: *mut ::std::os::raw::c_void, 402 | ) -> ::std::os::raw::c_int; 403 | } 404 | extern "C" { 405 | pub fn bpf_table_leaf_sscanf( 406 | program: *mut ::std::os::raw::c_void, 407 | id: usize, 408 | buf: *const ::std::os::raw::c_char, 409 | leaf: *mut ::std::os::raw::c_void, 410 | ) -> ::std::os::raw::c_int; 411 | } 412 | pub type __u8 = ::std::os::raw::c_uchar; 413 | pub type __s16 = ::std::os::raw::c_short; 414 | pub type __u16 = ::std::os::raw::c_ushort; 415 | pub type __s32 = ::std::os::raw::c_int; 416 | pub type __u32 = ::std::os::raw::c_uint; 417 | pub type __u64 = ::std::os::raw::c_ulonglong; 418 | pub const BPF_REG_0: _bindgen_ty_1 = 0; 419 | pub const BPF_REG_1: _bindgen_ty_1 = 1; 420 | pub const BPF_REG_2: _bindgen_ty_1 = 2; 421 | pub const BPF_REG_3: _bindgen_ty_1 = 3; 422 | pub const BPF_REG_4: _bindgen_ty_1 = 4; 423 | pub const BPF_REG_5: _bindgen_ty_1 = 5; 424 | pub const BPF_REG_6: _bindgen_ty_1 = 6; 425 | pub const BPF_REG_7: _bindgen_ty_1 = 7; 426 | pub const BPF_REG_8: _bindgen_ty_1 = 8; 427 | pub const BPF_REG_9: _bindgen_ty_1 = 9; 428 | pub const BPF_REG_10: _bindgen_ty_1 = 10; 429 | pub const __MAX_BPF_REG: _bindgen_ty_1 = 11; 430 | pub type _bindgen_ty_1 = u32; 431 | #[repr(C)] 432 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 433 | pub struct bpf_insn { 434 | pub code: __u8, 435 | pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, 436 | pub off: __s16, 437 | pub imm: __s32, 438 | } 439 | #[test] 440 | fn bindgen_test_layout_bpf_insn() { 441 | assert_eq!( 442 | ::std::mem::size_of::(), 443 | 8usize, 444 | concat!("Size of: ", stringify!(bpf_insn)) 445 | ); 446 | assert_eq!( 447 | ::std::mem::align_of::(), 448 | 4usize, 449 | concat!("Alignment of ", stringify!(bpf_insn)) 450 | ); 451 | assert_eq!( 452 | unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, 453 | 0usize, 454 | concat!( 455 | "Offset of field: ", 456 | stringify!(bpf_insn), 457 | "::", 458 | stringify!(code) 459 | ) 460 | ); 461 | assert_eq!( 462 | unsafe { &(*(::std::ptr::null::())).off as *const _ as usize }, 463 | 2usize, 464 | concat!( 465 | "Offset of field: ", 466 | stringify!(bpf_insn), 467 | "::", 468 | stringify!(off) 469 | ) 470 | ); 471 | assert_eq!( 472 | unsafe { &(*(::std::ptr::null::())).imm as *const _ as usize }, 473 | 4usize, 474 | concat!( 475 | "Offset of field: ", 476 | stringify!(bpf_insn), 477 | "::", 478 | stringify!(imm) 479 | ) 480 | ); 481 | } 482 | impl bpf_insn { 483 | #[inline] 484 | pub fn dst_reg(&self) -> __u8 { 485 | unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } 486 | } 487 | #[inline] 488 | pub fn set_dst_reg(&mut self, val: __u8) { 489 | unsafe { 490 | let val: u8 = ::std::mem::transmute(val); 491 | self._bitfield_1.set(0usize, 4u8, val as u64) 492 | } 493 | } 494 | #[inline] 495 | pub fn src_reg(&self) -> __u8 { 496 | unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } 497 | } 498 | #[inline] 499 | pub fn set_src_reg(&mut self, val: __u8) { 500 | unsafe { 501 | let val: u8 = ::std::mem::transmute(val); 502 | self._bitfield_1.set(4usize, 4u8, val as u64) 503 | } 504 | } 505 | #[inline] 506 | pub fn new_bitfield_1(dst_reg: __u8, src_reg: __u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { 507 | let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = 508 | Default::default(); 509 | __bindgen_bitfield_unit.set(0usize, 4u8, { 510 | let dst_reg: u8 = unsafe { ::std::mem::transmute(dst_reg) }; 511 | dst_reg as u64 512 | }); 513 | __bindgen_bitfield_unit.set(4usize, 4u8, { 514 | let src_reg: u8 = unsafe { ::std::mem::transmute(src_reg) }; 515 | src_reg as u64 516 | }); 517 | __bindgen_bitfield_unit 518 | } 519 | } 520 | #[repr(C)] 521 | #[derive(Debug, Default)] 522 | pub struct bpf_lpm_trie_key { 523 | pub prefixlen: __u32, 524 | pub data: __IncompleteArrayField<__u8>, 525 | } 526 | #[test] 527 | fn bindgen_test_layout_bpf_lpm_trie_key() { 528 | assert_eq!( 529 | ::std::mem::size_of::(), 530 | 4usize, 531 | concat!("Size of: ", stringify!(bpf_lpm_trie_key)) 532 | ); 533 | assert_eq!( 534 | ::std::mem::align_of::(), 535 | 4usize, 536 | concat!("Alignment of ", stringify!(bpf_lpm_trie_key)) 537 | ); 538 | assert_eq!( 539 | unsafe { &(*(::std::ptr::null::())).prefixlen as *const _ as usize }, 540 | 0usize, 541 | concat!( 542 | "Offset of field: ", 543 | stringify!(bpf_lpm_trie_key), 544 | "::", 545 | stringify!(prefixlen) 546 | ) 547 | ); 548 | assert_eq!( 549 | unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, 550 | 4usize, 551 | concat!( 552 | "Offset of field: ", 553 | stringify!(bpf_lpm_trie_key), 554 | "::", 555 | stringify!(data) 556 | ) 557 | ); 558 | } 559 | pub const bpf_cmd_BPF_MAP_CREATE: bpf_cmd = 0; 560 | pub const bpf_cmd_BPF_MAP_LOOKUP_ELEM: bpf_cmd = 1; 561 | pub const bpf_cmd_BPF_MAP_UPDATE_ELEM: bpf_cmd = 2; 562 | pub const bpf_cmd_BPF_MAP_DELETE_ELEM: bpf_cmd = 3; 563 | pub const bpf_cmd_BPF_MAP_GET_NEXT_KEY: bpf_cmd = 4; 564 | pub const bpf_cmd_BPF_PROG_LOAD: bpf_cmd = 5; 565 | pub const bpf_cmd_BPF_OBJ_PIN: bpf_cmd = 6; 566 | pub const bpf_cmd_BPF_OBJ_GET: bpf_cmd = 7; 567 | pub const bpf_cmd_BPF_PROG_ATTACH: bpf_cmd = 8; 568 | pub const bpf_cmd_BPF_PROG_DETACH: bpf_cmd = 9; 569 | pub const bpf_cmd_BPF_PROG_TEST_RUN: bpf_cmd = 10; 570 | pub const bpf_cmd_BPF_PROG_GET_NEXT_ID: bpf_cmd = 11; 571 | pub const bpf_cmd_BPF_MAP_GET_NEXT_ID: bpf_cmd = 12; 572 | pub const bpf_cmd_BPF_PROG_GET_FD_BY_ID: bpf_cmd = 13; 573 | pub const bpf_cmd_BPF_MAP_GET_FD_BY_ID: bpf_cmd = 14; 574 | pub const bpf_cmd_BPF_OBJ_GET_INFO_BY_FD: bpf_cmd = 15; 575 | pub const bpf_cmd_BPF_PROG_QUERY: bpf_cmd = 16; 576 | pub type bpf_cmd = u32; 577 | pub const bpf_map_type_BPF_MAP_TYPE_UNSPEC: bpf_map_type = 0; 578 | pub const bpf_map_type_BPF_MAP_TYPE_HASH: bpf_map_type = 1; 579 | pub const bpf_map_type_BPF_MAP_TYPE_ARRAY: bpf_map_type = 2; 580 | pub const bpf_map_type_BPF_MAP_TYPE_PROG_ARRAY: bpf_map_type = 3; 581 | pub const bpf_map_type_BPF_MAP_TYPE_PERF_EVENT_ARRAY: bpf_map_type = 4; 582 | pub const bpf_map_type_BPF_MAP_TYPE_PERCPU_HASH: bpf_map_type = 5; 583 | pub const bpf_map_type_BPF_MAP_TYPE_PERCPU_ARRAY: bpf_map_type = 6; 584 | pub const bpf_map_type_BPF_MAP_TYPE_STACK_TRACE: bpf_map_type = 7; 585 | pub const bpf_map_type_BPF_MAP_TYPE_CGROUP_ARRAY: bpf_map_type = 8; 586 | pub const bpf_map_type_BPF_MAP_TYPE_LRU_HASH: bpf_map_type = 9; 587 | pub const bpf_map_type_BPF_MAP_TYPE_LRU_PERCPU_HASH: bpf_map_type = 10; 588 | pub const bpf_map_type_BPF_MAP_TYPE_LPM_TRIE: bpf_map_type = 11; 589 | pub const bpf_map_type_BPF_MAP_TYPE_ARRAY_OF_MAPS: bpf_map_type = 12; 590 | pub const bpf_map_type_BPF_MAP_TYPE_HASH_OF_MAPS: bpf_map_type = 13; 591 | pub const bpf_map_type_BPF_MAP_TYPE_DEVMAP: bpf_map_type = 14; 592 | pub const bpf_map_type_BPF_MAP_TYPE_SOCKMAP: bpf_map_type = 15; 593 | pub type bpf_map_type = u32; 594 | pub const bpf_prog_type_BPF_PROG_TYPE_UNSPEC: bpf_prog_type = 0; 595 | pub const bpf_prog_type_BPF_PROG_TYPE_SOCKET_FILTER: bpf_prog_type = 1; 596 | pub const bpf_prog_type_BPF_PROG_TYPE_KPROBE: bpf_prog_type = 2; 597 | pub const bpf_prog_type_BPF_PROG_TYPE_SCHED_CLS: bpf_prog_type = 3; 598 | pub const bpf_prog_type_BPF_PROG_TYPE_SCHED_ACT: bpf_prog_type = 4; 599 | pub const bpf_prog_type_BPF_PROG_TYPE_TRACEPOINT: bpf_prog_type = 5; 600 | pub const bpf_prog_type_BPF_PROG_TYPE_XDP: bpf_prog_type = 6; 601 | pub const bpf_prog_type_BPF_PROG_TYPE_PERF_EVENT: bpf_prog_type = 7; 602 | pub const bpf_prog_type_BPF_PROG_TYPE_CGROUP_SKB: bpf_prog_type = 8; 603 | pub const bpf_prog_type_BPF_PROG_TYPE_CGROUP_SOCK: bpf_prog_type = 9; 604 | pub const bpf_prog_type_BPF_PROG_TYPE_LWT_IN: bpf_prog_type = 10; 605 | pub const bpf_prog_type_BPF_PROG_TYPE_LWT_OUT: bpf_prog_type = 11; 606 | pub const bpf_prog_type_BPF_PROG_TYPE_LWT_XMIT: bpf_prog_type = 12; 607 | pub const bpf_prog_type_BPF_PROG_TYPE_SOCK_OPS: bpf_prog_type = 13; 608 | pub const bpf_prog_type_BPF_PROG_TYPE_SK_SKB: bpf_prog_type = 14; 609 | pub type bpf_prog_type = u32; 610 | pub const bpf_attach_type_BPF_CGROUP_INET_INGRESS: bpf_attach_type = 0; 611 | pub const bpf_attach_type_BPF_CGROUP_INET_EGRESS: bpf_attach_type = 1; 612 | pub const bpf_attach_type_BPF_CGROUP_INET_SOCK_CREATE: bpf_attach_type = 2; 613 | pub const bpf_attach_type_BPF_CGROUP_SOCK_OPS: bpf_attach_type = 3; 614 | pub const bpf_attach_type_BPF_SK_SKB_STREAM_PARSER: bpf_attach_type = 4; 615 | pub const bpf_attach_type_BPF_SK_SKB_STREAM_VERDICT: bpf_attach_type = 5; 616 | pub const bpf_attach_type___MAX_BPF_ATTACH_TYPE: bpf_attach_type = 6; 617 | pub type bpf_attach_type = u32; 618 | #[repr(C)] 619 | #[derive(Copy, Clone)] 620 | pub union bpf_attr { 621 | pub __bindgen_anon_1: bpf_attr__bindgen_ty_1, 622 | pub __bindgen_anon_2: bpf_attr__bindgen_ty_2, 623 | pub __bindgen_anon_3: bpf_attr__bindgen_ty_3, 624 | pub __bindgen_anon_4: bpf_attr__bindgen_ty_4, 625 | pub __bindgen_anon_5: bpf_attr__bindgen_ty_5, 626 | pub test: bpf_attr__bindgen_ty_6, 627 | pub __bindgen_anon_6: bpf_attr__bindgen_ty_7, 628 | pub info: bpf_attr__bindgen_ty_8, 629 | pub query: bpf_attr__bindgen_ty_9, 630 | _bindgen_union_align: [u64; 8usize], 631 | } 632 | #[repr(C)] 633 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 634 | pub struct bpf_attr__bindgen_ty_1 { 635 | pub map_type: __u32, 636 | pub key_size: __u32, 637 | pub value_size: __u32, 638 | pub max_entries: __u32, 639 | pub map_flags: __u32, 640 | pub inner_map_fd: __u32, 641 | pub numa_node: __u32, 642 | pub map_name: [::std::os::raw::c_char; 16usize], 643 | } 644 | #[test] 645 | fn bindgen_test_layout_bpf_attr__bindgen_ty_1() { 646 | assert_eq!( 647 | ::std::mem::size_of::(), 648 | 44usize, 649 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_1)) 650 | ); 651 | assert_eq!( 652 | ::std::mem::align_of::(), 653 | 4usize, 654 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_1)) 655 | ); 656 | assert_eq!( 657 | unsafe { &(*(::std::ptr::null::())).map_type as *const _ as usize }, 658 | 0usize, 659 | concat!( 660 | "Offset of field: ", 661 | stringify!(bpf_attr__bindgen_ty_1), 662 | "::", 663 | stringify!(map_type) 664 | ) 665 | ); 666 | assert_eq!( 667 | unsafe { &(*(::std::ptr::null::())).key_size as *const _ as usize }, 668 | 4usize, 669 | concat!( 670 | "Offset of field: ", 671 | stringify!(bpf_attr__bindgen_ty_1), 672 | "::", 673 | stringify!(key_size) 674 | ) 675 | ); 676 | assert_eq!( 677 | unsafe { 678 | &(*(::std::ptr::null::())).value_size as *const _ as usize 679 | }, 680 | 8usize, 681 | concat!( 682 | "Offset of field: ", 683 | stringify!(bpf_attr__bindgen_ty_1), 684 | "::", 685 | stringify!(value_size) 686 | ) 687 | ); 688 | assert_eq!( 689 | unsafe { 690 | &(*(::std::ptr::null::())).max_entries as *const _ as usize 691 | }, 692 | 12usize, 693 | concat!( 694 | "Offset of field: ", 695 | stringify!(bpf_attr__bindgen_ty_1), 696 | "::", 697 | stringify!(max_entries) 698 | ) 699 | ); 700 | assert_eq!( 701 | unsafe { 702 | &(*(::std::ptr::null::())).map_flags as *const _ as usize 703 | }, 704 | 16usize, 705 | concat!( 706 | "Offset of field: ", 707 | stringify!(bpf_attr__bindgen_ty_1), 708 | "::", 709 | stringify!(map_flags) 710 | ) 711 | ); 712 | assert_eq!( 713 | unsafe { 714 | &(*(::std::ptr::null::())).inner_map_fd as *const _ as usize 715 | }, 716 | 20usize, 717 | concat!( 718 | "Offset of field: ", 719 | stringify!(bpf_attr__bindgen_ty_1), 720 | "::", 721 | stringify!(inner_map_fd) 722 | ) 723 | ); 724 | assert_eq!( 725 | unsafe { 726 | &(*(::std::ptr::null::())).numa_node as *const _ as usize 727 | }, 728 | 24usize, 729 | concat!( 730 | "Offset of field: ", 731 | stringify!(bpf_attr__bindgen_ty_1), 732 | "::", 733 | stringify!(numa_node) 734 | ) 735 | ); 736 | assert_eq!( 737 | unsafe { &(*(::std::ptr::null::())).map_name as *const _ as usize }, 738 | 28usize, 739 | concat!( 740 | "Offset of field: ", 741 | stringify!(bpf_attr__bindgen_ty_1), 742 | "::", 743 | stringify!(map_name) 744 | ) 745 | ); 746 | } 747 | #[repr(C)] 748 | #[derive(Copy, Clone)] 749 | pub struct bpf_attr__bindgen_ty_2 { 750 | pub map_fd: __u32, 751 | pub key: __u64, 752 | pub __bindgen_anon_1: bpf_attr__bindgen_ty_2__bindgen_ty_1, 753 | pub flags: __u64, 754 | } 755 | #[repr(C)] 756 | #[derive(Copy, Clone)] 757 | pub union bpf_attr__bindgen_ty_2__bindgen_ty_1 { 758 | pub value: __u64, 759 | pub next_key: __u64, 760 | _bindgen_union_align: u64, 761 | } 762 | #[test] 763 | fn bindgen_test_layout_bpf_attr__bindgen_ty_2__bindgen_ty_1() { 764 | assert_eq!( 765 | ::std::mem::size_of::(), 766 | 8usize, 767 | concat!( 768 | "Size of: ", 769 | stringify!(bpf_attr__bindgen_ty_2__bindgen_ty_1) 770 | ) 771 | ); 772 | assert_eq!( 773 | ::std::mem::align_of::(), 774 | 8usize, 775 | concat!( 776 | "Alignment of ", 777 | stringify!(bpf_attr__bindgen_ty_2__bindgen_ty_1) 778 | ) 779 | ); 780 | assert_eq!( 781 | unsafe { 782 | &(*(::std::ptr::null::())).value as *const _ 783 | as usize 784 | }, 785 | 0usize, 786 | concat!( 787 | "Offset of field: ", 788 | stringify!(bpf_attr__bindgen_ty_2__bindgen_ty_1), 789 | "::", 790 | stringify!(value) 791 | ) 792 | ); 793 | assert_eq!( 794 | unsafe { 795 | &(*(::std::ptr::null::())).next_key as *const _ 796 | as usize 797 | }, 798 | 0usize, 799 | concat!( 800 | "Offset of field: ", 801 | stringify!(bpf_attr__bindgen_ty_2__bindgen_ty_1), 802 | "::", 803 | stringify!(next_key) 804 | ) 805 | ); 806 | } 807 | impl Default for bpf_attr__bindgen_ty_2__bindgen_ty_1 { 808 | fn default() -> Self { 809 | unsafe { ::std::mem::zeroed() } 810 | } 811 | } 812 | impl ::std::fmt::Debug for bpf_attr__bindgen_ty_2__bindgen_ty_1 { 813 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 814 | write!(f, "bpf_attr__bindgen_ty_2__bindgen_ty_1 {{ union }}") 815 | } 816 | } 817 | #[test] 818 | fn bindgen_test_layout_bpf_attr__bindgen_ty_2() { 819 | assert_eq!( 820 | ::std::mem::size_of::(), 821 | 32usize, 822 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_2)) 823 | ); 824 | assert_eq!( 825 | ::std::mem::align_of::(), 826 | 8usize, 827 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_2)) 828 | ); 829 | assert_eq!( 830 | unsafe { &(*(::std::ptr::null::())).map_fd as *const _ as usize }, 831 | 0usize, 832 | concat!( 833 | "Offset of field: ", 834 | stringify!(bpf_attr__bindgen_ty_2), 835 | "::", 836 | stringify!(map_fd) 837 | ) 838 | ); 839 | assert_eq!( 840 | unsafe { &(*(::std::ptr::null::())).key as *const _ as usize }, 841 | 8usize, 842 | concat!( 843 | "Offset of field: ", 844 | stringify!(bpf_attr__bindgen_ty_2), 845 | "::", 846 | stringify!(key) 847 | ) 848 | ); 849 | assert_eq!( 850 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 851 | 24usize, 852 | concat!( 853 | "Offset of field: ", 854 | stringify!(bpf_attr__bindgen_ty_2), 855 | "::", 856 | stringify!(flags) 857 | ) 858 | ); 859 | } 860 | impl Default for bpf_attr__bindgen_ty_2 { 861 | fn default() -> Self { 862 | unsafe { ::std::mem::zeroed() } 863 | } 864 | } 865 | impl ::std::fmt::Debug for bpf_attr__bindgen_ty_2 { 866 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 867 | write ! ( f , "bpf_attr__bindgen_ty_2 {{ map_fd: {:?}, key: {:?}, __bindgen_anon_1: {:?}, flags: {:?} }}" , self . map_fd , self . key , self . __bindgen_anon_1 , self . flags ) 868 | } 869 | } 870 | #[repr(C)] 871 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 872 | pub struct bpf_attr__bindgen_ty_3 { 873 | pub prog_type: __u32, 874 | pub insn_cnt: __u32, 875 | pub insns: __u64, 876 | pub license: __u64, 877 | pub log_level: __u32, 878 | pub log_size: __u32, 879 | pub log_buf: __u64, 880 | pub kern_version: __u32, 881 | pub prog_flags: __u32, 882 | pub prog_name: [::std::os::raw::c_char; 16usize], 883 | } 884 | #[test] 885 | fn bindgen_test_layout_bpf_attr__bindgen_ty_3() { 886 | assert_eq!( 887 | ::std::mem::size_of::(), 888 | 64usize, 889 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_3)) 890 | ); 891 | assert_eq!( 892 | ::std::mem::align_of::(), 893 | 8usize, 894 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_3)) 895 | ); 896 | assert_eq!( 897 | unsafe { 898 | &(*(::std::ptr::null::())).prog_type as *const _ as usize 899 | }, 900 | 0usize, 901 | concat!( 902 | "Offset of field: ", 903 | stringify!(bpf_attr__bindgen_ty_3), 904 | "::", 905 | stringify!(prog_type) 906 | ) 907 | ); 908 | assert_eq!( 909 | unsafe { &(*(::std::ptr::null::())).insn_cnt as *const _ as usize }, 910 | 4usize, 911 | concat!( 912 | "Offset of field: ", 913 | stringify!(bpf_attr__bindgen_ty_3), 914 | "::", 915 | stringify!(insn_cnt) 916 | ) 917 | ); 918 | assert_eq!( 919 | unsafe { &(*(::std::ptr::null::())).insns as *const _ as usize }, 920 | 8usize, 921 | concat!( 922 | "Offset of field: ", 923 | stringify!(bpf_attr__bindgen_ty_3), 924 | "::", 925 | stringify!(insns) 926 | ) 927 | ); 928 | assert_eq!( 929 | unsafe { &(*(::std::ptr::null::())).license as *const _ as usize }, 930 | 16usize, 931 | concat!( 932 | "Offset of field: ", 933 | stringify!(bpf_attr__bindgen_ty_3), 934 | "::", 935 | stringify!(license) 936 | ) 937 | ); 938 | assert_eq!( 939 | unsafe { 940 | &(*(::std::ptr::null::())).log_level as *const _ as usize 941 | }, 942 | 24usize, 943 | concat!( 944 | "Offset of field: ", 945 | stringify!(bpf_attr__bindgen_ty_3), 946 | "::", 947 | stringify!(log_level) 948 | ) 949 | ); 950 | assert_eq!( 951 | unsafe { &(*(::std::ptr::null::())).log_size as *const _ as usize }, 952 | 28usize, 953 | concat!( 954 | "Offset of field: ", 955 | stringify!(bpf_attr__bindgen_ty_3), 956 | "::", 957 | stringify!(log_size) 958 | ) 959 | ); 960 | assert_eq!( 961 | unsafe { &(*(::std::ptr::null::())).log_buf as *const _ as usize }, 962 | 32usize, 963 | concat!( 964 | "Offset of field: ", 965 | stringify!(bpf_attr__bindgen_ty_3), 966 | "::", 967 | stringify!(log_buf) 968 | ) 969 | ); 970 | assert_eq!( 971 | unsafe { 972 | &(*(::std::ptr::null::())).kern_version as *const _ as usize 973 | }, 974 | 40usize, 975 | concat!( 976 | "Offset of field: ", 977 | stringify!(bpf_attr__bindgen_ty_3), 978 | "::", 979 | stringify!(kern_version) 980 | ) 981 | ); 982 | assert_eq!( 983 | unsafe { 984 | &(*(::std::ptr::null::())).prog_flags as *const _ as usize 985 | }, 986 | 44usize, 987 | concat!( 988 | "Offset of field: ", 989 | stringify!(bpf_attr__bindgen_ty_3), 990 | "::", 991 | stringify!(prog_flags) 992 | ) 993 | ); 994 | assert_eq!( 995 | unsafe { 996 | &(*(::std::ptr::null::())).prog_name as *const _ as usize 997 | }, 998 | 48usize, 999 | concat!( 1000 | "Offset of field: ", 1001 | stringify!(bpf_attr__bindgen_ty_3), 1002 | "::", 1003 | stringify!(prog_name) 1004 | ) 1005 | ); 1006 | } 1007 | #[repr(C)] 1008 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 1009 | pub struct bpf_attr__bindgen_ty_4 { 1010 | pub pathname: __u64, 1011 | pub bpf_fd: __u32, 1012 | } 1013 | #[test] 1014 | fn bindgen_test_layout_bpf_attr__bindgen_ty_4() { 1015 | assert_eq!( 1016 | ::std::mem::size_of::(), 1017 | 16usize, 1018 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_4)) 1019 | ); 1020 | assert_eq!( 1021 | ::std::mem::align_of::(), 1022 | 8usize, 1023 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_4)) 1024 | ); 1025 | assert_eq!( 1026 | unsafe { &(*(::std::ptr::null::())).pathname as *const _ as usize }, 1027 | 0usize, 1028 | concat!( 1029 | "Offset of field: ", 1030 | stringify!(bpf_attr__bindgen_ty_4), 1031 | "::", 1032 | stringify!(pathname) 1033 | ) 1034 | ); 1035 | assert_eq!( 1036 | unsafe { &(*(::std::ptr::null::())).bpf_fd as *const _ as usize }, 1037 | 8usize, 1038 | concat!( 1039 | "Offset of field: ", 1040 | stringify!(bpf_attr__bindgen_ty_4), 1041 | "::", 1042 | stringify!(bpf_fd) 1043 | ) 1044 | ); 1045 | } 1046 | #[repr(C)] 1047 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 1048 | pub struct bpf_attr__bindgen_ty_5 { 1049 | pub target_fd: __u32, 1050 | pub attach_bpf_fd: __u32, 1051 | pub attach_type: __u32, 1052 | pub attach_flags: __u32, 1053 | } 1054 | #[test] 1055 | fn bindgen_test_layout_bpf_attr__bindgen_ty_5() { 1056 | assert_eq!( 1057 | ::std::mem::size_of::(), 1058 | 16usize, 1059 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_5)) 1060 | ); 1061 | assert_eq!( 1062 | ::std::mem::align_of::(), 1063 | 4usize, 1064 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_5)) 1065 | ); 1066 | assert_eq!( 1067 | unsafe { 1068 | &(*(::std::ptr::null::())).target_fd as *const _ as usize 1069 | }, 1070 | 0usize, 1071 | concat!( 1072 | "Offset of field: ", 1073 | stringify!(bpf_attr__bindgen_ty_5), 1074 | "::", 1075 | stringify!(target_fd) 1076 | ) 1077 | ); 1078 | assert_eq!( 1079 | unsafe { 1080 | &(*(::std::ptr::null::())).attach_bpf_fd as *const _ as usize 1081 | }, 1082 | 4usize, 1083 | concat!( 1084 | "Offset of field: ", 1085 | stringify!(bpf_attr__bindgen_ty_5), 1086 | "::", 1087 | stringify!(attach_bpf_fd) 1088 | ) 1089 | ); 1090 | assert_eq!( 1091 | unsafe { 1092 | &(*(::std::ptr::null::())).attach_type as *const _ as usize 1093 | }, 1094 | 8usize, 1095 | concat!( 1096 | "Offset of field: ", 1097 | stringify!(bpf_attr__bindgen_ty_5), 1098 | "::", 1099 | stringify!(attach_type) 1100 | ) 1101 | ); 1102 | assert_eq!( 1103 | unsafe { 1104 | &(*(::std::ptr::null::())).attach_flags as *const _ as usize 1105 | }, 1106 | 12usize, 1107 | concat!( 1108 | "Offset of field: ", 1109 | stringify!(bpf_attr__bindgen_ty_5), 1110 | "::", 1111 | stringify!(attach_flags) 1112 | ) 1113 | ); 1114 | } 1115 | #[repr(C)] 1116 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 1117 | pub struct bpf_attr__bindgen_ty_6 { 1118 | pub prog_fd: __u32, 1119 | pub retval: __u32, 1120 | pub data_size_in: __u32, 1121 | pub data_size_out: __u32, 1122 | pub data_in: __u64, 1123 | pub data_out: __u64, 1124 | pub repeat: __u32, 1125 | pub duration: __u32, 1126 | } 1127 | #[test] 1128 | fn bindgen_test_layout_bpf_attr__bindgen_ty_6() { 1129 | assert_eq!( 1130 | ::std::mem::size_of::(), 1131 | 40usize, 1132 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_6)) 1133 | ); 1134 | assert_eq!( 1135 | ::std::mem::align_of::(), 1136 | 8usize, 1137 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_6)) 1138 | ); 1139 | assert_eq!( 1140 | unsafe { &(*(::std::ptr::null::())).prog_fd as *const _ as usize }, 1141 | 0usize, 1142 | concat!( 1143 | "Offset of field: ", 1144 | stringify!(bpf_attr__bindgen_ty_6), 1145 | "::", 1146 | stringify!(prog_fd) 1147 | ) 1148 | ); 1149 | assert_eq!( 1150 | unsafe { &(*(::std::ptr::null::())).retval as *const _ as usize }, 1151 | 4usize, 1152 | concat!( 1153 | "Offset of field: ", 1154 | stringify!(bpf_attr__bindgen_ty_6), 1155 | "::", 1156 | stringify!(retval) 1157 | ) 1158 | ); 1159 | assert_eq!( 1160 | unsafe { 1161 | &(*(::std::ptr::null::())).data_size_in as *const _ as usize 1162 | }, 1163 | 8usize, 1164 | concat!( 1165 | "Offset of field: ", 1166 | stringify!(bpf_attr__bindgen_ty_6), 1167 | "::", 1168 | stringify!(data_size_in) 1169 | ) 1170 | ); 1171 | assert_eq!( 1172 | unsafe { 1173 | &(*(::std::ptr::null::())).data_size_out as *const _ as usize 1174 | }, 1175 | 12usize, 1176 | concat!( 1177 | "Offset of field: ", 1178 | stringify!(bpf_attr__bindgen_ty_6), 1179 | "::", 1180 | stringify!(data_size_out) 1181 | ) 1182 | ); 1183 | assert_eq!( 1184 | unsafe { &(*(::std::ptr::null::())).data_in as *const _ as usize }, 1185 | 16usize, 1186 | concat!( 1187 | "Offset of field: ", 1188 | stringify!(bpf_attr__bindgen_ty_6), 1189 | "::", 1190 | stringify!(data_in) 1191 | ) 1192 | ); 1193 | assert_eq!( 1194 | unsafe { &(*(::std::ptr::null::())).data_out as *const _ as usize }, 1195 | 24usize, 1196 | concat!( 1197 | "Offset of field: ", 1198 | stringify!(bpf_attr__bindgen_ty_6), 1199 | "::", 1200 | stringify!(data_out) 1201 | ) 1202 | ); 1203 | assert_eq!( 1204 | unsafe { &(*(::std::ptr::null::())).repeat as *const _ as usize }, 1205 | 32usize, 1206 | concat!( 1207 | "Offset of field: ", 1208 | stringify!(bpf_attr__bindgen_ty_6), 1209 | "::", 1210 | stringify!(repeat) 1211 | ) 1212 | ); 1213 | assert_eq!( 1214 | unsafe { &(*(::std::ptr::null::())).duration as *const _ as usize }, 1215 | 36usize, 1216 | concat!( 1217 | "Offset of field: ", 1218 | stringify!(bpf_attr__bindgen_ty_6), 1219 | "::", 1220 | stringify!(duration) 1221 | ) 1222 | ); 1223 | } 1224 | #[repr(C)] 1225 | #[derive(Copy, Clone)] 1226 | pub struct bpf_attr__bindgen_ty_7 { 1227 | pub __bindgen_anon_1: bpf_attr__bindgen_ty_7__bindgen_ty_1, 1228 | pub next_id: __u32, 1229 | } 1230 | #[repr(C)] 1231 | #[derive(Copy, Clone)] 1232 | pub union bpf_attr__bindgen_ty_7__bindgen_ty_1 { 1233 | pub start_id: __u32, 1234 | pub prog_id: __u32, 1235 | pub map_id: __u32, 1236 | _bindgen_union_align: u32, 1237 | } 1238 | #[test] 1239 | fn bindgen_test_layout_bpf_attr__bindgen_ty_7__bindgen_ty_1() { 1240 | assert_eq!( 1241 | ::std::mem::size_of::(), 1242 | 4usize, 1243 | concat!( 1244 | "Size of: ", 1245 | stringify!(bpf_attr__bindgen_ty_7__bindgen_ty_1) 1246 | ) 1247 | ); 1248 | assert_eq!( 1249 | ::std::mem::align_of::(), 1250 | 4usize, 1251 | concat!( 1252 | "Alignment of ", 1253 | stringify!(bpf_attr__bindgen_ty_7__bindgen_ty_1) 1254 | ) 1255 | ); 1256 | assert_eq!( 1257 | unsafe { 1258 | &(*(::std::ptr::null::())).start_id as *const _ 1259 | as usize 1260 | }, 1261 | 0usize, 1262 | concat!( 1263 | "Offset of field: ", 1264 | stringify!(bpf_attr__bindgen_ty_7__bindgen_ty_1), 1265 | "::", 1266 | stringify!(start_id) 1267 | ) 1268 | ); 1269 | assert_eq!( 1270 | unsafe { 1271 | &(*(::std::ptr::null::())).prog_id as *const _ 1272 | as usize 1273 | }, 1274 | 0usize, 1275 | concat!( 1276 | "Offset of field: ", 1277 | stringify!(bpf_attr__bindgen_ty_7__bindgen_ty_1), 1278 | "::", 1279 | stringify!(prog_id) 1280 | ) 1281 | ); 1282 | assert_eq!( 1283 | unsafe { 1284 | &(*(::std::ptr::null::())).map_id as *const _ 1285 | as usize 1286 | }, 1287 | 0usize, 1288 | concat!( 1289 | "Offset of field: ", 1290 | stringify!(bpf_attr__bindgen_ty_7__bindgen_ty_1), 1291 | "::", 1292 | stringify!(map_id) 1293 | ) 1294 | ); 1295 | } 1296 | impl Default for bpf_attr__bindgen_ty_7__bindgen_ty_1 { 1297 | fn default() -> Self { 1298 | unsafe { ::std::mem::zeroed() } 1299 | } 1300 | } 1301 | impl ::std::fmt::Debug for bpf_attr__bindgen_ty_7__bindgen_ty_1 { 1302 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1303 | write!(f, "bpf_attr__bindgen_ty_7__bindgen_ty_1 {{ union }}") 1304 | } 1305 | } 1306 | #[test] 1307 | fn bindgen_test_layout_bpf_attr__bindgen_ty_7() { 1308 | assert_eq!( 1309 | ::std::mem::size_of::(), 1310 | 8usize, 1311 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_7)) 1312 | ); 1313 | assert_eq!( 1314 | ::std::mem::align_of::(), 1315 | 4usize, 1316 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_7)) 1317 | ); 1318 | assert_eq!( 1319 | unsafe { &(*(::std::ptr::null::())).next_id as *const _ as usize }, 1320 | 4usize, 1321 | concat!( 1322 | "Offset of field: ", 1323 | stringify!(bpf_attr__bindgen_ty_7), 1324 | "::", 1325 | stringify!(next_id) 1326 | ) 1327 | ); 1328 | } 1329 | impl Default for bpf_attr__bindgen_ty_7 { 1330 | fn default() -> Self { 1331 | unsafe { ::std::mem::zeroed() } 1332 | } 1333 | } 1334 | impl ::std::fmt::Debug for bpf_attr__bindgen_ty_7 { 1335 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1336 | write!( 1337 | f, 1338 | "bpf_attr__bindgen_ty_7 {{ __bindgen_anon_1: {:?}, next_id: {:?} }}", 1339 | self.__bindgen_anon_1, self.next_id 1340 | ) 1341 | } 1342 | } 1343 | #[repr(C)] 1344 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 1345 | pub struct bpf_attr__bindgen_ty_8 { 1346 | pub bpf_fd: __u32, 1347 | pub info_len: __u32, 1348 | pub info: __u64, 1349 | } 1350 | #[test] 1351 | fn bindgen_test_layout_bpf_attr__bindgen_ty_8() { 1352 | assert_eq!( 1353 | ::std::mem::size_of::(), 1354 | 16usize, 1355 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_8)) 1356 | ); 1357 | assert_eq!( 1358 | ::std::mem::align_of::(), 1359 | 8usize, 1360 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_8)) 1361 | ); 1362 | assert_eq!( 1363 | unsafe { &(*(::std::ptr::null::())).bpf_fd as *const _ as usize }, 1364 | 0usize, 1365 | concat!( 1366 | "Offset of field: ", 1367 | stringify!(bpf_attr__bindgen_ty_8), 1368 | "::", 1369 | stringify!(bpf_fd) 1370 | ) 1371 | ); 1372 | assert_eq!( 1373 | unsafe { &(*(::std::ptr::null::())).info_len as *const _ as usize }, 1374 | 4usize, 1375 | concat!( 1376 | "Offset of field: ", 1377 | stringify!(bpf_attr__bindgen_ty_8), 1378 | "::", 1379 | stringify!(info_len) 1380 | ) 1381 | ); 1382 | assert_eq!( 1383 | unsafe { &(*(::std::ptr::null::())).info as *const _ as usize }, 1384 | 8usize, 1385 | concat!( 1386 | "Offset of field: ", 1387 | stringify!(bpf_attr__bindgen_ty_8), 1388 | "::", 1389 | stringify!(info) 1390 | ) 1391 | ); 1392 | } 1393 | #[repr(C)] 1394 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 1395 | pub struct bpf_attr__bindgen_ty_9 { 1396 | pub target_fd: __u32, 1397 | pub attach_type: __u32, 1398 | pub query_flags: __u32, 1399 | pub attach_flags: __u32, 1400 | pub prog_ids: __u64, 1401 | pub prog_cnt: __u32, 1402 | } 1403 | #[test] 1404 | fn bindgen_test_layout_bpf_attr__bindgen_ty_9() { 1405 | assert_eq!( 1406 | ::std::mem::size_of::(), 1407 | 32usize, 1408 | concat!("Size of: ", stringify!(bpf_attr__bindgen_ty_9)) 1409 | ); 1410 | assert_eq!( 1411 | ::std::mem::align_of::(), 1412 | 8usize, 1413 | concat!("Alignment of ", stringify!(bpf_attr__bindgen_ty_9)) 1414 | ); 1415 | assert_eq!( 1416 | unsafe { 1417 | &(*(::std::ptr::null::())).target_fd as *const _ as usize 1418 | }, 1419 | 0usize, 1420 | concat!( 1421 | "Offset of field: ", 1422 | stringify!(bpf_attr__bindgen_ty_9), 1423 | "::", 1424 | stringify!(target_fd) 1425 | ) 1426 | ); 1427 | assert_eq!( 1428 | unsafe { 1429 | &(*(::std::ptr::null::())).attach_type as *const _ as usize 1430 | }, 1431 | 4usize, 1432 | concat!( 1433 | "Offset of field: ", 1434 | stringify!(bpf_attr__bindgen_ty_9), 1435 | "::", 1436 | stringify!(attach_type) 1437 | ) 1438 | ); 1439 | assert_eq!( 1440 | unsafe { 1441 | &(*(::std::ptr::null::())).query_flags as *const _ as usize 1442 | }, 1443 | 8usize, 1444 | concat!( 1445 | "Offset of field: ", 1446 | stringify!(bpf_attr__bindgen_ty_9), 1447 | "::", 1448 | stringify!(query_flags) 1449 | ) 1450 | ); 1451 | assert_eq!( 1452 | unsafe { 1453 | &(*(::std::ptr::null::())).attach_flags as *const _ as usize 1454 | }, 1455 | 12usize, 1456 | concat!( 1457 | "Offset of field: ", 1458 | stringify!(bpf_attr__bindgen_ty_9), 1459 | "::", 1460 | stringify!(attach_flags) 1461 | ) 1462 | ); 1463 | assert_eq!( 1464 | unsafe { &(*(::std::ptr::null::())).prog_ids as *const _ as usize }, 1465 | 16usize, 1466 | concat!( 1467 | "Offset of field: ", 1468 | stringify!(bpf_attr__bindgen_ty_9), 1469 | "::", 1470 | stringify!(prog_ids) 1471 | ) 1472 | ); 1473 | assert_eq!( 1474 | unsafe { &(*(::std::ptr::null::())).prog_cnt as *const _ as usize }, 1475 | 24usize, 1476 | concat!( 1477 | "Offset of field: ", 1478 | stringify!(bpf_attr__bindgen_ty_9), 1479 | "::", 1480 | stringify!(prog_cnt) 1481 | ) 1482 | ); 1483 | } 1484 | #[test] 1485 | fn bindgen_test_layout_bpf_attr() { 1486 | assert_eq!( 1487 | ::std::mem::size_of::(), 1488 | 64usize, 1489 | concat!("Size of: ", stringify!(bpf_attr)) 1490 | ); 1491 | assert_eq!( 1492 | ::std::mem::align_of::(), 1493 | 8usize, 1494 | concat!("Alignment of ", stringify!(bpf_attr)) 1495 | ); 1496 | assert_eq!( 1497 | unsafe { &(*(::std::ptr::null::())).test as *const _ as usize }, 1498 | 0usize, 1499 | concat!( 1500 | "Offset of field: ", 1501 | stringify!(bpf_attr), 1502 | "::", 1503 | stringify!(test) 1504 | ) 1505 | ); 1506 | assert_eq!( 1507 | unsafe { &(*(::std::ptr::null::())).info as *const _ as usize }, 1508 | 0usize, 1509 | concat!( 1510 | "Offset of field: ", 1511 | stringify!(bpf_attr), 1512 | "::", 1513 | stringify!(info) 1514 | ) 1515 | ); 1516 | assert_eq!( 1517 | unsafe { &(*(::std::ptr::null::())).query as *const _ as usize }, 1518 | 0usize, 1519 | concat!( 1520 | "Offset of field: ", 1521 | stringify!(bpf_attr), 1522 | "::", 1523 | stringify!(query) 1524 | ) 1525 | ); 1526 | } 1527 | impl Default for bpf_attr { 1528 | fn default() -> Self { 1529 | unsafe { ::std::mem::zeroed() } 1530 | } 1531 | } 1532 | impl ::std::fmt::Debug for bpf_attr { 1533 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1534 | write!(f, "bpf_attr {{ union }}") 1535 | } 1536 | } 1537 | pub const bpf_func_id_BPF_FUNC_unspec: bpf_func_id = 0; 1538 | pub const bpf_func_id_BPF_FUNC_map_lookup_elem: bpf_func_id = 1; 1539 | pub const bpf_func_id_BPF_FUNC_map_update_elem: bpf_func_id = 2; 1540 | pub const bpf_func_id_BPF_FUNC_map_delete_elem: bpf_func_id = 3; 1541 | pub const bpf_func_id_BPF_FUNC_probe_read: bpf_func_id = 4; 1542 | pub const bpf_func_id_BPF_FUNC_ktime_get_ns: bpf_func_id = 5; 1543 | pub const bpf_func_id_BPF_FUNC_trace_printk: bpf_func_id = 6; 1544 | pub const bpf_func_id_BPF_FUNC_get_prandom_u32: bpf_func_id = 7; 1545 | pub const bpf_func_id_BPF_FUNC_get_smp_processor_id: bpf_func_id = 8; 1546 | pub const bpf_func_id_BPF_FUNC_skb_store_bytes: bpf_func_id = 9; 1547 | pub const bpf_func_id_BPF_FUNC_l3_csum_replace: bpf_func_id = 10; 1548 | pub const bpf_func_id_BPF_FUNC_l4_csum_replace: bpf_func_id = 11; 1549 | pub const bpf_func_id_BPF_FUNC_tail_call: bpf_func_id = 12; 1550 | pub const bpf_func_id_BPF_FUNC_clone_redirect: bpf_func_id = 13; 1551 | pub const bpf_func_id_BPF_FUNC_get_current_pid_tgid: bpf_func_id = 14; 1552 | pub const bpf_func_id_BPF_FUNC_get_current_uid_gid: bpf_func_id = 15; 1553 | pub const bpf_func_id_BPF_FUNC_get_current_comm: bpf_func_id = 16; 1554 | pub const bpf_func_id_BPF_FUNC_get_cgroup_classid: bpf_func_id = 17; 1555 | pub const bpf_func_id_BPF_FUNC_skb_vlan_push: bpf_func_id = 18; 1556 | pub const bpf_func_id_BPF_FUNC_skb_vlan_pop: bpf_func_id = 19; 1557 | pub const bpf_func_id_BPF_FUNC_skb_get_tunnel_key: bpf_func_id = 20; 1558 | pub const bpf_func_id_BPF_FUNC_skb_set_tunnel_key: bpf_func_id = 21; 1559 | pub const bpf_func_id_BPF_FUNC_perf_event_read: bpf_func_id = 22; 1560 | pub const bpf_func_id_BPF_FUNC_redirect: bpf_func_id = 23; 1561 | pub const bpf_func_id_BPF_FUNC_get_route_realm: bpf_func_id = 24; 1562 | pub const bpf_func_id_BPF_FUNC_perf_event_output: bpf_func_id = 25; 1563 | pub const bpf_func_id_BPF_FUNC_skb_load_bytes: bpf_func_id = 26; 1564 | pub const bpf_func_id_BPF_FUNC_get_stackid: bpf_func_id = 27; 1565 | pub const bpf_func_id_BPF_FUNC_csum_diff: bpf_func_id = 28; 1566 | pub const bpf_func_id_BPF_FUNC_skb_get_tunnel_opt: bpf_func_id = 29; 1567 | pub const bpf_func_id_BPF_FUNC_skb_set_tunnel_opt: bpf_func_id = 30; 1568 | pub const bpf_func_id_BPF_FUNC_skb_change_proto: bpf_func_id = 31; 1569 | pub const bpf_func_id_BPF_FUNC_skb_change_type: bpf_func_id = 32; 1570 | pub const bpf_func_id_BPF_FUNC_skb_under_cgroup: bpf_func_id = 33; 1571 | pub const bpf_func_id_BPF_FUNC_get_hash_recalc: bpf_func_id = 34; 1572 | pub const bpf_func_id_BPF_FUNC_get_current_task: bpf_func_id = 35; 1573 | pub const bpf_func_id_BPF_FUNC_probe_write_user: bpf_func_id = 36; 1574 | pub const bpf_func_id_BPF_FUNC_current_task_under_cgroup: bpf_func_id = 37; 1575 | pub const bpf_func_id_BPF_FUNC_skb_change_tail: bpf_func_id = 38; 1576 | pub const bpf_func_id_BPF_FUNC_skb_pull_data: bpf_func_id = 39; 1577 | pub const bpf_func_id_BPF_FUNC_csum_update: bpf_func_id = 40; 1578 | pub const bpf_func_id_BPF_FUNC_set_hash_invalid: bpf_func_id = 41; 1579 | pub const bpf_func_id_BPF_FUNC_get_numa_node_id: bpf_func_id = 42; 1580 | pub const bpf_func_id_BPF_FUNC_skb_change_head: bpf_func_id = 43; 1581 | pub const bpf_func_id_BPF_FUNC_xdp_adjust_head: bpf_func_id = 44; 1582 | pub const bpf_func_id_BPF_FUNC_probe_read_str: bpf_func_id = 45; 1583 | pub const bpf_func_id_BPF_FUNC_get_socket_cookie: bpf_func_id = 46; 1584 | pub const bpf_func_id_BPF_FUNC_get_socket_uid: bpf_func_id = 47; 1585 | pub const bpf_func_id_BPF_FUNC_set_hash: bpf_func_id = 48; 1586 | pub const bpf_func_id_BPF_FUNC_setsockopt: bpf_func_id = 49; 1587 | pub const bpf_func_id_BPF_FUNC_skb_adjust_room: bpf_func_id = 50; 1588 | pub const bpf_func_id_BPF_FUNC_redirect_map: bpf_func_id = 51; 1589 | pub const bpf_func_id_BPF_FUNC_sk_redirect_map: bpf_func_id = 52; 1590 | pub const bpf_func_id_BPF_FUNC_sock_map_update: bpf_func_id = 53; 1591 | pub const bpf_func_id_BPF_FUNC_xdp_adjust_meta: bpf_func_id = 54; 1592 | pub const bpf_func_id_BPF_FUNC_perf_event_read_value: bpf_func_id = 55; 1593 | pub const bpf_func_id_BPF_FUNC_perf_prog_read_value: bpf_func_id = 56; 1594 | pub const bpf_func_id___BPF_FUNC_MAX_ID: bpf_func_id = 57; 1595 | pub type bpf_func_id = u32; 1596 | pub const bpf_adj_room_mode_BPF_ADJ_ROOM_NET: bpf_adj_room_mode = 0; 1597 | pub type bpf_adj_room_mode = u32; 1598 | #[repr(C)] 1599 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 1600 | pub struct __sk_buff { 1601 | pub len: __u32, 1602 | pub pkt_type: __u32, 1603 | pub mark: __u32, 1604 | pub queue_mapping: __u32, 1605 | pub protocol: __u32, 1606 | pub vlan_present: __u32, 1607 | pub vlan_tci: __u32, 1608 | pub vlan_proto: __u32, 1609 | pub priority: __u32, 1610 | pub ingress_ifindex: __u32, 1611 | pub ifindex: __u32, 1612 | pub tc_index: __u32, 1613 | pub cb: [__u32; 5usize], 1614 | pub hash: __u32, 1615 | pub tc_classid: __u32, 1616 | pub data: __u32, 1617 | pub data_end: __u32, 1618 | pub napi_id: __u32, 1619 | pub family: __u32, 1620 | pub remote_ip4: __u32, 1621 | pub local_ip4: __u32, 1622 | pub remote_ip6: [__u32; 4usize], 1623 | pub local_ip6: [__u32; 4usize], 1624 | pub remote_port: __u32, 1625 | pub local_port: __u32, 1626 | pub data_meta: __u32, 1627 | } 1628 | #[test] 1629 | fn bindgen_test_layout___sk_buff() { 1630 | assert_eq!( 1631 | ::std::mem::size_of::<__sk_buff>(), 1632 | 144usize, 1633 | concat!("Size of: ", stringify!(__sk_buff)) 1634 | ); 1635 | assert_eq!( 1636 | ::std::mem::align_of::<__sk_buff>(), 1637 | 4usize, 1638 | concat!("Alignment of ", stringify!(__sk_buff)) 1639 | ); 1640 | assert_eq!( 1641 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).len as *const _ as usize }, 1642 | 0usize, 1643 | concat!( 1644 | "Offset of field: ", 1645 | stringify!(__sk_buff), 1646 | "::", 1647 | stringify!(len) 1648 | ) 1649 | ); 1650 | assert_eq!( 1651 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).pkt_type as *const _ as usize }, 1652 | 4usize, 1653 | concat!( 1654 | "Offset of field: ", 1655 | stringify!(__sk_buff), 1656 | "::", 1657 | stringify!(pkt_type) 1658 | ) 1659 | ); 1660 | assert_eq!( 1661 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).mark as *const _ as usize }, 1662 | 8usize, 1663 | concat!( 1664 | "Offset of field: ", 1665 | stringify!(__sk_buff), 1666 | "::", 1667 | stringify!(mark) 1668 | ) 1669 | ); 1670 | assert_eq!( 1671 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).queue_mapping as *const _ as usize }, 1672 | 12usize, 1673 | concat!( 1674 | "Offset of field: ", 1675 | stringify!(__sk_buff), 1676 | "::", 1677 | stringify!(queue_mapping) 1678 | ) 1679 | ); 1680 | assert_eq!( 1681 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).protocol as *const _ as usize }, 1682 | 16usize, 1683 | concat!( 1684 | "Offset of field: ", 1685 | stringify!(__sk_buff), 1686 | "::", 1687 | stringify!(protocol) 1688 | ) 1689 | ); 1690 | assert_eq!( 1691 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).vlan_present as *const _ as usize }, 1692 | 20usize, 1693 | concat!( 1694 | "Offset of field: ", 1695 | stringify!(__sk_buff), 1696 | "::", 1697 | stringify!(vlan_present) 1698 | ) 1699 | ); 1700 | assert_eq!( 1701 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).vlan_tci as *const _ as usize }, 1702 | 24usize, 1703 | concat!( 1704 | "Offset of field: ", 1705 | stringify!(__sk_buff), 1706 | "::", 1707 | stringify!(vlan_tci) 1708 | ) 1709 | ); 1710 | assert_eq!( 1711 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).vlan_proto as *const _ as usize }, 1712 | 28usize, 1713 | concat!( 1714 | "Offset of field: ", 1715 | stringify!(__sk_buff), 1716 | "::", 1717 | stringify!(vlan_proto) 1718 | ) 1719 | ); 1720 | assert_eq!( 1721 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).priority as *const _ as usize }, 1722 | 32usize, 1723 | concat!( 1724 | "Offset of field: ", 1725 | stringify!(__sk_buff), 1726 | "::", 1727 | stringify!(priority) 1728 | ) 1729 | ); 1730 | assert_eq!( 1731 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).ingress_ifindex as *const _ as usize }, 1732 | 36usize, 1733 | concat!( 1734 | "Offset of field: ", 1735 | stringify!(__sk_buff), 1736 | "::", 1737 | stringify!(ingress_ifindex) 1738 | ) 1739 | ); 1740 | assert_eq!( 1741 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).ifindex as *const _ as usize }, 1742 | 40usize, 1743 | concat!( 1744 | "Offset of field: ", 1745 | stringify!(__sk_buff), 1746 | "::", 1747 | stringify!(ifindex) 1748 | ) 1749 | ); 1750 | assert_eq!( 1751 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).tc_index as *const _ as usize }, 1752 | 44usize, 1753 | concat!( 1754 | "Offset of field: ", 1755 | stringify!(__sk_buff), 1756 | "::", 1757 | stringify!(tc_index) 1758 | ) 1759 | ); 1760 | assert_eq!( 1761 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).cb as *const _ as usize }, 1762 | 48usize, 1763 | concat!( 1764 | "Offset of field: ", 1765 | stringify!(__sk_buff), 1766 | "::", 1767 | stringify!(cb) 1768 | ) 1769 | ); 1770 | assert_eq!( 1771 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).hash as *const _ as usize }, 1772 | 68usize, 1773 | concat!( 1774 | "Offset of field: ", 1775 | stringify!(__sk_buff), 1776 | "::", 1777 | stringify!(hash) 1778 | ) 1779 | ); 1780 | assert_eq!( 1781 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).tc_classid as *const _ as usize }, 1782 | 72usize, 1783 | concat!( 1784 | "Offset of field: ", 1785 | stringify!(__sk_buff), 1786 | "::", 1787 | stringify!(tc_classid) 1788 | ) 1789 | ); 1790 | assert_eq!( 1791 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).data as *const _ as usize }, 1792 | 76usize, 1793 | concat!( 1794 | "Offset of field: ", 1795 | stringify!(__sk_buff), 1796 | "::", 1797 | stringify!(data) 1798 | ) 1799 | ); 1800 | assert_eq!( 1801 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).data_end as *const _ as usize }, 1802 | 80usize, 1803 | concat!( 1804 | "Offset of field: ", 1805 | stringify!(__sk_buff), 1806 | "::", 1807 | stringify!(data_end) 1808 | ) 1809 | ); 1810 | assert_eq!( 1811 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).napi_id as *const _ as usize }, 1812 | 84usize, 1813 | concat!( 1814 | "Offset of field: ", 1815 | stringify!(__sk_buff), 1816 | "::", 1817 | stringify!(napi_id) 1818 | ) 1819 | ); 1820 | assert_eq!( 1821 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).family as *const _ as usize }, 1822 | 88usize, 1823 | concat!( 1824 | "Offset of field: ", 1825 | stringify!(__sk_buff), 1826 | "::", 1827 | stringify!(family) 1828 | ) 1829 | ); 1830 | assert_eq!( 1831 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).remote_ip4 as *const _ as usize }, 1832 | 92usize, 1833 | concat!( 1834 | "Offset of field: ", 1835 | stringify!(__sk_buff), 1836 | "::", 1837 | stringify!(remote_ip4) 1838 | ) 1839 | ); 1840 | assert_eq!( 1841 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).local_ip4 as *const _ as usize }, 1842 | 96usize, 1843 | concat!( 1844 | "Offset of field: ", 1845 | stringify!(__sk_buff), 1846 | "::", 1847 | stringify!(local_ip4) 1848 | ) 1849 | ); 1850 | assert_eq!( 1851 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).remote_ip6 as *const _ as usize }, 1852 | 100usize, 1853 | concat!( 1854 | "Offset of field: ", 1855 | stringify!(__sk_buff), 1856 | "::", 1857 | stringify!(remote_ip6) 1858 | ) 1859 | ); 1860 | assert_eq!( 1861 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).local_ip6 as *const _ as usize }, 1862 | 116usize, 1863 | concat!( 1864 | "Offset of field: ", 1865 | stringify!(__sk_buff), 1866 | "::", 1867 | stringify!(local_ip6) 1868 | ) 1869 | ); 1870 | assert_eq!( 1871 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).remote_port as *const _ as usize }, 1872 | 132usize, 1873 | concat!( 1874 | "Offset of field: ", 1875 | stringify!(__sk_buff), 1876 | "::", 1877 | stringify!(remote_port) 1878 | ) 1879 | ); 1880 | assert_eq!( 1881 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).local_port as *const _ as usize }, 1882 | 136usize, 1883 | concat!( 1884 | "Offset of field: ", 1885 | stringify!(__sk_buff), 1886 | "::", 1887 | stringify!(local_port) 1888 | ) 1889 | ); 1890 | assert_eq!( 1891 | unsafe { &(*(::std::ptr::null::<__sk_buff>())).data_meta as *const _ as usize }, 1892 | 140usize, 1893 | concat!( 1894 | "Offset of field: ", 1895 | stringify!(__sk_buff), 1896 | "::", 1897 | stringify!(data_meta) 1898 | ) 1899 | ); 1900 | } 1901 | #[repr(C)] 1902 | #[derive(Copy, Clone)] 1903 | pub struct bpf_tunnel_key { 1904 | pub tunnel_id: __u32, 1905 | pub __bindgen_anon_1: bpf_tunnel_key__bindgen_ty_1, 1906 | pub tunnel_tos: __u8, 1907 | pub tunnel_ttl: __u8, 1908 | pub tunnel_ext: __u16, 1909 | pub tunnel_label: __u32, 1910 | } 1911 | #[repr(C)] 1912 | #[derive(Copy, Clone)] 1913 | pub union bpf_tunnel_key__bindgen_ty_1 { 1914 | pub remote_ipv4: __u32, 1915 | pub remote_ipv6: [__u32; 4usize], 1916 | _bindgen_union_align: [u32; 4usize], 1917 | } 1918 | #[test] 1919 | fn bindgen_test_layout_bpf_tunnel_key__bindgen_ty_1() { 1920 | assert_eq!( 1921 | ::std::mem::size_of::(), 1922 | 16usize, 1923 | concat!("Size of: ", stringify!(bpf_tunnel_key__bindgen_ty_1)) 1924 | ); 1925 | assert_eq!( 1926 | ::std::mem::align_of::(), 1927 | 4usize, 1928 | concat!("Alignment of ", stringify!(bpf_tunnel_key__bindgen_ty_1)) 1929 | ); 1930 | assert_eq!( 1931 | unsafe { 1932 | &(*(::std::ptr::null::())).remote_ipv4 as *const _ 1933 | as usize 1934 | }, 1935 | 0usize, 1936 | concat!( 1937 | "Offset of field: ", 1938 | stringify!(bpf_tunnel_key__bindgen_ty_1), 1939 | "::", 1940 | stringify!(remote_ipv4) 1941 | ) 1942 | ); 1943 | assert_eq!( 1944 | unsafe { 1945 | &(*(::std::ptr::null::())).remote_ipv6 as *const _ 1946 | as usize 1947 | }, 1948 | 0usize, 1949 | concat!( 1950 | "Offset of field: ", 1951 | stringify!(bpf_tunnel_key__bindgen_ty_1), 1952 | "::", 1953 | stringify!(remote_ipv6) 1954 | ) 1955 | ); 1956 | } 1957 | impl Default for bpf_tunnel_key__bindgen_ty_1 { 1958 | fn default() -> Self { 1959 | unsafe { ::std::mem::zeroed() } 1960 | } 1961 | } 1962 | impl ::std::fmt::Debug for bpf_tunnel_key__bindgen_ty_1 { 1963 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1964 | write!(f, "bpf_tunnel_key__bindgen_ty_1 {{ union }}") 1965 | } 1966 | } 1967 | #[test] 1968 | fn bindgen_test_layout_bpf_tunnel_key() { 1969 | assert_eq!( 1970 | ::std::mem::size_of::(), 1971 | 28usize, 1972 | concat!("Size of: ", stringify!(bpf_tunnel_key)) 1973 | ); 1974 | assert_eq!( 1975 | ::std::mem::align_of::(), 1976 | 4usize, 1977 | concat!("Alignment of ", stringify!(bpf_tunnel_key)) 1978 | ); 1979 | assert_eq!( 1980 | unsafe { &(*(::std::ptr::null::())).tunnel_id as *const _ as usize }, 1981 | 0usize, 1982 | concat!( 1983 | "Offset of field: ", 1984 | stringify!(bpf_tunnel_key), 1985 | "::", 1986 | stringify!(tunnel_id) 1987 | ) 1988 | ); 1989 | assert_eq!( 1990 | unsafe { &(*(::std::ptr::null::())).tunnel_tos as *const _ as usize }, 1991 | 20usize, 1992 | concat!( 1993 | "Offset of field: ", 1994 | stringify!(bpf_tunnel_key), 1995 | "::", 1996 | stringify!(tunnel_tos) 1997 | ) 1998 | ); 1999 | assert_eq!( 2000 | unsafe { &(*(::std::ptr::null::())).tunnel_ttl as *const _ as usize }, 2001 | 21usize, 2002 | concat!( 2003 | "Offset of field: ", 2004 | stringify!(bpf_tunnel_key), 2005 | "::", 2006 | stringify!(tunnel_ttl) 2007 | ) 2008 | ); 2009 | assert_eq!( 2010 | unsafe { &(*(::std::ptr::null::())).tunnel_ext as *const _ as usize }, 2011 | 22usize, 2012 | concat!( 2013 | "Offset of field: ", 2014 | stringify!(bpf_tunnel_key), 2015 | "::", 2016 | stringify!(tunnel_ext) 2017 | ) 2018 | ); 2019 | assert_eq!( 2020 | unsafe { &(*(::std::ptr::null::())).tunnel_label as *const _ as usize }, 2021 | 24usize, 2022 | concat!( 2023 | "Offset of field: ", 2024 | stringify!(bpf_tunnel_key), 2025 | "::", 2026 | stringify!(tunnel_label) 2027 | ) 2028 | ); 2029 | } 2030 | impl Default for bpf_tunnel_key { 2031 | fn default() -> Self { 2032 | unsafe { ::std::mem::zeroed() } 2033 | } 2034 | } 2035 | impl ::std::fmt::Debug for bpf_tunnel_key { 2036 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 2037 | write ! ( f , "bpf_tunnel_key {{ tunnel_id: {:?}, __bindgen_anon_1: {:?}, tunnel_tos: {:?}, tunnel_ttl: {:?}, tunnel_ext: {:?}, tunnel_label: {:?} }}" , self . tunnel_id , self . __bindgen_anon_1 , self . tunnel_tos , self . tunnel_ttl , self . tunnel_ext , self . tunnel_label ) 2038 | } 2039 | } 2040 | pub const bpf_ret_code_BPF_OK: bpf_ret_code = 0; 2041 | pub const bpf_ret_code_BPF_DROP: bpf_ret_code = 2; 2042 | pub const bpf_ret_code_BPF_REDIRECT: bpf_ret_code = 7; 2043 | pub type bpf_ret_code = u32; 2044 | #[repr(C)] 2045 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2046 | pub struct bpf_sock { 2047 | pub bound_dev_if: __u32, 2048 | pub family: __u32, 2049 | pub type_: __u32, 2050 | pub protocol: __u32, 2051 | pub mark: __u32, 2052 | pub priority: __u32, 2053 | } 2054 | #[test] 2055 | fn bindgen_test_layout_bpf_sock() { 2056 | assert_eq!( 2057 | ::std::mem::size_of::(), 2058 | 24usize, 2059 | concat!("Size of: ", stringify!(bpf_sock)) 2060 | ); 2061 | assert_eq!( 2062 | ::std::mem::align_of::(), 2063 | 4usize, 2064 | concat!("Alignment of ", stringify!(bpf_sock)) 2065 | ); 2066 | assert_eq!( 2067 | unsafe { &(*(::std::ptr::null::())).bound_dev_if as *const _ as usize }, 2068 | 0usize, 2069 | concat!( 2070 | "Offset of field: ", 2071 | stringify!(bpf_sock), 2072 | "::", 2073 | stringify!(bound_dev_if) 2074 | ) 2075 | ); 2076 | assert_eq!( 2077 | unsafe { &(*(::std::ptr::null::())).family as *const _ as usize }, 2078 | 4usize, 2079 | concat!( 2080 | "Offset of field: ", 2081 | stringify!(bpf_sock), 2082 | "::", 2083 | stringify!(family) 2084 | ) 2085 | ); 2086 | assert_eq!( 2087 | unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, 2088 | 8usize, 2089 | concat!( 2090 | "Offset of field: ", 2091 | stringify!(bpf_sock), 2092 | "::", 2093 | stringify!(type_) 2094 | ) 2095 | ); 2096 | assert_eq!( 2097 | unsafe { &(*(::std::ptr::null::())).protocol as *const _ as usize }, 2098 | 12usize, 2099 | concat!( 2100 | "Offset of field: ", 2101 | stringify!(bpf_sock), 2102 | "::", 2103 | stringify!(protocol) 2104 | ) 2105 | ); 2106 | assert_eq!( 2107 | unsafe { &(*(::std::ptr::null::())).mark as *const _ as usize }, 2108 | 16usize, 2109 | concat!( 2110 | "Offset of field: ", 2111 | stringify!(bpf_sock), 2112 | "::", 2113 | stringify!(mark) 2114 | ) 2115 | ); 2116 | assert_eq!( 2117 | unsafe { &(*(::std::ptr::null::())).priority as *const _ as usize }, 2118 | 20usize, 2119 | concat!( 2120 | "Offset of field: ", 2121 | stringify!(bpf_sock), 2122 | "::", 2123 | stringify!(priority) 2124 | ) 2125 | ); 2126 | } 2127 | pub const xdp_action_XDP_ABORTED: xdp_action = 0; 2128 | pub const xdp_action_XDP_DROP: xdp_action = 1; 2129 | pub const xdp_action_XDP_PASS: xdp_action = 2; 2130 | pub const xdp_action_XDP_TX: xdp_action = 3; 2131 | pub const xdp_action_XDP_REDIRECT: xdp_action = 4; 2132 | pub type xdp_action = u32; 2133 | #[repr(C)] 2134 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2135 | pub struct xdp_md { 2136 | pub data: __u32, 2137 | pub data_end: __u32, 2138 | pub data_meta: __u32, 2139 | } 2140 | #[test] 2141 | fn bindgen_test_layout_xdp_md() { 2142 | assert_eq!( 2143 | ::std::mem::size_of::(), 2144 | 12usize, 2145 | concat!("Size of: ", stringify!(xdp_md)) 2146 | ); 2147 | assert_eq!( 2148 | ::std::mem::align_of::(), 2149 | 4usize, 2150 | concat!("Alignment of ", stringify!(xdp_md)) 2151 | ); 2152 | assert_eq!( 2153 | unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, 2154 | 0usize, 2155 | concat!( 2156 | "Offset of field: ", 2157 | stringify!(xdp_md), 2158 | "::", 2159 | stringify!(data) 2160 | ) 2161 | ); 2162 | assert_eq!( 2163 | unsafe { &(*(::std::ptr::null::())).data_end as *const _ as usize }, 2164 | 4usize, 2165 | concat!( 2166 | "Offset of field: ", 2167 | stringify!(xdp_md), 2168 | "::", 2169 | stringify!(data_end) 2170 | ) 2171 | ); 2172 | assert_eq!( 2173 | unsafe { &(*(::std::ptr::null::())).data_meta as *const _ as usize }, 2174 | 8usize, 2175 | concat!( 2176 | "Offset of field: ", 2177 | stringify!(xdp_md), 2178 | "::", 2179 | stringify!(data_meta) 2180 | ) 2181 | ); 2182 | } 2183 | pub const sk_action_SK_ABORTED: sk_action = 0; 2184 | pub const sk_action_SK_DROP: sk_action = 1; 2185 | pub const sk_action_SK_REDIRECT: sk_action = 2; 2186 | pub type sk_action = u32; 2187 | #[repr(C)] 2188 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2189 | pub struct bpf_prog_info { 2190 | pub type_: __u32, 2191 | pub id: __u32, 2192 | pub tag: [__u8; 8usize], 2193 | pub jited_prog_len: __u32, 2194 | pub xlated_prog_len: __u32, 2195 | pub jited_prog_insns: __u64, 2196 | pub xlated_prog_insns: __u64, 2197 | pub load_time: __u64, 2198 | pub created_by_uid: __u32, 2199 | pub nr_map_ids: __u32, 2200 | pub map_ids: __u64, 2201 | pub name: [::std::os::raw::c_char; 16usize], 2202 | } 2203 | #[test] 2204 | fn bindgen_test_layout_bpf_prog_info() { 2205 | assert_eq!( 2206 | ::std::mem::size_of::(), 2207 | 80usize, 2208 | concat!("Size of: ", stringify!(bpf_prog_info)) 2209 | ); 2210 | assert_eq!( 2211 | ::std::mem::align_of::(), 2212 | 8usize, 2213 | concat!("Alignment of ", stringify!(bpf_prog_info)) 2214 | ); 2215 | assert_eq!( 2216 | unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, 2217 | 0usize, 2218 | concat!( 2219 | "Offset of field: ", 2220 | stringify!(bpf_prog_info), 2221 | "::", 2222 | stringify!(type_) 2223 | ) 2224 | ); 2225 | assert_eq!( 2226 | unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, 2227 | 4usize, 2228 | concat!( 2229 | "Offset of field: ", 2230 | stringify!(bpf_prog_info), 2231 | "::", 2232 | stringify!(id) 2233 | ) 2234 | ); 2235 | assert_eq!( 2236 | unsafe { &(*(::std::ptr::null::())).tag as *const _ as usize }, 2237 | 8usize, 2238 | concat!( 2239 | "Offset of field: ", 2240 | stringify!(bpf_prog_info), 2241 | "::", 2242 | stringify!(tag) 2243 | ) 2244 | ); 2245 | assert_eq!( 2246 | unsafe { &(*(::std::ptr::null::())).jited_prog_len as *const _ as usize }, 2247 | 16usize, 2248 | concat!( 2249 | "Offset of field: ", 2250 | stringify!(bpf_prog_info), 2251 | "::", 2252 | stringify!(jited_prog_len) 2253 | ) 2254 | ); 2255 | assert_eq!( 2256 | unsafe { &(*(::std::ptr::null::())).xlated_prog_len as *const _ as usize }, 2257 | 20usize, 2258 | concat!( 2259 | "Offset of field: ", 2260 | stringify!(bpf_prog_info), 2261 | "::", 2262 | stringify!(xlated_prog_len) 2263 | ) 2264 | ); 2265 | assert_eq!( 2266 | unsafe { &(*(::std::ptr::null::())).jited_prog_insns as *const _ as usize }, 2267 | 24usize, 2268 | concat!( 2269 | "Offset of field: ", 2270 | stringify!(bpf_prog_info), 2271 | "::", 2272 | stringify!(jited_prog_insns) 2273 | ) 2274 | ); 2275 | assert_eq!( 2276 | unsafe { &(*(::std::ptr::null::())).xlated_prog_insns as *const _ as usize }, 2277 | 32usize, 2278 | concat!( 2279 | "Offset of field: ", 2280 | stringify!(bpf_prog_info), 2281 | "::", 2282 | stringify!(xlated_prog_insns) 2283 | ) 2284 | ); 2285 | assert_eq!( 2286 | unsafe { &(*(::std::ptr::null::())).load_time as *const _ as usize }, 2287 | 40usize, 2288 | concat!( 2289 | "Offset of field: ", 2290 | stringify!(bpf_prog_info), 2291 | "::", 2292 | stringify!(load_time) 2293 | ) 2294 | ); 2295 | assert_eq!( 2296 | unsafe { &(*(::std::ptr::null::())).created_by_uid as *const _ as usize }, 2297 | 48usize, 2298 | concat!( 2299 | "Offset of field: ", 2300 | stringify!(bpf_prog_info), 2301 | "::", 2302 | stringify!(created_by_uid) 2303 | ) 2304 | ); 2305 | assert_eq!( 2306 | unsafe { &(*(::std::ptr::null::())).nr_map_ids as *const _ as usize }, 2307 | 52usize, 2308 | concat!( 2309 | "Offset of field: ", 2310 | stringify!(bpf_prog_info), 2311 | "::", 2312 | stringify!(nr_map_ids) 2313 | ) 2314 | ); 2315 | assert_eq!( 2316 | unsafe { &(*(::std::ptr::null::())).map_ids as *const _ as usize }, 2317 | 56usize, 2318 | concat!( 2319 | "Offset of field: ", 2320 | stringify!(bpf_prog_info), 2321 | "::", 2322 | stringify!(map_ids) 2323 | ) 2324 | ); 2325 | assert_eq!( 2326 | unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, 2327 | 64usize, 2328 | concat!( 2329 | "Offset of field: ", 2330 | stringify!(bpf_prog_info), 2331 | "::", 2332 | stringify!(name) 2333 | ) 2334 | ); 2335 | } 2336 | #[repr(C)] 2337 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2338 | pub struct bpf_map_info { 2339 | pub type_: __u32, 2340 | pub id: __u32, 2341 | pub key_size: __u32, 2342 | pub value_size: __u32, 2343 | pub max_entries: __u32, 2344 | pub map_flags: __u32, 2345 | pub name: [::std::os::raw::c_char; 16usize], 2346 | pub __bindgen_align: [u64; 0usize], 2347 | } 2348 | #[test] 2349 | fn bindgen_test_layout_bpf_map_info() { 2350 | assert_eq!( 2351 | ::std::mem::size_of::(), 2352 | 40usize, 2353 | concat!("Size of: ", stringify!(bpf_map_info)) 2354 | ); 2355 | assert_eq!( 2356 | ::std::mem::align_of::(), 2357 | 8usize, 2358 | concat!("Alignment of ", stringify!(bpf_map_info)) 2359 | ); 2360 | assert_eq!( 2361 | unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, 2362 | 0usize, 2363 | concat!( 2364 | "Offset of field: ", 2365 | stringify!(bpf_map_info), 2366 | "::", 2367 | stringify!(type_) 2368 | ) 2369 | ); 2370 | assert_eq!( 2371 | unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, 2372 | 4usize, 2373 | concat!( 2374 | "Offset of field: ", 2375 | stringify!(bpf_map_info), 2376 | "::", 2377 | stringify!(id) 2378 | ) 2379 | ); 2380 | assert_eq!( 2381 | unsafe { &(*(::std::ptr::null::())).key_size as *const _ as usize }, 2382 | 8usize, 2383 | concat!( 2384 | "Offset of field: ", 2385 | stringify!(bpf_map_info), 2386 | "::", 2387 | stringify!(key_size) 2388 | ) 2389 | ); 2390 | assert_eq!( 2391 | unsafe { &(*(::std::ptr::null::())).value_size as *const _ as usize }, 2392 | 12usize, 2393 | concat!( 2394 | "Offset of field: ", 2395 | stringify!(bpf_map_info), 2396 | "::", 2397 | stringify!(value_size) 2398 | ) 2399 | ); 2400 | assert_eq!( 2401 | unsafe { &(*(::std::ptr::null::())).max_entries as *const _ as usize }, 2402 | 16usize, 2403 | concat!( 2404 | "Offset of field: ", 2405 | stringify!(bpf_map_info), 2406 | "::", 2407 | stringify!(max_entries) 2408 | ) 2409 | ); 2410 | assert_eq!( 2411 | unsafe { &(*(::std::ptr::null::())).map_flags as *const _ as usize }, 2412 | 20usize, 2413 | concat!( 2414 | "Offset of field: ", 2415 | stringify!(bpf_map_info), 2416 | "::", 2417 | stringify!(map_flags) 2418 | ) 2419 | ); 2420 | assert_eq!( 2421 | unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, 2422 | 24usize, 2423 | concat!( 2424 | "Offset of field: ", 2425 | stringify!(bpf_map_info), 2426 | "::", 2427 | stringify!(name) 2428 | ) 2429 | ); 2430 | } 2431 | #[repr(C)] 2432 | #[derive(Copy, Clone)] 2433 | pub struct bpf_sock_ops { 2434 | pub op: __u32, 2435 | pub __bindgen_anon_1: bpf_sock_ops__bindgen_ty_1, 2436 | pub family: __u32, 2437 | pub remote_ip4: __u32, 2438 | pub local_ip4: __u32, 2439 | pub remote_ip6: [__u32; 4usize], 2440 | pub local_ip6: [__u32; 4usize], 2441 | pub remote_port: __u32, 2442 | pub local_port: __u32, 2443 | } 2444 | #[repr(C)] 2445 | #[derive(Copy, Clone)] 2446 | pub union bpf_sock_ops__bindgen_ty_1 { 2447 | pub reply: __u32, 2448 | pub replylong: [__u32; 4usize], 2449 | _bindgen_union_align: [u32; 4usize], 2450 | } 2451 | #[test] 2452 | fn bindgen_test_layout_bpf_sock_ops__bindgen_ty_1() { 2453 | assert_eq!( 2454 | ::std::mem::size_of::(), 2455 | 16usize, 2456 | concat!("Size of: ", stringify!(bpf_sock_ops__bindgen_ty_1)) 2457 | ); 2458 | assert_eq!( 2459 | ::std::mem::align_of::(), 2460 | 4usize, 2461 | concat!("Alignment of ", stringify!(bpf_sock_ops__bindgen_ty_1)) 2462 | ); 2463 | assert_eq!( 2464 | unsafe { 2465 | &(*(::std::ptr::null::())).reply as *const _ as usize 2466 | }, 2467 | 0usize, 2468 | concat!( 2469 | "Offset of field: ", 2470 | stringify!(bpf_sock_ops__bindgen_ty_1), 2471 | "::", 2472 | stringify!(reply) 2473 | ) 2474 | ); 2475 | assert_eq!( 2476 | unsafe { 2477 | &(*(::std::ptr::null::())).replylong as *const _ as usize 2478 | }, 2479 | 0usize, 2480 | concat!( 2481 | "Offset of field: ", 2482 | stringify!(bpf_sock_ops__bindgen_ty_1), 2483 | "::", 2484 | stringify!(replylong) 2485 | ) 2486 | ); 2487 | } 2488 | impl Default for bpf_sock_ops__bindgen_ty_1 { 2489 | fn default() -> Self { 2490 | unsafe { ::std::mem::zeroed() } 2491 | } 2492 | } 2493 | impl ::std::fmt::Debug for bpf_sock_ops__bindgen_ty_1 { 2494 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 2495 | write!(f, "bpf_sock_ops__bindgen_ty_1 {{ union }}") 2496 | } 2497 | } 2498 | #[test] 2499 | fn bindgen_test_layout_bpf_sock_ops() { 2500 | assert_eq!( 2501 | ::std::mem::size_of::(), 2502 | 72usize, 2503 | concat!("Size of: ", stringify!(bpf_sock_ops)) 2504 | ); 2505 | assert_eq!( 2506 | ::std::mem::align_of::(), 2507 | 4usize, 2508 | concat!("Alignment of ", stringify!(bpf_sock_ops)) 2509 | ); 2510 | assert_eq!( 2511 | unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, 2512 | 0usize, 2513 | concat!( 2514 | "Offset of field: ", 2515 | stringify!(bpf_sock_ops), 2516 | "::", 2517 | stringify!(op) 2518 | ) 2519 | ); 2520 | assert_eq!( 2521 | unsafe { &(*(::std::ptr::null::())).family as *const _ as usize }, 2522 | 20usize, 2523 | concat!( 2524 | "Offset of field: ", 2525 | stringify!(bpf_sock_ops), 2526 | "::", 2527 | stringify!(family) 2528 | ) 2529 | ); 2530 | assert_eq!( 2531 | unsafe { &(*(::std::ptr::null::())).remote_ip4 as *const _ as usize }, 2532 | 24usize, 2533 | concat!( 2534 | "Offset of field: ", 2535 | stringify!(bpf_sock_ops), 2536 | "::", 2537 | stringify!(remote_ip4) 2538 | ) 2539 | ); 2540 | assert_eq!( 2541 | unsafe { &(*(::std::ptr::null::())).local_ip4 as *const _ as usize }, 2542 | 28usize, 2543 | concat!( 2544 | "Offset of field: ", 2545 | stringify!(bpf_sock_ops), 2546 | "::", 2547 | stringify!(local_ip4) 2548 | ) 2549 | ); 2550 | assert_eq!( 2551 | unsafe { &(*(::std::ptr::null::())).remote_ip6 as *const _ as usize }, 2552 | 32usize, 2553 | concat!( 2554 | "Offset of field: ", 2555 | stringify!(bpf_sock_ops), 2556 | "::", 2557 | stringify!(remote_ip6) 2558 | ) 2559 | ); 2560 | assert_eq!( 2561 | unsafe { &(*(::std::ptr::null::())).local_ip6 as *const _ as usize }, 2562 | 48usize, 2563 | concat!( 2564 | "Offset of field: ", 2565 | stringify!(bpf_sock_ops), 2566 | "::", 2567 | stringify!(local_ip6) 2568 | ) 2569 | ); 2570 | assert_eq!( 2571 | unsafe { &(*(::std::ptr::null::())).remote_port as *const _ as usize }, 2572 | 64usize, 2573 | concat!( 2574 | "Offset of field: ", 2575 | stringify!(bpf_sock_ops), 2576 | "::", 2577 | stringify!(remote_port) 2578 | ) 2579 | ); 2580 | assert_eq!( 2581 | unsafe { &(*(::std::ptr::null::())).local_port as *const _ as usize }, 2582 | 68usize, 2583 | concat!( 2584 | "Offset of field: ", 2585 | stringify!(bpf_sock_ops), 2586 | "::", 2587 | stringify!(local_port) 2588 | ) 2589 | ); 2590 | } 2591 | impl Default for bpf_sock_ops { 2592 | fn default() -> Self { 2593 | unsafe { ::std::mem::zeroed() } 2594 | } 2595 | } 2596 | impl ::std::fmt::Debug for bpf_sock_ops { 2597 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 2598 | write ! ( f , "bpf_sock_ops {{ op: {:?}, __bindgen_anon_1: {:?}, family: {:?}, remote_ip4: {:?}, local_ip4: {:?}, remote_ip6: {:?}, local_ip6: {:?}, remote_port: {:?}, local_port: {:?} }}" , self . op , self . __bindgen_anon_1 , self . family , self . remote_ip4 , self . local_ip4 , self . remote_ip6 , self . local_ip6 , self . remote_port , self . local_port ) 2599 | } 2600 | } 2601 | pub const BPF_SOCK_OPS_VOID: _bindgen_ty_2 = 0; 2602 | pub const BPF_SOCK_OPS_TIMEOUT_INIT: _bindgen_ty_2 = 1; 2603 | pub const BPF_SOCK_OPS_RWND_INIT: _bindgen_ty_2 = 2; 2604 | pub const BPF_SOCK_OPS_TCP_CONNECT_CB: _bindgen_ty_2 = 3; 2605 | pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: _bindgen_ty_2 = 4; 2606 | pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: _bindgen_ty_2 = 5; 2607 | pub const BPF_SOCK_OPS_NEEDS_ECN: _bindgen_ty_2 = 6; 2608 | pub type _bindgen_ty_2 = u32; 2609 | #[repr(C)] 2610 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2611 | pub struct bpf_perf_event_value { 2612 | pub counter: __u64, 2613 | pub enabled: __u64, 2614 | pub running: __u64, 2615 | } 2616 | #[test] 2617 | fn bindgen_test_layout_bpf_perf_event_value() { 2618 | assert_eq!( 2619 | ::std::mem::size_of::(), 2620 | 24usize, 2621 | concat!("Size of: ", stringify!(bpf_perf_event_value)) 2622 | ); 2623 | assert_eq!( 2624 | ::std::mem::align_of::(), 2625 | 8usize, 2626 | concat!("Alignment of ", stringify!(bpf_perf_event_value)) 2627 | ); 2628 | assert_eq!( 2629 | unsafe { &(*(::std::ptr::null::())).counter as *const _ as usize }, 2630 | 0usize, 2631 | concat!( 2632 | "Offset of field: ", 2633 | stringify!(bpf_perf_event_value), 2634 | "::", 2635 | stringify!(counter) 2636 | ) 2637 | ); 2638 | assert_eq!( 2639 | unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, 2640 | 8usize, 2641 | concat!( 2642 | "Offset of field: ", 2643 | stringify!(bpf_perf_event_value), 2644 | "::", 2645 | stringify!(enabled) 2646 | ) 2647 | ); 2648 | assert_eq!( 2649 | unsafe { &(*(::std::ptr::null::())).running as *const _ as usize }, 2650 | 16usize, 2651 | concat!( 2652 | "Offset of field: ", 2653 | stringify!(bpf_perf_event_value), 2654 | "::", 2655 | stringify!(running) 2656 | ) 2657 | ); 2658 | } 2659 | pub const bpf_probe_attach_type_BPF_PROBE_ENTRY: bpf_probe_attach_type = 0; 2660 | pub const bpf_probe_attach_type_BPF_PROBE_RETURN: bpf_probe_attach_type = 1; 2661 | pub type bpf_probe_attach_type = u32; 2662 | extern "C" { 2663 | pub fn bpf_create_map( 2664 | map_type: bpf_map_type, 2665 | key_size: ::std::os::raw::c_int, 2666 | value_size: ::std::os::raw::c_int, 2667 | max_entries: ::std::os::raw::c_int, 2668 | map_flags: ::std::os::raw::c_int, 2669 | ) -> ::std::os::raw::c_int; 2670 | } 2671 | extern "C" { 2672 | pub fn bpf_update_elem( 2673 | fd: ::std::os::raw::c_int, 2674 | key: *mut ::std::os::raw::c_void, 2675 | value: *mut ::std::os::raw::c_void, 2676 | flags: ::std::os::raw::c_ulonglong, 2677 | ) -> ::std::os::raw::c_int; 2678 | } 2679 | extern "C" { 2680 | pub fn bpf_lookup_elem( 2681 | fd: ::std::os::raw::c_int, 2682 | key: *mut ::std::os::raw::c_void, 2683 | value: *mut ::std::os::raw::c_void, 2684 | ) -> ::std::os::raw::c_int; 2685 | } 2686 | extern "C" { 2687 | pub fn bpf_delete_elem( 2688 | fd: ::std::os::raw::c_int, 2689 | key: *mut ::std::os::raw::c_void, 2690 | ) -> ::std::os::raw::c_int; 2691 | } 2692 | extern "C" { 2693 | pub fn bpf_get_first_key( 2694 | fd: ::std::os::raw::c_int, 2695 | key: *mut ::std::os::raw::c_void, 2696 | key_size: usize, 2697 | ) -> ::std::os::raw::c_int; 2698 | } 2699 | extern "C" { 2700 | pub fn bpf_get_next_key( 2701 | fd: ::std::os::raw::c_int, 2702 | key: *mut ::std::os::raw::c_void, 2703 | next_key: *mut ::std::os::raw::c_void, 2704 | ) -> ::std::os::raw::c_int; 2705 | } 2706 | extern "C" { 2707 | pub fn bpf_prog_load( 2708 | prog_type: bpf_prog_type, 2709 | insns: *const bpf_insn, 2710 | insn_len: ::std::os::raw::c_int, 2711 | license: *const ::std::os::raw::c_char, 2712 | kern_version: ::std::os::raw::c_uint, 2713 | log_buf: *mut ::std::os::raw::c_char, 2714 | log_buf_size: ::std::os::raw::c_uint, 2715 | ) -> ::std::os::raw::c_int; 2716 | } 2717 | extern "C" { 2718 | pub fn bpf_attach_socket( 2719 | sockfd: ::std::os::raw::c_int, 2720 | progfd: ::std::os::raw::c_int, 2721 | ) -> ::std::os::raw::c_int; 2722 | } 2723 | extern "C" { 2724 | pub fn bpf_open_raw_sock(name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 2725 | } 2726 | pub type perf_reader_cb = ::std::option::Option< 2727 | unsafe extern "C" fn( 2728 | cb_cookie: *mut ::std::os::raw::c_void, 2729 | pid: ::std::os::raw::c_int, 2730 | callchain_num: u64, 2731 | callchain: *mut ::std::os::raw::c_void, 2732 | ), 2733 | >; 2734 | pub type perf_reader_raw_cb = ::std::option::Option< 2735 | unsafe extern "C" fn( 2736 | cb_cookie: *mut ::std::os::raw::c_void, 2737 | raw: *mut ::std::os::raw::c_void, 2738 | raw_size: ::std::os::raw::c_int, 2739 | ), 2740 | >; 2741 | pub type perf_reader_lost_cb = ::std::option::Option; 2742 | extern "C" { 2743 | pub fn bpf_attach_kprobe( 2744 | progfd: ::std::os::raw::c_int, 2745 | attach_type: bpf_probe_attach_type, 2746 | ev_name: *const ::std::os::raw::c_char, 2747 | fn_name: *const ::std::os::raw::c_char, 2748 | pid: pid_t, 2749 | cpu: ::std::os::raw::c_int, 2750 | group_fd: ::std::os::raw::c_int, 2751 | cb: perf_reader_cb, 2752 | cb_cookie: *mut ::std::os::raw::c_void, 2753 | ) -> *mut ::std::os::raw::c_void; 2754 | } 2755 | extern "C" { 2756 | pub fn bpf_detach_kprobe(ev_name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 2757 | } 2758 | extern "C" { 2759 | pub fn bpf_attach_uprobe( 2760 | progfd: ::std::os::raw::c_int, 2761 | attach_type: bpf_probe_attach_type, 2762 | ev_name: *const ::std::os::raw::c_char, 2763 | binary_path: *const ::std::os::raw::c_char, 2764 | offset: u64, 2765 | pid: pid_t, 2766 | cpu: ::std::os::raw::c_int, 2767 | group_fd: ::std::os::raw::c_int, 2768 | cb: perf_reader_cb, 2769 | cb_cookie: *mut ::std::os::raw::c_void, 2770 | ) -> *mut ::std::os::raw::c_void; 2771 | } 2772 | extern "C" { 2773 | pub fn bpf_detach_uprobe(ev_name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 2774 | } 2775 | extern "C" { 2776 | pub fn bpf_attach_tracepoint( 2777 | progfd: ::std::os::raw::c_int, 2778 | tp_category: *const ::std::os::raw::c_char, 2779 | tp_name: *const ::std::os::raw::c_char, 2780 | pid: ::std::os::raw::c_int, 2781 | cpu: ::std::os::raw::c_int, 2782 | group_fd: ::std::os::raw::c_int, 2783 | cb: perf_reader_cb, 2784 | cb_cookie: *mut ::std::os::raw::c_void, 2785 | ) -> *mut ::std::os::raw::c_void; 2786 | } 2787 | extern "C" { 2788 | pub fn bpf_detach_tracepoint( 2789 | tp_category: *const ::std::os::raw::c_char, 2790 | tp_name: *const ::std::os::raw::c_char, 2791 | ) -> ::std::os::raw::c_int; 2792 | } 2793 | extern "C" { 2794 | pub fn bpf_open_perf_buffer( 2795 | raw_cb: perf_reader_raw_cb, 2796 | lost_cb: perf_reader_lost_cb, 2797 | cb_cookie: *mut ::std::os::raw::c_void, 2798 | pid: ::std::os::raw::c_int, 2799 | cpu: ::std::os::raw::c_int, 2800 | page_cnt: ::std::os::raw::c_int, 2801 | ) -> *mut ::std::os::raw::c_void; 2802 | } 2803 | extern "C" { 2804 | pub fn bpf_attach_xdp( 2805 | dev_name: *const ::std::os::raw::c_char, 2806 | progfd: ::std::os::raw::c_int, 2807 | flags: u32, 2808 | ) -> ::std::os::raw::c_int; 2809 | } 2810 | extern "C" { 2811 | pub fn bpf_attach_perf_event( 2812 | progfd: ::std::os::raw::c_int, 2813 | ev_type: u32, 2814 | ev_config: u32, 2815 | sample_period: u64, 2816 | sample_freq: u64, 2817 | pid: pid_t, 2818 | cpu: ::std::os::raw::c_int, 2819 | group_fd: ::std::os::raw::c_int, 2820 | ) -> ::std::os::raw::c_int; 2821 | } 2822 | extern "C" { 2823 | pub fn bpf_open_perf_event( 2824 | type_: u32, 2825 | config: u64, 2826 | pid: ::std::os::raw::c_int, 2827 | cpu: ::std::os::raw::c_int, 2828 | ) -> ::std::os::raw::c_int; 2829 | } 2830 | extern "C" { 2831 | pub fn bpf_close_perf_event_fd(fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int; 2832 | } 2833 | extern "C" { 2834 | pub fn bpf_obj_pin( 2835 | fd: ::std::os::raw::c_int, 2836 | pathname: *const ::std::os::raw::c_char, 2837 | ) -> ::std::os::raw::c_int; 2838 | } 2839 | extern "C" { 2840 | pub fn bpf_obj_get(pathname: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 2841 | } 2842 | extern "C" { 2843 | pub fn bpf_obj_get_info( 2844 | prog_map_fd: ::std::os::raw::c_int, 2845 | info: *mut ::std::os::raw::c_void, 2846 | info_len: *mut ::std::os::raw::c_int, 2847 | ) -> ::std::os::raw::c_int; 2848 | } 2849 | extern "C" { 2850 | pub fn bpf_prog_compute_tag( 2851 | insns: *const bpf_insn, 2852 | prog_len: ::std::os::raw::c_int, 2853 | tag: *mut ::std::os::raw::c_ulonglong, 2854 | ) -> ::std::os::raw::c_int; 2855 | } 2856 | extern "C" { 2857 | pub fn bpf_prog_get_tag( 2858 | fd: ::std::os::raw::c_int, 2859 | tag: *mut ::std::os::raw::c_ulonglong, 2860 | ) -> ::std::os::raw::c_int; 2861 | } 2862 | #[repr(C)] 2863 | #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2864 | pub struct bcc_symbol { 2865 | pub name: *const ::std::os::raw::c_char, 2866 | pub demangle_name: *const ::std::os::raw::c_char, 2867 | pub module: *const ::std::os::raw::c_char, 2868 | pub offset: u64, 2869 | } 2870 | #[test] 2871 | fn bindgen_test_layout_bcc_symbol() { 2872 | assert_eq!( 2873 | ::std::mem::size_of::(), 2874 | 32usize, 2875 | concat!("Size of: ", stringify!(bcc_symbol)) 2876 | ); 2877 | assert_eq!( 2878 | ::std::mem::align_of::(), 2879 | 8usize, 2880 | concat!("Alignment of ", stringify!(bcc_symbol)) 2881 | ); 2882 | assert_eq!( 2883 | unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, 2884 | 0usize, 2885 | concat!( 2886 | "Offset of field: ", 2887 | stringify!(bcc_symbol), 2888 | "::", 2889 | stringify!(name) 2890 | ) 2891 | ); 2892 | assert_eq!( 2893 | unsafe { &(*(::std::ptr::null::())).demangle_name as *const _ as usize }, 2894 | 8usize, 2895 | concat!( 2896 | "Offset of field: ", 2897 | stringify!(bcc_symbol), 2898 | "::", 2899 | stringify!(demangle_name) 2900 | ) 2901 | ); 2902 | assert_eq!( 2903 | unsafe { &(*(::std::ptr::null::())).module as *const _ as usize }, 2904 | 16usize, 2905 | concat!( 2906 | "Offset of field: ", 2907 | stringify!(bcc_symbol), 2908 | "::", 2909 | stringify!(module) 2910 | ) 2911 | ); 2912 | assert_eq!( 2913 | unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, 2914 | 24usize, 2915 | concat!( 2916 | "Offset of field: ", 2917 | stringify!(bcc_symbol), 2918 | "::", 2919 | stringify!(offset) 2920 | ) 2921 | ); 2922 | } 2923 | impl Default for bcc_symbol { 2924 | fn default() -> Self { 2925 | unsafe { ::std::mem::zeroed() } 2926 | } 2927 | } 2928 | pub type SYM_CB = ::std::option::Option< 2929 | unsafe extern "C" fn( 2930 | symname: *const ::std::os::raw::c_char, 2931 | addr: u64, 2932 | ) -> ::std::os::raw::c_int, 2933 | >; 2934 | #[repr(C)] 2935 | #[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 2936 | pub struct bcc_symbol_option { 2937 | pub use_debug_file: ::std::os::raw::c_int, 2938 | pub check_debug_file_crc: ::std::os::raw::c_int, 2939 | pub use_symbol_type: u32, 2940 | } 2941 | #[test] 2942 | fn bindgen_test_layout_bcc_symbol_option() { 2943 | assert_eq!( 2944 | ::std::mem::size_of::(), 2945 | 12usize, 2946 | concat!("Size of: ", stringify!(bcc_symbol_option)) 2947 | ); 2948 | assert_eq!( 2949 | ::std::mem::align_of::(), 2950 | 4usize, 2951 | concat!("Alignment of ", stringify!(bcc_symbol_option)) 2952 | ); 2953 | assert_eq!( 2954 | unsafe { 2955 | &(*(::std::ptr::null::())).use_debug_file as *const _ as usize 2956 | }, 2957 | 0usize, 2958 | concat!( 2959 | "Offset of field: ", 2960 | stringify!(bcc_symbol_option), 2961 | "::", 2962 | stringify!(use_debug_file) 2963 | ) 2964 | ); 2965 | assert_eq!( 2966 | unsafe { 2967 | &(*(::std::ptr::null::())).check_debug_file_crc as *const _ as usize 2968 | }, 2969 | 4usize, 2970 | concat!( 2971 | "Offset of field: ", 2972 | stringify!(bcc_symbol_option), 2973 | "::", 2974 | stringify!(check_debug_file_crc) 2975 | ) 2976 | ); 2977 | assert_eq!( 2978 | unsafe { 2979 | &(*(::std::ptr::null::())).use_symbol_type as *const _ as usize 2980 | }, 2981 | 8usize, 2982 | concat!( 2983 | "Offset of field: ", 2984 | stringify!(bcc_symbol_option), 2985 | "::", 2986 | stringify!(use_symbol_type) 2987 | ) 2988 | ); 2989 | } 2990 | extern "C" { 2991 | pub fn bcc_symcache_new( 2992 | pid: ::std::os::raw::c_int, 2993 | option: *mut bcc_symbol_option, 2994 | ) -> *mut ::std::os::raw::c_void; 2995 | } 2996 | extern "C" { 2997 | pub fn bcc_free_symcache(symcache: *mut ::std::os::raw::c_void, pid: ::std::os::raw::c_int); 2998 | } 2999 | extern "C" { 3000 | pub fn bcc_symbol_free_demangle_name(sym: *mut bcc_symbol); 3001 | } 3002 | extern "C" { 3003 | pub fn bcc_symcache_resolve( 3004 | symcache: *mut ::std::os::raw::c_void, 3005 | addr: u64, 3006 | sym: *mut bcc_symbol, 3007 | ) -> ::std::os::raw::c_int; 3008 | } 3009 | extern "C" { 3010 | pub fn bcc_symcache_resolve_no_demangle( 3011 | symcache: *mut ::std::os::raw::c_void, 3012 | addr: u64, 3013 | sym: *mut bcc_symbol, 3014 | ) -> ::std::os::raw::c_int; 3015 | } 3016 | extern "C" { 3017 | pub fn bcc_symcache_resolve_name( 3018 | resolver: *mut ::std::os::raw::c_void, 3019 | module: *const ::std::os::raw::c_char, 3020 | name: *const ::std::os::raw::c_char, 3021 | addr: *mut u64, 3022 | ) -> ::std::os::raw::c_int; 3023 | } 3024 | extern "C" { 3025 | pub fn bcc_symcache_refresh(resolver: *mut ::std::os::raw::c_void); 3026 | } 3027 | extern "C" { 3028 | pub fn bcc_resolve_global_addr( 3029 | pid: ::std::os::raw::c_int, 3030 | module: *const ::std::os::raw::c_char, 3031 | address: u64, 3032 | global: *mut u64, 3033 | ) -> ::std::os::raw::c_int; 3034 | } 3035 | extern "C" { 3036 | pub fn bcc_foreach_function_symbol( 3037 | module: *const ::std::os::raw::c_char, 3038 | cb: SYM_CB, 3039 | ) -> ::std::os::raw::c_int; 3040 | } 3041 | extern "C" { 3042 | pub fn bcc_resolve_symname( 3043 | module: *const ::std::os::raw::c_char, 3044 | symname: *const ::std::os::raw::c_char, 3045 | addr: u64, 3046 | pid: ::std::os::raw::c_int, 3047 | option: *mut bcc_symbol_option, 3048 | sym: *mut bcc_symbol, 3049 | ) -> ::std::os::raw::c_int; 3050 | } 3051 | #[repr(C)] 3052 | #[derive(Debug, Copy, Clone)] 3053 | pub struct perf_reader { 3054 | _unused: [u8; 0], 3055 | } 3056 | extern "C" { 3057 | pub fn perf_reader_new( 3058 | cb: perf_reader_cb, 3059 | raw_cb: perf_reader_raw_cb, 3060 | lost_cb: perf_reader_lost_cb, 3061 | cb_cookie: *mut ::std::os::raw::c_void, 3062 | page_cnt: ::std::os::raw::c_int, 3063 | ) -> *mut perf_reader; 3064 | } 3065 | extern "C" { 3066 | pub fn perf_reader_free(ptr: *mut ::std::os::raw::c_void); 3067 | } 3068 | extern "C" { 3069 | pub fn perf_reader_mmap( 3070 | reader: *mut perf_reader, 3071 | type_: ::std::os::raw::c_uint, 3072 | sample_type: ::std::os::raw::c_ulong, 3073 | ) -> ::std::os::raw::c_int; 3074 | } 3075 | extern "C" { 3076 | pub fn perf_reader_event_read(reader: *mut perf_reader); 3077 | } 3078 | extern "C" { 3079 | pub fn perf_reader_poll( 3080 | num_readers: ::std::os::raw::c_int, 3081 | readers: *mut *mut perf_reader, 3082 | timeout: ::std::os::raw::c_int, 3083 | ) -> ::std::os::raw::c_int; 3084 | } 3085 | extern "C" { 3086 | pub fn perf_reader_fd(reader: *mut perf_reader) -> ::std::os::raw::c_int; 3087 | } 3088 | extern "C" { 3089 | pub fn perf_reader_set_fd(reader: *mut perf_reader, fd: ::std::os::raw::c_int); 3090 | } 3091 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] 2 | 3 | pub mod bccapi; 4 | -------------------------------------------------------------------------------- /wrapper.h: -------------------------------------------------------------------------------- 1 | #ifdef __BCC_COMMON__ 2 | #include 3 | #endif 4 | 5 | #ifdef __BPF_COMMON__ 6 | #include 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | --------------------------------------------------------------------------------