• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_applicable_licenses: ["external_libpcap_license"],
3}
4
5license {
6    name: "external_libpcap_license",
7    visibility: [":__subpackages__"],
8    license_kinds: [
9        "SPDX-license-identifier-Apache-2.0",
10        "SPDX-license-identifier-BSD",
11        "SPDX-license-identifier-ISC",
12        "SPDX-license-identifier-MIT",
13    ],
14    license_text: [
15        "LICENSE",
16        "NOTICE",
17    ],
18}
19
20cc_defaults {
21    name: "libpcap_defaults",
22    cflags: [
23        "-D_BSD_SOURCE",
24        "-DHAVE_CONFIG_H",
25        "-Dlint",
26        "-D_U_=__attribute__((__unused__))",
27        "-Wall",
28        "-Werror",
29        "-Wno-macro-redefined",
30        "-Wno-pointer-arith",
31        "-Wno-sign-compare",
32        "-Wno-unused-parameter",
33        "-Wno-unused-result",
34        "-Wno-tautological-compare",
35    ],
36}
37
38cc_library {
39    name: "libpcap",
40    host_supported: true,
41    vendor_available: true,
42    // Build against the NDK 29 because it's used by the network stack mainline module tests, which
43    // need to support Q.
44    // TODO(b/148792341): stop hardcoding sdk_version integers in libraries all over the tree and
45    // define a min_apex_sdk_version property that all module code can use.
46    sdk_version: "29",
47    defaults: ["libpcap_defaults"],
48
49    // (Matches order in libpcap's Makefile.)
50    srcs: [
51        "pcap-linux.c",
52        "pcap-usb-linux.c",
53        "pcap-netfilter-linux-android.c",
54        "fad-getad.c",
55        "pcap.c",
56        "gencode.c",
57        "optimize.c",
58        "nametoaddr.c",
59        "etherent.c",
60        "fmtutils.c",
61        "savefile.c",
62        "sf-pcap.c",
63        "sf-pcapng.c",
64        "pcap-common.c",
65        "bpf_image.c",
66        "bpf_filter.c",
67        "bpf_dump.c",
68        "scanner.c",
69        "grammar.c",
70    ],
71
72    target: {
73        linux: {
74            srcs: [
75                "missing/strlcpy.c",
76            ],
77        },
78        darwin: {
79            enabled: false,
80        },
81    },
82
83    export_include_dirs: ["."],
84}
85
86//
87// Tests.
88//
89
90cc_test {
91    name: "libpcap_test",
92    defaults: ["libpcap_defaults"],
93    gtest: false,
94    // (Matches order in libpcap's Makefile.)
95    srcs: [
96        "testprogs/can_set_rfmon_test.c",
97        "testprogs/capturetest.c",
98        "testprogs/filtertest.c",
99        "testprogs/findalldevstest.c",
100        "testprogs/opentest.c",
101        "testprogs/reactivatetest.c",
102        "testprogs/selpolltest.c",
103        "testprogs/threadsignaltest.c",
104        "testprogs/valgrindtest.c",
105    ],
106    static_libs: ["libpcap"],
107    test_per_src: true,
108}
109