Skip to content

Commit d51f0c3

Browse files
authored
Merge branch 'main' into add-daita-ui-part-ios-794
2 parents a0f226c + 18c61de commit d51f0c3

File tree

8 files changed

+65
-321
lines changed

8 files changed

+65
-321
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt

+1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ val appModule = module {
3737
single { ConnectionProxy(get(), get(), get()) }
3838
single { LocaleRepository(get()) }
3939
single { RelayLocationTranslationRepository(get(), get(), MainScope()) }
40+
single { androidContext().resources }
4041
}

android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ val uiModule = module {
103103
single { ApplicationsProvider(get(), get(named(SELF_PACKAGE_NAME))) }
104104
scope<MainActivity> { scoped { ServiceConnectionManager(androidContext()) } }
105105
single { InetAddressValidator.getInstance() }
106-
single { androidContext().resources }
107106
single { androidContext().assets }
108107
single { androidContext().contentResolver }
109108

talpid-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ system-configuration = "0.5.1"
5353
hickory-proto = "0.24.1"
5454
hickory-server = { version = "0.24.1", features = ["resolver"] }
5555
talpid-platform-metadata = { path = "../talpid-platform-metadata" }
56-
pcap = { version = "2.0", features = ["capture-stream"] }
56+
pcap = { version = "2.1", features = ["capture-stream"] }
5757
pnet_packet = "0.34"
5858
tun = { version = "0.5.5", features = ["async"] }
5959
nix = { version = "0.28", features = ["socket"] }
+53-271
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// automatically generated by rust-bindgen 0.69.2
1+
/* automatically generated by rust-bindgen 0.70.1 */
22

33
pub const PTH_FLAG_DIR_OUT: u32 = 2;
4-
pub const PCAP_ERRBUF_SIZE: u32 = 256;
54
pub type __int32_t = ::std::os::raw::c_int;
65
pub type __darwin_pid_t = __int32_t;
76
pub type __darwin_uuid_t = [::std::os::raw::c_uchar; 16usize];
@@ -12,41 +11,13 @@ pub struct timeval32 {
1211
pub tv_sec: __int32_t,
1312
pub tv_usec: __int32_t,
1413
}
15-
#[test]
16-
fn bindgen_test_layout_timeval32() {
17-
const UNINIT: ::std::mem::MaybeUninit<timeval32> = ::std::mem::MaybeUninit::uninit();
18-
let ptr = UNINIT.as_ptr();
19-
assert_eq!(
20-
::std::mem::size_of::<timeval32>(),
21-
8usize,
22-
concat!("Size of: ", stringify!(timeval32))
23-
);
24-
assert_eq!(
25-
::std::mem::align_of::<timeval32>(),
26-
4usize,
27-
concat!("Alignment of ", stringify!(timeval32))
28-
);
29-
assert_eq!(
30-
unsafe { ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize },
31-
0usize,
32-
concat!(
33-
"Offset of field: ",
34-
stringify!(timeval32),
35-
"::",
36-
stringify!(tv_sec)
37-
)
38-
);
39-
assert_eq!(
40-
unsafe { ::std::ptr::addr_of!((*ptr).tv_usec) as usize - ptr as usize },
41-
4usize,
42-
concat!(
43-
"Offset of field: ",
44-
stringify!(timeval32),
45-
"::",
46-
stringify!(tv_usec)
47-
)
48-
);
49-
}
14+
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
15+
const _: () = {
16+
["Size of timeval32"][::std::mem::size_of::<timeval32>() - 8usize];
17+
["Alignment of timeval32"][::std::mem::align_of::<timeval32>() - 4usize];
18+
["Offset of field: timeval32::tv_sec"][::std::mem::offset_of!(timeval32, tv_sec) - 0usize];
19+
["Offset of field: timeval32::tv_usec"][::std::mem::offset_of!(timeval32, tv_usec) - 4usize];
20+
};
5021
pub type uuid_t = __darwin_uuid_t;
5122
#[repr(C)]
5223
#[derive(Debug, Copy, Clone)]
@@ -72,237 +43,48 @@ pub struct pktap_header {
7243
pub pth_uuid: uuid_t,
7344
pub pth_euuid: uuid_t,
7445
}
75-
#[test]
76-
fn bindgen_test_layout_pktap_header() {
77-
const UNINIT: ::std::mem::MaybeUninit<pktap_header> = ::std::mem::MaybeUninit::uninit();
78-
let ptr = UNINIT.as_ptr();
79-
assert_eq!(
80-
::std::mem::size_of::<pktap_header>(),
81-
156usize,
82-
concat!("Size of: ", stringify!(pktap_header))
83-
);
84-
assert_eq!(
85-
::std::mem::align_of::<pktap_header>(),
86-
4usize,
87-
concat!("Alignment of ", stringify!(pktap_header))
88-
);
89-
assert_eq!(
90-
unsafe { ::std::ptr::addr_of!((*ptr).pth_length) as usize - ptr as usize },
91-
0usize,
92-
concat!(
93-
"Offset of field: ",
94-
stringify!(pktap_header),
95-
"::",
96-
stringify!(pth_length)
97-
)
98-
);
99-
assert_eq!(
100-
unsafe { ::std::ptr::addr_of!((*ptr).pth_type_next) as usize - ptr as usize },
101-
4usize,
102-
concat!(
103-
"Offset of field: ",
104-
stringify!(pktap_header),
105-
"::",
106-
stringify!(pth_type_next)
107-
)
108-
);
109-
assert_eq!(
110-
unsafe { ::std::ptr::addr_of!((*ptr).pth_dlt) as usize - ptr as usize },
111-
8usize,
112-
concat!(
113-
"Offset of field: ",
114-
stringify!(pktap_header),
115-
"::",
116-
stringify!(pth_dlt)
117-
)
118-
);
119-
assert_eq!(
120-
unsafe { ::std::ptr::addr_of!((*ptr).pth_ifname) as usize - ptr as usize },
121-
12usize,
122-
concat!(
123-
"Offset of field: ",
124-
stringify!(pktap_header),
125-
"::",
126-
stringify!(pth_ifname)
127-
)
128-
);
129-
assert_eq!(
130-
unsafe { ::std::ptr::addr_of!((*ptr).pth_flags) as usize - ptr as usize },
131-
36usize,
132-
concat!(
133-
"Offset of field: ",
134-
stringify!(pktap_header),
135-
"::",
136-
stringify!(pth_flags)
137-
)
138-
);
139-
assert_eq!(
140-
unsafe { ::std::ptr::addr_of!((*ptr).pth_protocol_family) as usize - ptr as usize },
141-
40usize,
142-
concat!(
143-
"Offset of field: ",
144-
stringify!(pktap_header),
145-
"::",
146-
stringify!(pth_protocol_family)
147-
)
148-
);
149-
assert_eq!(
150-
unsafe { ::std::ptr::addr_of!((*ptr).pth_frame_pre_length) as usize - ptr as usize },
151-
44usize,
152-
concat!(
153-
"Offset of field: ",
154-
stringify!(pktap_header),
155-
"::",
156-
stringify!(pth_frame_pre_length)
157-
)
158-
);
159-
assert_eq!(
160-
unsafe { ::std::ptr::addr_of!((*ptr).pth_frame_post_length) as usize - ptr as usize },
161-
48usize,
162-
concat!(
163-
"Offset of field: ",
164-
stringify!(pktap_header),
165-
"::",
166-
stringify!(pth_frame_post_length)
167-
)
168-
);
169-
assert_eq!(
170-
unsafe { ::std::ptr::addr_of!((*ptr).pth_pid) as usize - ptr as usize },
171-
52usize,
172-
concat!(
173-
"Offset of field: ",
174-
stringify!(pktap_header),
175-
"::",
176-
stringify!(pth_pid)
177-
)
178-
);
179-
assert_eq!(
180-
unsafe { ::std::ptr::addr_of!((*ptr).pth_comm) as usize - ptr as usize },
181-
56usize,
182-
concat!(
183-
"Offset of field: ",
184-
stringify!(pktap_header),
185-
"::",
186-
stringify!(pth_comm)
187-
)
188-
);
189-
assert_eq!(
190-
unsafe { ::std::ptr::addr_of!((*ptr).pth_svc) as usize - ptr as usize },
191-
76usize,
192-
concat!(
193-
"Offset of field: ",
194-
stringify!(pktap_header),
195-
"::",
196-
stringify!(pth_svc)
197-
)
198-
);
199-
assert_eq!(
200-
unsafe { ::std::ptr::addr_of!((*ptr).pth_iftype) as usize - ptr as usize },
201-
80usize,
202-
concat!(
203-
"Offset of field: ",
204-
stringify!(pktap_header),
205-
"::",
206-
stringify!(pth_iftype)
207-
)
208-
);
209-
assert_eq!(
210-
unsafe { ::std::ptr::addr_of!((*ptr).pth_ifunit) as usize - ptr as usize },
211-
82usize,
212-
concat!(
213-
"Offset of field: ",
214-
stringify!(pktap_header),
215-
"::",
216-
stringify!(pth_ifunit)
217-
)
218-
);
219-
assert_eq!(
220-
unsafe { ::std::ptr::addr_of!((*ptr).pth_epid) as usize - ptr as usize },
221-
84usize,
222-
concat!(
223-
"Offset of field: ",
224-
stringify!(pktap_header),
225-
"::",
226-
stringify!(pth_epid)
227-
)
228-
);
229-
assert_eq!(
230-
unsafe { ::std::ptr::addr_of!((*ptr).pth_ecomm) as usize - ptr as usize },
231-
88usize,
232-
concat!(
233-
"Offset of field: ",
234-
stringify!(pktap_header),
235-
"::",
236-
stringify!(pth_ecomm)
237-
)
238-
);
239-
assert_eq!(
240-
unsafe { ::std::ptr::addr_of!((*ptr).pth_flowid) as usize - ptr as usize },
241-
108usize,
242-
concat!(
243-
"Offset of field: ",
244-
stringify!(pktap_header),
245-
"::",
246-
stringify!(pth_flowid)
247-
)
248-
);
249-
assert_eq!(
250-
unsafe { ::std::ptr::addr_of!((*ptr).pth_ipproto) as usize - ptr as usize },
251-
112usize,
252-
concat!(
253-
"Offset of field: ",
254-
stringify!(pktap_header),
255-
"::",
256-
stringify!(pth_ipproto)
257-
)
258-
);
259-
assert_eq!(
260-
unsafe { ::std::ptr::addr_of!((*ptr).pth_tstamp) as usize - ptr as usize },
261-
116usize,
262-
concat!(
263-
"Offset of field: ",
264-
stringify!(pktap_header),
265-
"::",
266-
stringify!(pth_tstamp)
267-
)
268-
);
269-
assert_eq!(
270-
unsafe { ::std::ptr::addr_of!((*ptr).pth_uuid) as usize - ptr as usize },
271-
124usize,
272-
concat!(
273-
"Offset of field: ",
274-
stringify!(pktap_header),
275-
"::",
276-
stringify!(pth_uuid)
277-
)
278-
);
279-
assert_eq!(
280-
unsafe { ::std::ptr::addr_of!((*ptr).pth_euuid) as usize - ptr as usize },
281-
140usize,
282-
concat!(
283-
"Offset of field: ",
284-
stringify!(pktap_header),
285-
"::",
286-
stringify!(pth_euuid)
287-
)
288-
);
289-
}
290-
#[repr(C)]
291-
#[derive(Debug, Copy, Clone)]
292-
pub struct pcap {
293-
_unused: [u8; 0],
294-
}
295-
pub type pcap_t = pcap;
296-
extern "C" {
297-
pub fn pcap_create(
298-
arg1: *const ::std::os::raw::c_char,
299-
arg2: *mut ::std::os::raw::c_char,
300-
) -> *mut pcap_t;
301-
}
302-
extern "C" {
303-
pub fn pcap_set_want_pktap(
304-
arg1: *mut pcap_t,
305-
arg2: ::std::os::raw::c_int,
306-
) -> ::std::os::raw::c_int;
307-
}
308-
pub const BIOCSWANTPKTAP: u64 = 3221504639;
46+
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
47+
const _: () = {
48+
["Size of pktap_header"][::std::mem::size_of::<pktap_header>() - 156usize];
49+
["Alignment of pktap_header"][::std::mem::align_of::<pktap_header>() - 4usize];
50+
["Offset of field: pktap_header::pth_length"]
51+
[::std::mem::offset_of!(pktap_header, pth_length) - 0usize];
52+
["Offset of field: pktap_header::pth_type_next"]
53+
[::std::mem::offset_of!(pktap_header, pth_type_next) - 4usize];
54+
["Offset of field: pktap_header::pth_dlt"]
55+
[::std::mem::offset_of!(pktap_header, pth_dlt) - 8usize];
56+
["Offset of field: pktap_header::pth_ifname"]
57+
[::std::mem::offset_of!(pktap_header, pth_ifname) - 12usize];
58+
["Offset of field: pktap_header::pth_flags"]
59+
[::std::mem::offset_of!(pktap_header, pth_flags) - 36usize];
60+
["Offset of field: pktap_header::pth_protocol_family"]
61+
[::std::mem::offset_of!(pktap_header, pth_protocol_family) - 40usize];
62+
["Offset of field: pktap_header::pth_frame_pre_length"]
63+
[::std::mem::offset_of!(pktap_header, pth_frame_pre_length) - 44usize];
64+
["Offset of field: pktap_header::pth_frame_post_length"]
65+
[::std::mem::offset_of!(pktap_header, pth_frame_post_length) - 48usize];
66+
["Offset of field: pktap_header::pth_pid"]
67+
[::std::mem::offset_of!(pktap_header, pth_pid) - 52usize];
68+
["Offset of field: pktap_header::pth_comm"]
69+
[::std::mem::offset_of!(pktap_header, pth_comm) - 56usize];
70+
["Offset of field: pktap_header::pth_svc"]
71+
[::std::mem::offset_of!(pktap_header, pth_svc) - 76usize];
72+
["Offset of field: pktap_header::pth_iftype"]
73+
[::std::mem::offset_of!(pktap_header, pth_iftype) - 80usize];
74+
["Offset of field: pktap_header::pth_ifunit"]
75+
[::std::mem::offset_of!(pktap_header, pth_ifunit) - 82usize];
76+
["Offset of field: pktap_header::pth_epid"]
77+
[::std::mem::offset_of!(pktap_header, pth_epid) - 84usize];
78+
["Offset of field: pktap_header::pth_ecomm"]
79+
[::std::mem::offset_of!(pktap_header, pth_ecomm) - 88usize];
80+
["Offset of field: pktap_header::pth_flowid"]
81+
[::std::mem::offset_of!(pktap_header, pth_flowid) - 108usize];
82+
["Offset of field: pktap_header::pth_ipproto"]
83+
[::std::mem::offset_of!(pktap_header, pth_ipproto) - 112usize];
84+
["Offset of field: pktap_header::pth_tstamp"]
85+
[::std::mem::offset_of!(pktap_header, pth_tstamp) - 116usize];
86+
["Offset of field: pktap_header::pth_uuid"]
87+
[::std::mem::offset_of!(pktap_header, pth_uuid) - 124usize];
88+
["Offset of field: pktap_header::pth_euuid"]
89+
[::std::mem::offset_of!(pktap_header, pth_euuid) - 140usize];
90+
};

talpid-core/src/split_tunnel/macos/bpf.rs

-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use std::{
2222
};
2323
use tokio::io::{unix::AsyncFd, AsyncRead, Interest, ReadBuf};
2424

25-
use super::bindings::BIOCSWANTPKTAP;
26-
2725
#[derive(thiserror::Error, Debug)]
2826
pub enum Error {
2927
/// Failed to open BPF device
@@ -167,12 +165,6 @@ impl Bpf {
167165
unsafe { ioctl!(self.file.as_raw_fd(), BIOCSHDRCMPLT, &enable) }
168166
}
169167

170-
pub fn set_want_pktap(&self, enable: bool) -> Result<(), Error> {
171-
let enable: c_int = if enable { 1 } else { 0 };
172-
// SAFETY: The fd is valid for the lifetime of `self`
173-
unsafe { ioctl!(self.file.as_raw_fd(), BIOCSWANTPKTAP, &enable) }
174-
}
175-
176168
pub fn set_buffer_size(&self, mut buffer_size: c_uint) -> Result<usize, Error> {
177169
// SAFETY: The fd is valid for the lifetime of `self`
178170
unsafe {

0 commit comments

Comments
 (0)