}
d = &d[1..];
}
- Err(Err::Incomplete(Needed::new(2 as usize - d.len())))
+ Err(Err::Incomplete(Needed::new(2_usize - d.len())))
}
/// Makes a call to the nom parser for parsing DCERPC Header.
let mut consumed = 0;
while !cur_i.is_empty() {
if cur_i.len() == 1 {
- return AppLayerResult::incomplete(consumed as u32, 2 as u32);
+ return AppLayerResult::incomplete(consumed as u32, 2_u32);
}
let size = match be_u16(cur_i) as IResult<&[u8],u16> {
Ok((_, len)) => len,
let mut consumed = 0;
while !cur_i.is_empty() {
if cur_i.len() == 1 {
- return AppLayerResult::incomplete(consumed as u32, 2 as u32);
+ return AppLayerResult::incomplete(consumed as u32, 2_u32);
}
let size = match be_u16(cur_i) as IResult<&[u8],u16> {
Ok((_, len)) => len,
/// If gap_size > 0 'data' should not be used.
/// return how much we consumed of data
pub fn update(&mut self, files: &mut FileContainer, flags: u16, data: &[u8], gap_size: u32) -> u32 {
- let mut consumed = 0 as usize;
+ let mut consumed = 0_usize;
let is_gap = gap_size > 0;
if is_gap || gap_size > 0 {
SCLogDebug!("is_gap {} size {} ooo? {}", is_gap, gap_size, self.chunk_is_ooo);
fn http2_tx_get_next_priority(
tx: &mut HTTP2Transaction, direction: Direction, nb: u32,
) -> std::os::raw::c_int {
- let mut pos = 0 as u32;
+ let mut pos = 0_u32;
if direction == Direction::ToServer {
for i in 0..tx.frames_ts.len() {
match &tx.frames_ts[i].data {
fn http2_tx_get_next_window(
tx: &mut HTTP2Transaction, direction: Direction, nb: u32,
) -> std::os::raw::c_int {
- let mut pos = 0 as u32;
+ let mut pos = 0_u32;
if direction == Direction::ToServer {
for i in 0..tx.frames_ts.len() {
match tx.frames_ts[i].data {
pub unsafe extern "C" fn rs_http2_tx_get_header_name(
tx: &mut HTTP2Transaction, direction: u8, nb: u32, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
- let mut pos = 0 as u32;
+ let mut pos = 0_u32;
match direction.into() {
Direction::ToServer => {
for i in 0..tx.frames_ts.len() {
pub unsafe extern "C" fn rs_http2_tx_get_header(
tx: &mut HTTP2Transaction, direction: u8, nb: u32, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
- let mut pos = 0 as u32;
+ let mut pos = 0_u32;
match direction.into() {
Direction::ToServer => {
for i in 0..tx.frames_ts.len() {
self.progress = HTTP2ConnectionState::Http2StateMagicDone;
} else {
//still more buffer
- return AppLayerResult::incomplete(0 as u32, HTTP2_MAGIC_LEN as u32);
+ return AppLayerResult::incomplete(0_u32, HTTP2_MAGIC_LEN as u32);
}
}
//first consume frame bytes
// cut off final eof field
let d = if rd.data.len() >= 4 {
- &rd.data[..rd.data.len()-4 as usize]
+ &rd.data[..rd.data.len()-4_usize]
} else {
rd.data
};
let (r, attr) = nfs4_parse_attrbits(&buf[4..]).unwrap();
assert_eq!(r.len(), 0);
// assert_eq!(attr.attr_mask, 35618163785728);
- assert_eq!(attr.attr_mask, ((0x00002065 as u64) << 32 | 0 as u64));
+ assert_eq!(attr.attr_mask, (0x00002065_u64 << 32 | 0_u64));
}
#[test]
fn test_nfs4_response_compound() {
SCLogDebug!("lets first see if we have prior data");
// msg_id 0 as this data crosses cmd/reply pairs
let ehdr = SMBHashKeyHdrGuid::new(SMBCommonHdr::new(SMBHDR_TYPE_TRANS_FRAG,
- hdr.ssn_id as u64, hdr.tree_id as u32, 0 as u64), guid.to_vec());
+ hdr.ssn_id as u64, hdr.tree_id as u32, 0_u64), guid.to_vec());
let mut prevdata = match state.ssnguid2vec_map.remove(&ehdr) {
Some(s) => s,
None => Vec::new(),
fn add_nbss_ts_frames(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8], nbss_len: i64) -> (Option<Frame>, Option<Frame>, Option<Frame>) {
let nbss_pdu = Frame::new(flow, stream_slice, input, nbss_len + 4, SMBFrameType::NBSSPdu as u8);
SCLogDebug!("NBSS PDU frame {:?}", nbss_pdu);
- let nbss_hdr_frame = Frame::new(flow, stream_slice, input, 4 as i64, SMBFrameType::NBSSHdr as u8);
+ let nbss_hdr_frame = Frame::new(flow, stream_slice, input, 4_i64, SMBFrameType::NBSSHdr as u8);
SCLogDebug!("NBSS HDR frame {:?}", nbss_hdr_frame);
let nbss_data_frame = Frame::new(flow, stream_slice, &input[4..], nbss_len, SMBFrameType::NBSSData as u8);
SCLogDebug!("NBSS DATA frame {:?}", nbss_data_frame);
smb_pdu
}
fn add_smb1_ts_hdr_data_frames(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8], nbss_len: i64) {
- let _smb1_hdr = Frame::new(flow, stream_slice, input, 32 as i64, SMBFrameType::SMB1Hdr as u8);
+ let _smb1_hdr = Frame::new(flow, stream_slice, input, 32_i64, SMBFrameType::SMB1Hdr as u8);
SCLogDebug!("SMBv1 HDR frame {:?}", _smb1_hdr);
if input.len() > 32 {
let _smb1_data = Frame::new(flow, stream_slice, &input[32..], (nbss_len - 32) as i64, SMBFrameType::SMB1Data as u8);
smb_pdu
}
fn add_smb3_ts_hdr_data_frames(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8], nbss_len: i64) {
- let _smb3_hdr = Frame::new(flow, stream_slice, input, 52 as i64, SMBFrameType::SMB3Hdr as u8);
+ let _smb3_hdr = Frame::new(flow, stream_slice, input, 52_i64, SMBFrameType::SMB3Hdr as u8);
SCLogDebug!("SMBv3 HDR frame {:?}", _smb3_hdr);
if input.len() > 52 {
let _smb3_data = Frame::new(flow, stream_slice, &input[52..], (nbss_len - 52) as i64, SMBFrameType::SMB3Data as u8);
fn add_nbss_tc_frames(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8], nbss_len: i64) -> (Option<Frame>, Option<Frame>, Option<Frame>) {
let nbss_pdu = Frame::new(flow, stream_slice, input, nbss_len + 4, SMBFrameType::NBSSPdu as u8);
SCLogDebug!("NBSS PDU frame {:?}", nbss_pdu);
- let nbss_hdr_frame = Frame::new(flow, stream_slice, input, 4 as i64, SMBFrameType::NBSSHdr as u8);
+ let nbss_hdr_frame = Frame::new(flow, stream_slice, input, 4_i64, SMBFrameType::NBSSHdr as u8);
SCLogDebug!("NBSS HDR frame {:?}", nbss_hdr_frame);
let nbss_data_frame = Frame::new(flow, stream_slice, &input[4..], nbss_len, SMBFrameType::NBSSData as u8);
SCLogDebug!("NBSS DATA frame {:?}", nbss_data_frame);
SCLogDebug!("SMBv3 PDU frame {:?}", _smb_pdu);
}
fn add_smb3_tc_hdr_data_frames(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8], nbss_len: i64) {
- let _smb3_hdr = Frame::new(flow, stream_slice, input, 52 as i64, SMBFrameType::SMB3Hdr as u8);
+ let _smb3_hdr = Frame::new(flow, stream_slice, input, 52_i64, SMBFrameType::SMB3Hdr as u8);
SCLogDebug!("SMBv3 HDR frame {:?}", _smb3_hdr);
if input.len() > 52 {
let _smb3_data = Frame::new(flow, stream_slice, &input[52..], (nbss_len - 52) as i64, SMBFrameType::SMB3Data as u8);
fn smb_basic_search(d: &[u8]) -> usize {
let needle = b"SMB";
- let mut r = 0 as usize;
+ let mut r = 0_usize;
// this could be replaced by aho-corasick
let iter = d.windows(needle.len());
for window in iter {
}
d = &d[index + 3..];
}
- Err(Err::Incomplete(Needed::new(4 as usize - d.len())))
+ Err(Err::Incomplete(Needed::new(4_usize - d.len())))
}
return r;
}
Err(Err::Incomplete(_)) => {
- return AppLayerResult::incomplete(0 as u32, (input.len() + 1) as u32);
+ return AppLayerResult::incomplete(0_u32, (input.len() + 1) as u32);
}
Err(_e) => {
SCLogDebug!("SSH invalid banner {}", _e);
Err(Err::Incomplete(_)) => {
if input.len() < SSH_MAX_BANNER_LEN {
//0 consumed, needs at least one more byte
- return AppLayerResult::incomplete(0 as u32, (input.len() + 1) as u32);
+ return AppLayerResult::incomplete(0_u32, (input.len() + 1) as u32);
} else {
SCLogDebug!(
"SSH banner too long {} vs {} and waiting for eol",
flow,
stream_slice,
start,
- -1 as i64,
+ -1_i64,
TelnetFrameType::Pdu as u8,
);
}
flow,
stream_slice,
start,
- -1 as i64,
+ -1_i64,
TelnetFrameType::Ctl as u8,
)
} else {
flow,
stream_slice,
start,
- -1 as i64,
+ -1_i64,
TelnetFrameType::Data as u8,
)
// app-layer-frame-documentation tag end: parse_request
let mut start = input;
while !start.is_empty() {
if self.response_frame.is_none() {
- self.response_frame = Frame::new(flow, stream_slice, start, -1 as i64, TelnetFrameType::Pdu as u8);
+ self.response_frame = Frame::new(flow, stream_slice, start, -1_i64, TelnetFrameType::Pdu as u8);
}
if self.response_specific_frame.is_none() {
if let Ok((_, is_ctl)) = parser::peek_message_is_ctl(start) {
self.response_specific_frame = if is_ctl {
- Frame::new(flow, stream_slice, start, -1 as i64, TelnetFrameType::Ctl as u8)
+ Frame::new(flow, stream_slice, start, -1_i64, TelnetFrameType::Ctl as u8)
} else {
- Frame::new(flow, stream_slice, start, -1 as i64, TelnetFrameType::Data as u8)
+ Frame::new(flow, stream_slice, start, -1_i64, TelnetFrameType::Data as u8)
};
}
}