rust/clippy: fix lint: upper_case_acronyms

pull/8251/head
Jason Ish 4 years ago committed by Victor Julien
parent 029ac650d7
commit 7ba2dadc7f

@ -80,23 +80,23 @@ impl Read for HTTP2cursor {
} }
pub enum HTTP2Decompresser { pub enum HTTP2Decompresser {
UNASSIGNED, Unassigned,
// Box because large. // Box because large.
GZIP(Box<GzDecoder<HTTP2cursor>>), Gzip(Box<GzDecoder<HTTP2cursor>>),
// Box because large. // Box because large.
BROTLI(Box<brotli::Decompressor<HTTP2cursor>>), Brotli(Box<brotli::Decompressor<HTTP2cursor>>),
// This one is not so large, at 88 bytes as of doing this, but box // This one is not so large, at 88 bytes as of doing this, but box
// for consistency. // for consistency.
DEFLATE(Box<DeflateDecoder<HTTP2cursor>>), Deflate(Box<DeflateDecoder<HTTP2cursor>>),
} }
impl std::fmt::Debug for HTTP2Decompresser { impl std::fmt::Debug for HTTP2Decompresser {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self { match self {
HTTP2Decompresser::UNASSIGNED => write!(f, "UNASSIGNED"), HTTP2Decompresser::Unassigned => write!(f, "UNASSIGNED"),
HTTP2Decompresser::GZIP(_) => write!(f, "GZIP"), HTTP2Decompresser::Gzip(_) => write!(f, "GZIP"),
HTTP2Decompresser::BROTLI(_) => write!(f, "BROTLI"), HTTP2Decompresser::Brotli(_) => write!(f, "BROTLI"),
HTTP2Decompresser::DEFLATE(_) => write!(f, "DEFLATE"), HTTP2Decompresser::Deflate(_) => write!(f, "DEFLATE"),
} }
} }
} }
@ -169,7 +169,7 @@ impl HTTP2DecoderHalf {
pub fn new() -> HTTP2DecoderHalf { pub fn new() -> HTTP2DecoderHalf {
HTTP2DecoderHalf { HTTP2DecoderHalf {
encoding: HTTP2ContentEncoding::Unknown, encoding: HTTP2ContentEncoding::Unknown,
decoder: HTTP2Decompresser::UNASSIGNED, decoder: HTTP2Decompresser::Unassigned,
} }
} }
@ -178,13 +178,13 @@ impl HTTP2DecoderHalf {
if self.encoding == HTTP2ContentEncoding::Unknown { if self.encoding == HTTP2ContentEncoding::Unknown {
if input == b"gzip" { if input == b"gzip" {
self.encoding = HTTP2ContentEncoding::Gzip; self.encoding = HTTP2ContentEncoding::Gzip;
self.decoder = HTTP2Decompresser::GZIP(Box::new(GzDecoder::new(HTTP2cursor::new()))); self.decoder = HTTP2Decompresser::Gzip(Box::new(GzDecoder::new(HTTP2cursor::new())));
} else if input == b"deflate" { } else if input == b"deflate" {
self.encoding = HTTP2ContentEncoding::Deflate; self.encoding = HTTP2ContentEncoding::Deflate;
self.decoder = HTTP2Decompresser::DEFLATE(Box::new(DeflateDecoder::new(HTTP2cursor::new()))); self.decoder = HTTP2Decompresser::Deflate(Box::new(DeflateDecoder::new(HTTP2cursor::new())));
} else if input == b"br" { } else if input == b"br" {
self.encoding = HTTP2ContentEncoding::Br; self.encoding = HTTP2ContentEncoding::Br;
self.decoder = HTTP2Decompresser::BROTLI(Box::new(brotli::Decompressor::new( self.decoder = HTTP2Decompresser::Brotli(Box::new(brotli::Decompressor::new(
HTTP2cursor::new(), HTTP2cursor::new(),
HTTP2_DECOMPRESSION_CHUNK_SIZE, HTTP2_DECOMPRESSION_CHUNK_SIZE,
))); )));
@ -198,24 +198,24 @@ impl HTTP2DecoderHalf {
&mut self, input: &'a [u8], output: &'a mut Vec<u8>, &mut self, input: &'a [u8], output: &'a mut Vec<u8>,
) -> io::Result<&'a [u8]> { ) -> io::Result<&'a [u8]> {
match self.decoder { match self.decoder {
HTTP2Decompresser::GZIP(ref mut gzip_decoder) => { HTTP2Decompresser::Gzip(ref mut gzip_decoder) => {
let r = http2_decompress(&mut *gzip_decoder.as_mut(), input, output); let r = http2_decompress(&mut *gzip_decoder.as_mut(), input, output);
if r.is_err() { if r.is_err() {
self.decoder = HTTP2Decompresser::UNASSIGNED; self.decoder = HTTP2Decompresser::Unassigned;
} }
return r; return r;
} }
HTTP2Decompresser::BROTLI(ref mut br_decoder) => { HTTP2Decompresser::Brotli(ref mut br_decoder) => {
let r = http2_decompress(&mut *br_decoder.as_mut(), input, output); let r = http2_decompress(&mut *br_decoder.as_mut(), input, output);
if r.is_err() { if r.is_err() {
self.decoder = HTTP2Decompresser::UNASSIGNED; self.decoder = HTTP2Decompresser::Unassigned;
} }
return r; return r;
} }
HTTP2Decompresser::DEFLATE(ref mut df_decoder) => { HTTP2Decompresser::Deflate(ref mut df_decoder) => {
let r = http2_decompress(&mut *df_decoder.as_mut(), input, output); let r = http2_decompress(&mut *df_decoder.as_mut(), input, output);
if r.is_err() { if r.is_err() {
self.decoder = HTTP2Decompresser::UNASSIGNED; self.decoder = HTTP2Decompresser::Unassigned;
} }
return r; return r;
} }

@ -841,7 +841,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_header(
fn http2_tx_set_header(state: &mut HTTP2State, name: &[u8], input: &[u8]) { fn http2_tx_set_header(state: &mut HTTP2State, name: &[u8], input: &[u8]) {
let head = parser::HTTP2FrameHeader { let head = parser::HTTP2FrameHeader {
length: 0, length: 0,
ftype: parser::HTTP2FrameType::HEADERS as u8, ftype: parser::HTTP2FrameType::Headers as u8,
flags: 0, flags: 0,
reserved: 0, reserved: 0,
stream_id: 1, stream_id: 1,
@ -894,7 +894,7 @@ fn http2_tx_set_settings(state: &mut HTTP2State, input: &[u8]) {
let head = parser::HTTP2FrameHeader { let head = parser::HTTP2FrameHeader {
length: dec.len() as u32, length: dec.len() as u32,
ftype: parser::HTTP2FrameType::SETTINGS as u8, ftype: parser::HTTP2FrameType::Settings as u8,
flags: 0, flags: 0,
reserved: 0, reserved: 0,
stream_id: 0, stream_id: 0,
@ -997,7 +997,7 @@ mod tests {
let mut tx = HTTP2Transaction::new(); let mut tx = HTTP2Transaction::new();
let head = parser::HTTP2FrameHeader { let head = parser::HTTP2FrameHeader {
length: 0, length: 0,
ftype: parser::HTTP2FrameType::HEADERS as u8, ftype: parser::HTTP2FrameType::Headers as u8,
flags: 0, flags: 0,
reserved: 0, reserved: 0,
stream_id: 1, stream_id: 1,

@ -346,7 +346,7 @@ impl HTTP2Transaction {
} }
} }
} }
} else if header.ftype == parser::HTTP2FrameType::DATA as u8 { } else if header.ftype == parser::HTTP2FrameType::Data as u8 {
//not end of stream //not end of stream
if dir == Direction::ToServer { if dir == Direction::ToServer {
if self.state < HTTP2TransactionState::HTTP2StateDataClient { if self.state < HTTP2TransactionState::HTTP2StateDataClient {
@ -595,9 +595,9 @@ impl HTTP2State {
if index > 0 { if index > 0 {
if self.transactions[index - 1].state == HTTP2TransactionState::HTTP2StateClosed { if self.transactions[index - 1].state == HTTP2TransactionState::HTTP2StateClosed {
//these frames can be received in this state for a short period //these frames can be received in this state for a short period
if header.ftype != parser::HTTP2FrameType::RSTSTREAM as u8 if header.ftype != parser::HTTP2FrameType::RstStream as u8
&& header.ftype != parser::HTTP2FrameType::WINDOWUPDATE as u8 && header.ftype != parser::HTTP2FrameType::WindowUpdate as u8
&& header.ftype != parser::HTTP2FrameType::PRIORITY as u8 && header.ftype != parser::HTTP2FrameType::Priority as u8
{ {
self.set_event(HTTP2Event::StreamIdReuse); self.set_event(HTTP2Event::StreamIdReuse);
} }
@ -666,7 +666,7 @@ impl HTTP2State {
&mut self, ftype: u8, input: &[u8], complete: bool, hflags: u8, dir: Direction, &mut self, ftype: u8, input: &[u8], complete: bool, hflags: u8, dir: Direction,
) -> HTTP2FrameTypeData { ) -> HTTP2FrameTypeData {
match num::FromPrimitive::from_u8(ftype) { match num::FromPrimitive::from_u8(ftype) {
Some(parser::HTTP2FrameType::GOAWAY) => { Some(parser::HTTP2FrameType::GoAway) => {
if input.len() < HTTP2_FRAME_GOAWAY_LEN { if input.len() < HTTP2_FRAME_GOAWAY_LEN {
self.set_event(HTTP2Event::InvalidFrameLength); self.set_event(HTTP2Event::InvalidFrameLength);
return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled { return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled {
@ -685,11 +685,11 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::SETTINGS) => { Some(parser::HTTP2FrameType::Settings) => {
match parser::http2_parse_frame_settings(input) { match parser::http2_parse_frame_settings(input) {
Ok((_, set)) => { Ok((_, set)) => {
for e in &set { for e in &set {
if e.id == parser::HTTP2SettingsId::SETTINGSHEADERTABLESIZE { if e.id == parser::HTTP2SettingsId::HeaderTableSize {
//reverse order as this is what we accept from the other endpoint //reverse order as this is what we accept from the other endpoint
let dyn_headers = if dir == Direction::ToClient { let dyn_headers = if dir == Direction::ToClient {
&mut self.dynamic_headers_ts &mut self.dynamic_headers_ts
@ -729,7 +729,7 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::RSTSTREAM) => { Some(parser::HTTP2FrameType::RstStream) => {
if input.len() != HTTP2_FRAME_RSTSTREAM_LEN { if input.len() != HTTP2_FRAME_RSTSTREAM_LEN {
self.set_event(HTTP2Event::InvalidFrameLength); self.set_event(HTTP2Event::InvalidFrameLength);
return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled { return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled {
@ -749,7 +749,7 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::PRIORITY) => { Some(parser::HTTP2FrameType::Priority) => {
if input.len() != HTTP2_FRAME_PRIORITY_LEN { if input.len() != HTTP2_FRAME_PRIORITY_LEN {
self.set_event(HTTP2Event::InvalidFrameLength); self.set_event(HTTP2Event::InvalidFrameLength);
return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled { return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled {
@ -769,7 +769,7 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::WINDOWUPDATE) => { Some(parser::HTTP2FrameType::WindowUpdate) => {
if input.len() != HTTP2_FRAME_WINDOWUPDATE_LEN { if input.len() != HTTP2_FRAME_WINDOWUPDATE_LEN {
self.set_event(HTTP2Event::InvalidFrameLength); self.set_event(HTTP2Event::InvalidFrameLength);
return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled { return HTTP2FrameTypeData::UNHANDLED(HTTP2FrameUnhandled {
@ -789,7 +789,7 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::PUSHPROMISE) => { Some(parser::HTTP2FrameType::PushPromise) => {
let dyn_headers = if dir == Direction::ToClient { let dyn_headers = if dir == Direction::ToClient {
&mut self.dynamic_headers_tc &mut self.dynamic_headers_tc
} else { } else {
@ -820,10 +820,10 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::DATA) => { Some(parser::HTTP2FrameType::Data) => {
return HTTP2FrameTypeData::DATA; return HTTP2FrameTypeData::DATA;
} }
Some(parser::HTTP2FrameType::CONTINUATION) => { Some(parser::HTTP2FrameType::Continuation) => {
let dyn_headers = if dir == Direction::ToClient { let dyn_headers = if dir == Direction::ToClient {
&mut self.dynamic_headers_tc &mut self.dynamic_headers_tc
} else { } else {
@ -854,7 +854,7 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::HEADERS) => { Some(parser::HTTP2FrameType::Headers) => {
let dyn_headers = if dir == Direction::ToClient { let dyn_headers = if dir == Direction::ToClient {
&mut self.dynamic_headers_tc &mut self.dynamic_headers_tc
} else { } else {
@ -889,7 +889,7 @@ impl HTTP2State {
} }
} }
} }
Some(parser::HTTP2FrameType::PING) => { Some(parser::HTTP2FrameType::Ping) => {
return HTTP2FrameTypeData::PING; return HTTP2FrameTypeData::PING;
} }
_ => { _ => {
@ -934,7 +934,7 @@ impl HTTP2State {
(hl, true) (hl, true)
}; };
if head.length == 0 && head.ftype == parser::HTTP2FrameType::SETTINGS as u8 { if head.length == 0 && head.ftype == parser::HTTP2FrameType::Settings as u8 {
input = &rem[hlsafe..]; input = &rem[hlsafe..];
continue; continue;
} }
@ -963,7 +963,7 @@ impl HTTP2State {
data: txdata, data: txdata,
}); });
} }
if ftype == parser::HTTP2FrameType::DATA as u8 { if ftype == parser::HTTP2FrameType::Data as u8 {
match unsafe { SURICATA_HTTP2_FILE_CONFIG } { match unsafe { SURICATA_HTTP2_FILE_CONFIG } {
Some(sfcm) => { Some(sfcm) => {
//borrow checker forbids to reuse directly tx //borrow checker forbids to reuse directly tx
@ -1095,7 +1095,7 @@ pub unsafe extern "C" fn rs_http2_probing_parser_tc(
if header.reserved != 0 if header.reserved != 0
|| header.length > HTTP2_DEFAULT_MAX_FRAME_SIZE || header.length > HTTP2_DEFAULT_MAX_FRAME_SIZE
|| header.flags & 0xFE != 0 || header.flags & 0xFE != 0
|| header.ftype != parser::HTTP2FrameType::SETTINGS as u8 || header.ftype != parser::HTTP2FrameType::Settings as u8
{ {
return ALPROTO_FAILED; return ALPROTO_FAILED;
} }

@ -112,7 +112,7 @@ fn log_http2_frames(frames: &[HTTP2Frame], js: &mut JsonBuilder) -> Result<bool,
} }
for e in set { for e in set {
js.start_object()?; js.start_object()?;
js.set_string("settings_id", &e.id.to_string())?; js.set_string("settings_id", &format!("SETTINGS{}", &e.id.to_string().to_uppercase()))?;
js.set_uint("settings_value", e.value as u64)?; js.set_uint("settings_value", e.value as u64)?;
js.close()?; js.close()?;
} }
@ -133,7 +133,7 @@ fn log_http2_frames(frames: &[HTTP2Frame], js: &mut JsonBuilder) -> Result<bool,
num::FromPrimitive::from_u32(goaway.errorcode); num::FromPrimitive::from_u32(goaway.errorcode);
match errcode { match errcode {
Some(errstr) => { Some(errstr) => {
js.set_string("error_code", &errstr.to_string())?; js.set_string("error_code", &errstr.to_string().to_uppercase())?;
} }
None => { None => {
//use uint32 //use uint32

@ -34,16 +34,16 @@ use std::str::FromStr;
#[repr(u8)] #[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)] #[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)]
pub enum HTTP2FrameType { pub enum HTTP2FrameType {
DATA = 0, Data = 0,
HEADERS = 1, Headers = 1,
PRIORITY = 2, Priority = 2,
RSTSTREAM = 3, RstStream = 3,
SETTINGS = 4, Settings = 4,
PUSHPROMISE = 5, PushPromise = 5,
PING = 6, Ping = 6,
GOAWAY = 7, GoAway = 7,
WINDOWUPDATE = 8, WindowUpdate = 8,
CONTINUATION = 9, Continuation = 9,
} }
impl fmt::Display for HTTP2FrameType { impl fmt::Display for HTTP2FrameType {
@ -59,16 +59,16 @@ impl std::str::FromStr for HTTP2FrameType {
let su = s.to_uppercase(); let su = s.to_uppercase();
let su_slice: &str = &su; let su_slice: &str = &su;
match su_slice { match su_slice {
"DATA" => Ok(HTTP2FrameType::DATA), "DATA" => Ok(HTTP2FrameType::Data),
"HEADERS" => Ok(HTTP2FrameType::HEADERS), "HEADERS" => Ok(HTTP2FrameType::Headers),
"PRIORITY" => Ok(HTTP2FrameType::PRIORITY), "PRIORITY" => Ok(HTTP2FrameType::Priority),
"RSTSTREAM" => Ok(HTTP2FrameType::RSTSTREAM), "RSTSTREAM" => Ok(HTTP2FrameType::RstStream),
"SETTINGS" => Ok(HTTP2FrameType::SETTINGS), "SETTINGS" => Ok(HTTP2FrameType::Settings),
"PUSHPROMISE" => Ok(HTTP2FrameType::PUSHPROMISE), "PUSHPROMISE" => Ok(HTTP2FrameType::PushPromise),
"PING" => Ok(HTTP2FrameType::PING), "PING" => Ok(HTTP2FrameType::Ping),
"GOAWAY" => Ok(HTTP2FrameType::GOAWAY), "GOAWAY" => Ok(HTTP2FrameType::GoAway),
"WINDOWUPDATE" => Ok(HTTP2FrameType::WINDOWUPDATE), "WINDOWUPDATE" => Ok(HTTP2FrameType::WindowUpdate),
"CONTINUATION" => Ok(HTTP2FrameType::CONTINUATION), "CONTINUATION" => Ok(HTTP2FrameType::Continuation),
_ => Err(format!("'{}' is not a valid value for HTTP2FrameType", s)), _ => Err(format!("'{}' is not a valid value for HTTP2FrameType", s)),
} }
} }
@ -105,20 +105,20 @@ pub fn http2_parse_frame_header(i: &[u8]) -> IResult<&[u8], HTTP2FrameHeader> {
#[repr(u32)] #[repr(u32)]
#[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)] #[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)]
pub enum HTTP2ErrorCode { pub enum HTTP2ErrorCode {
NOERROR = 0, NoError = 0,
PROTOCOLERROR = 1, ProtocolError = 1,
INTERNALERROR = 2, InternalError = 2,
FLOWCONTROLERROR = 3, FlowControlError = 3,
SETTINGSTIMEOUT = 4, SettingsTimeout = 4,
STREAMCLOSED = 5, StreamClosed = 5,
FRAMESIZEERROR = 6, FrameSizeError = 6,
REFUSEDSTREAM = 7, RefusedStream = 7,
CANCEL = 8, Cancel = 8,
COMPRESSIONERROR = 9, CompressionError = 9,
CONNECTERROR = 10, ConnectError = 10,
ENHANCEYOURCALM = 11, EnhanceYourCalm = 11,
INADEQUATESECURITY = 12, InadequateSecurity = 12,
HTTP11REQUIRED = 13, Http11Required = 13,
} }
impl fmt::Display for HTTP2ErrorCode { impl fmt::Display for HTTP2ErrorCode {
@ -134,19 +134,19 @@ impl std::str::FromStr for HTTP2ErrorCode {
let su = s.to_uppercase(); let su = s.to_uppercase();
let su_slice: &str = &su; let su_slice: &str = &su;
match su_slice { match su_slice {
"NO_ERROR" => Ok(HTTP2ErrorCode::NOERROR), "NO_ERROR" => Ok(HTTP2ErrorCode::NoError),
"PROTOCOL_ERROR" => Ok(HTTP2ErrorCode::PROTOCOLERROR), "PROTOCOL_ERROR" => Ok(HTTP2ErrorCode::ProtocolError),
"FLOW_CONTROL_ERROR" => Ok(HTTP2ErrorCode::FLOWCONTROLERROR), "FLOW_CONTROL_ERROR" => Ok(HTTP2ErrorCode::FlowControlError),
"SETTINGS_TIMEOUT" => Ok(HTTP2ErrorCode::SETTINGSTIMEOUT), "SETTINGS_TIMEOUT" => Ok(HTTP2ErrorCode::SettingsTimeout),
"STREAM_CLOSED" => Ok(HTTP2ErrorCode::STREAMCLOSED), "STREAM_CLOSED" => Ok(HTTP2ErrorCode::StreamClosed),
"FRAME_SIZE_ERROR" => Ok(HTTP2ErrorCode::FRAMESIZEERROR), "FRAME_SIZE_ERROR" => Ok(HTTP2ErrorCode::FrameSizeError),
"REFUSED_STREAM" => Ok(HTTP2ErrorCode::REFUSEDSTREAM), "REFUSED_STREAM" => Ok(HTTP2ErrorCode::RefusedStream),
"CANCEL" => Ok(HTTP2ErrorCode::CANCEL), "CANCEL" => Ok(HTTP2ErrorCode::Cancel),
"COMPRESSION_ERROR" => Ok(HTTP2ErrorCode::COMPRESSIONERROR), "COMPRESSION_ERROR" => Ok(HTTP2ErrorCode::CompressionError),
"CONNECT_ERROR" => Ok(HTTP2ErrorCode::CONNECTERROR), "CONNECT_ERROR" => Ok(HTTP2ErrorCode::ConnectError),
"ENHANCE_YOUR_CALM" => Ok(HTTP2ErrorCode::ENHANCEYOURCALM), "ENHANCE_YOUR_CALM" => Ok(HTTP2ErrorCode::EnhanceYourCalm),
"INADEQUATE_SECURITY" => Ok(HTTP2ErrorCode::INADEQUATESECURITY), "INADEQUATE_SECURITY" => Ok(HTTP2ErrorCode::InadequateSecurity),
"HTTP_1_1_REQUIRED" => Ok(HTTP2ErrorCode::HTTP11REQUIRED), "HTTP_1_1_REQUIRED" => Ok(HTTP2ErrorCode::Http11Required),
_ => Err(format!("'{}' is not a valid value for HTTP2ErrorCode", s)), _ => Err(format!("'{}' is not a valid value for HTTP2ErrorCode", s)),
} }
} }
@ -683,12 +683,12 @@ pub fn http2_parse_frame_continuation<'a>(
#[repr(u16)] #[repr(u16)]
#[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)] #[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)]
pub enum HTTP2SettingsId { pub enum HTTP2SettingsId {
SETTINGSHEADERTABLESIZE = 1, HeaderTableSize = 1,
SETTINGSENABLEPUSH = 2, EnablePush = 2,
SETTINGSMAXCONCURRENTSTREAMS = 3, MaxConcurrentStreams = 3,
SETTINGSINITIALWINDOWSIZE = 4, InitialWindowSize = 4,
SETTINGSMAXFRAMESIZE = 5, MaxFrameSize = 5,
SETTINGSMAXHEADERLISTSIZE = 6, MaxHeaderListSize = 6,
} }
impl fmt::Display for HTTP2SettingsId { impl fmt::Display for HTTP2SettingsId {
@ -704,12 +704,12 @@ impl std::str::FromStr for HTTP2SettingsId {
let su = s.to_uppercase(); let su = s.to_uppercase();
let su_slice: &str = &su; let su_slice: &str = &su;
match su_slice { match su_slice {
"SETTINGS_HEADER_TABLE_SIZE" => Ok(HTTP2SettingsId::SETTINGSHEADERTABLESIZE), "SETTINGS_HEADER_TABLE_SIZE" => Ok(HTTP2SettingsId::HeaderTableSize),
"SETTINGS_ENABLE_PUSH" => Ok(HTTP2SettingsId::SETTINGSENABLEPUSH), "SETTINGS_ENABLE_PUSH" => Ok(HTTP2SettingsId::EnablePush),
"SETTINGS_MAX_CONCURRENT_STREAMS" => Ok(HTTP2SettingsId::SETTINGSMAXCONCURRENTSTREAMS), "SETTINGS_MAX_CONCURRENT_STREAMS" => Ok(HTTP2SettingsId::MaxConcurrentStreams),
"SETTINGS_INITIAL_WINDOW_SIZE" => Ok(HTTP2SettingsId::SETTINGSINITIALWINDOWSIZE), "SETTINGS_INITIAL_WINDOW_SIZE" => Ok(HTTP2SettingsId::InitialWindowSize),
"SETTINGS_MAX_FRAME_SIZE" => Ok(HTTP2SettingsId::SETTINGSMAXFRAMESIZE), "SETTINGS_MAX_FRAME_SIZE" => Ok(HTTP2SettingsId::MaxFrameSize),
"SETTINGS_MAX_HEADER_LIST_SIZE" => Ok(HTTP2SettingsId::SETTINGSMAXHEADERLISTSIZE), "SETTINGS_MAX_HEADER_LIST_SIZE" => Ok(HTTP2SettingsId::MaxHeaderListSize),
_ => Err(format!("'{}' is not a valid value for HTTP2SettingsId", s)), _ => Err(format!("'{}' is not a valid value for HTTP2SettingsId", s)),
} }
} }
@ -872,7 +872,7 @@ mod tests {
let r = http2_parse_settingsctx(s); let r = http2_parse_settingsctx(s);
match r { match r {
Ok((rem, ctx)) => { Ok((rem, ctx)) => {
assert_eq!(ctx.id, HTTP2SettingsId::SETTINGSENABLEPUSH); assert_eq!(ctx.id, HTTP2SettingsId::EnablePush);
match ctx.value { match ctx.value {
Some(_) => { Some(_) => {
panic!("Unexpected value"); panic!("Unexpected value");
@ -891,7 +891,7 @@ mod tests {
let r1 = http2_parse_settingsctx(s1); let r1 = http2_parse_settingsctx(s1);
match r1 { match r1 {
Ok((rem, ctx)) => { Ok((rem, ctx)) => {
assert_eq!(ctx.id, HTTP2SettingsId::SETTINGSENABLEPUSH); assert_eq!(ctx.id, HTTP2SettingsId::EnablePush);
if ctx.value.is_some() { if ctx.value.is_some() {
panic!("Unexpected value"); panic!("Unexpected value");
} }
@ -906,7 +906,7 @@ mod tests {
let r2 = http2_parse_settingsctx(s2); let r2 = http2_parse_settingsctx(s2);
match r2 { match r2 {
Ok((rem, ctx)) => { Ok((rem, ctx)) => {
assert_eq!(ctx.id, HTTP2SettingsId::SETTINGSMAXCONCURRENTSTREAMS); assert_eq!(ctx.id, HTTP2SettingsId::MaxConcurrentStreams);
match ctx.value { match ctx.value {
Some(ctxval) => { Some(ctxval) => {
assert_eq!(ctxval.arg1, 42); assert_eq!(ctxval.arg1, 42);
@ -926,7 +926,7 @@ mod tests {
let r3 = http2_parse_settingsctx(s3); let r3 = http2_parse_settingsctx(s3);
match r3 { match r3 {
Ok((rem, ctx)) => { Ok((rem, ctx)) => {
assert_eq!(ctx.id, HTTP2SettingsId::SETTINGSMAXCONCURRENTSTREAMS); assert_eq!(ctx.id, HTTP2SettingsId::MaxConcurrentStreams);
match ctx.value { match ctx.value {
Some(ctxval) => { Some(ctxval) => {
assert_eq!(ctxval.arg1, 42); assert_eq!(ctxval.arg1, 42);
@ -948,7 +948,7 @@ mod tests {
let r4 = http2_parse_settingsctx(s4); let r4 = http2_parse_settingsctx(s4);
match r4 { match r4 {
Ok((rem, ctx)) => { Ok((rem, ctx)) => {
assert_eq!(ctx.id, HTTP2SettingsId::SETTINGSMAXCONCURRENTSTREAMS); assert_eq!(ctx.id, HTTP2SettingsId::MaxConcurrentStreams);
match ctx.value { match ctx.value {
Some(ctxval) => { Some(ctxval) => {
assert_eq!(ctxval.arg1, 54); assert_eq!(ctxval.arg1, 54);
@ -969,7 +969,7 @@ mod tests {
let r5 = http2_parse_settingsctx(s5); let r5 = http2_parse_settingsctx(s5);
match r5 { match r5 {
Ok((rem, ctx)) => { Ok((rem, ctx)) => {
assert_eq!(ctx.id, HTTP2SettingsId::SETTINGSMAXCONCURRENTSTREAMS); assert_eq!(ctx.id, HTTP2SettingsId::MaxConcurrentStreams);
match ctx.value { match ctx.value {
Some(ctxval) => { Some(ctxval) => {
assert_eq!(ctxval.arg1, 76); assert_eq!(ctxval.arg1, 76);
@ -1025,7 +1025,7 @@ mod tests {
Ok((remainder, frame)) => { Ok((remainder, frame)) => {
// Check the first message. // Check the first message.
assert_eq!(frame.length, 6); assert_eq!(frame.length, 6);
assert_eq!(frame.ftype, HTTP2FrameType::SETTINGS as u8); assert_eq!(frame.ftype, HTTP2FrameType::Settings as u8);
assert_eq!(frame.flags, 0); assert_eq!(frame.flags, 0);
assert_eq!(frame.reserved, 0); assert_eq!(frame.reserved, 0);
assert_eq!(frame.stream_id, 0); assert_eq!(frame.stream_id, 0);

@ -144,7 +144,7 @@ pub enum AttributeType {
GroupCurveB = 10, GroupCurveB = 10,
LifeType = 11, LifeType = 11,
LifeDuration = 12, LifeDuration = 12,
PRF = 13, Prf = 13,
KeyLength = 14, KeyLength = 14,
FieldSize = 15, FieldSize = 15,
GroupOrder = 16, GroupOrder = 16,
@ -165,7 +165,7 @@ impl fmt::Display for AttributeType {
AttributeType::GroupCurveB => write!(f, "sa_group_curve_b"), AttributeType::GroupCurveB => write!(f, "sa_group_curve_b"),
AttributeType::LifeType => write!(f, "sa_life_type"), AttributeType::LifeType => write!(f, "sa_life_type"),
AttributeType::LifeDuration => write!(f, "sa_life_duration"), AttributeType::LifeDuration => write!(f, "sa_life_duration"),
AttributeType::PRF => write!(f, "alg_prf"), AttributeType::Prf => write!(f, "alg_prf"),
AttributeType::KeyLength => write!(f, "sa_key_length"), AttributeType::KeyLength => write!(f, "sa_key_length"),
AttributeType::FieldSize => write!(f, "sa_field_size"), AttributeType::FieldSize => write!(f, "sa_field_size"),
AttributeType::GroupOrder => write!(f, "sa_group_order"), AttributeType::GroupOrder => write!(f, "sa_group_order"),
@ -351,7 +351,7 @@ fn get_attribute_type(v: u16) -> AttributeType {
10 => AttributeType::GroupCurveB, 10 => AttributeType::GroupCurveB,
11 => AttributeType::LifeType, 11 => AttributeType::LifeType,
12 => AttributeType::LifeDuration, 12 => AttributeType::LifeDuration,
13 => AttributeType::PRF, 13 => AttributeType::Prf,
14 => AttributeType::KeyLength, 14 => AttributeType::KeyLength,
15 => AttributeType::FieldSize, 15 => AttributeType::FieldSize,
16 => AttributeType::GroupOrder, 16 => AttributeType::GroupOrder,

@ -31,7 +31,6 @@
#![allow(clippy::module_inception)] #![allow(clippy::module_inception)]
#![allow(clippy::result_unit_err)] #![allow(clippy::result_unit_err)]
#![allow(clippy::type_complexity)] #![allow(clippy::type_complexity)]
#![allow(clippy::upper_case_acronyms)]
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;

Loading…
Cancel
Save