From: Victor Julien Date: Thu, 28 Mar 2019 10:51:43 +0000 (+0100) Subject: rust/mingw: fix missing IPPROTO_* declarations X-Git-Tag: suricata-5.0.0-beta1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0301ceab136b8b4624dce956a1f083bf951ad7bc;p=thirdparty%2Fsuricata.git rust/mingw: fix missing IPPROTO_* declarations The libc crate doesn't provide these on MinGW, so define them in our 'core' instead. We only use IPPROTO_TCP and IPPROTO_UDP. Bug #2733 --- diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index fdfab3cd5a..bfa1a2409e 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -16,7 +16,7 @@ */ use std; -use core::{self, ALPROTO_UNKNOWN, AppProto, Flow}; +use core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP}; use libc; use log::*; use std::mem::transmute; @@ -515,7 +515,7 @@ pub unsafe extern "C" fn rs_template_register_parser() { let parser = RustParser { name: PARSER_NAME.as_ptr() as *const libc::c_char, default_port: default_port.as_ptr(), - ipproto: libc::IPPROTO_TCP, + ipproto: IPPROTO_TCP, probe_ts: rs_template_probing_parser, probe_tc: rs_template_probing_parser, min_depth: 0, diff --git a/rust/src/core.rs b/rust/src/core.rs index c529f57d19..bf334b0cae 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -46,6 +46,9 @@ pub type AppProto = libc::c_int; pub const ALPROTO_UNKNOWN : AppProto = 0; pub static mut ALPROTO_FAILED : AppProto = 0; // updated during init +pub const IPPROTO_TCP : i32 = 6; +pub const IPPROTO_UDP : i32 = 17; + macro_rules!BIT_U64 { ($x:expr) => (1 << $x); } diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 5f22f8c2bc..21e99fc329 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -17,7 +17,7 @@ use applayer; use core; -use core::{ALPROTO_UNKNOWN, AppProto, Flow}; +use core::{ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_UDP}; use core::{sc_detect_engine_state_free, sc_app_layer_decoder_events_free_events}; use dhcp::parser::*; use libc; @@ -400,7 +400,7 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() { let parser = RustParser { name: PARSER_NAME.as_ptr() as *const libc::c_char, default_port: ports.as_ptr(), - ipproto: libc::IPPROTO_UDP, + ipproto: IPPROTO_UDP, probe_ts: rs_dhcp_probing_parser, probe_tc: rs_dhcp_probing_parser, min_depth: 0, diff --git a/rust/src/ikev2/ikev2.rs b/rust/src/ikev2/ikev2.rs index dcbf581f26..c0dfc97827 100644 --- a/rust/src/ikev2/ikev2.rs +++ b/rust/src/ikev2/ikev2.rs @@ -666,7 +666,7 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() { let parser = RustParser { name : PARSER_NAME.as_ptr() as *const libc::c_char, default_port : default_port.as_ptr(), - ipproto : libc::IPPROTO_UDP, + ipproto : core::IPPROTO_UDP, probe_ts : rs_ikev2_probing_parser, probe_tc : rs_ikev2_probing_parser, min_depth : 0, diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index bab1e584ec..d997c56258 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -617,7 +617,7 @@ pub unsafe extern "C" fn rs_register_krb5_parser() { let mut parser = RustParser { name : PARSER_NAME.as_ptr() as *const libc::c_char, default_port : default_port.as_ptr(), - ipproto : libc::IPPROTO_UDP, + ipproto : core::IPPROTO_UDP, probe_ts : rs_krb5_probing_parser, probe_tc : rs_krb5_probing_parser, min_depth : 0, @@ -657,7 +657,7 @@ pub unsafe extern "C" fn rs_register_krb5_parser() { SCLogDebug!("Protocol detecter and parser disabled for KRB5/UDP."); } // register TCP parser - parser.ipproto = libc::IPPROTO_TCP; + parser.ipproto = core::IPPROTO_TCP; parser.probe_ts = rs_krb5_probing_parser_tcp; parser.probe_tc = rs_krb5_probing_parser_tcp; parser.parse_ts = rs_krb5_parse_request_tcp; diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index 0d449f3f95..f88e125994 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -375,7 +375,7 @@ pub unsafe extern "C" fn rs_register_ntp_parser() { let parser = RustParser { name : PARSER_NAME.as_ptr() as *const libc::c_char, default_port : default_port.as_ptr(), - ipproto : libc::IPPROTO_UDP, + ipproto : core::IPPROTO_UDP, probe_ts : ntp_probing_parser, probe_tc : ntp_probing_parser, min_depth : 0, diff --git a/rust/src/parser.rs b/rust/src/parser.rs index ab2efec695..1f9102bf8d 100644 --- a/rust/src/parser.rs +++ b/rust/src/parser.rs @@ -33,7 +33,7 @@ pub struct RustParser { /// Default port pub default_port: *const c_char, - /// IP Protocol (libc::IPPROTO_UDP, libc::IPPROTO_TCP, etc.) + /// IP Protocol (core::IPPROTO_UDP, core::IPPROTO_TCP, etc.) pub ipproto: c_int, /// Probing function, for packets going to server