Skip to content

Commit 8a0c9ea

Browse files
authored
Fix compilatino issues on raspberry pi. (#22)
1 parent 97bc15e commit 8a0c9ea

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/handle.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl Handle {
2626
pub fn live_capture(iface: &str) -> Result<std::sync::Arc<Handle>, Error> {
2727
let device_str = std::ffi::CString::new(iface).map_err(Error::Ffi)?;
2828

29-
let errbuf = ([0i8; 256]).as_mut_ptr();
30-
let h = unsafe { pcap_sys::pcap_create(device_str.as_ptr(), errbuf) };
29+
let errbuf = ([0 as std::os::raw::c_char; 256]).as_mut_ptr();
30+
let h = unsafe { pcap_sys::pcap_create(device_str.as_ptr() as _, errbuf) };
3131
let r = if h.is_null() {
3232
pcap_util::cstr_to_string(errbuf).and_then(|msg| {
3333
error!("Failed to create live stream: {}", msg);
@@ -58,10 +58,10 @@ impl Handle {
5858
};
5959
let device_str = std::ffi::CString::new(path).map_err(Error::Ffi)?;
6060

61-
let errbuf = ([0i8; 256]).as_mut_ptr();
62-
let h = unsafe { pcap_sys::pcap_open_offline(device_str.as_ptr(), errbuf) };
61+
let errbuf = ([0 as std::os::raw::c_char; 256]).as_mut_ptr();
62+
let h = unsafe { pcap_sys::pcap_open_offline(device_str.as_ptr() as _, errbuf) };
6363
let r = if h.is_null() {
64-
pcap_util::cstr_to_string(errbuf).and_then(|msg| {
64+
pcap_util::cstr_to_string(errbuf as _).and_then(|msg| {
6565
error!("Failed to create file stream: {}", msg);
6666
Err(Error::FileCapture {
6767
file: path.to_string(),
@@ -99,7 +99,7 @@ impl Handle {
9999
}
100100

101101
pub fn lookup() -> Result<std::sync::Arc<Handle>, Error> {
102-
let errbuf = ([0i8; 256]).as_mut_ptr();
102+
let errbuf = ([0 as std::os::raw::c_char; 256]).as_mut_ptr();
103103
let dev = unsafe { pcap_sys::pcap_lookupdev(errbuf) };
104104
let res = if dev.is_null() {
105105
pcap_util::cstr_to_string(errbuf as _).and_then(|msg| Err(Error::LibPcapError(msg)))
@@ -114,7 +114,7 @@ impl Handle {
114114
}
115115

116116
pub fn set_non_block(&self) -> Result<&Self, Error> {
117-
let errbuf = ([0i8; 256]).as_mut_ptr();
117+
let errbuf = ([0 as std::os::raw::c_char; 256]).as_mut_ptr();
118118
if -1 == unsafe { pcap_sys::pcap_setnonblock(self.handle, 1, errbuf) } {
119119
pcap_util::cstr_to_string(errbuf as _).and_then(|msg| {
120120
error!("Failed to set non block: {}", msg);

src/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct Info {
1010

1111
impl Info {
1212
pub fn all() -> Result<Vec<Info>, Error> {
13-
let mut err_buf = vec![0u8 as std::os::raw::c_char; pcap_sys::PCAP_ERRBUF_SIZE as _];
13+
let mut err_buf = vec![0 as std::os::raw::c_char; pcap_sys::PCAP_ERRBUF_SIZE as _];
1414
let mut device_result: *mut pcap_sys::pcap_if_t = std::ptr::null_mut();
1515

1616
unsafe {

src/pcap_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ pub fn convert_libpcap_error(handle: *mut pcap_sys::pcap_t) -> Error {
2525
}
2626

2727
#[inline]
28-
pub fn cstr_to_string(err: *mut libc::c_char) -> Result<String, Error> {
28+
pub fn cstr_to_string(err: *mut std::os::raw::c_char) -> Result<String, Error> {
2929
if err.is_null() {
3030
Err(Error::NullPtr)
3131
} else {
32-
unsafe { std::ffi::CStr::from_ptr(err as _) }
32+
unsafe { std::ffi::CStr::from_ptr(err) }
3333
.to_str()
3434
.map_err(Error::Utf8)
3535
.map(|s| s.to_owned())

0 commit comments

Comments
 (0)