From 6092eec050e395564877bed2dca974dbd2c9b892 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 26 May 2024 22:01:31 +1200 Subject: [PATCH 1/2] HTTP: add Frame type enumeration --- src/http/FrameType.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ src/http/Makefile.am | 8 ++++++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/http/FrameType.h diff --git a/src/http/FrameType.h b/src/http/FrameType.h new file mode 100644 index 00000000000..903b928721b --- /dev/null +++ b/src/http/FrameType.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 1996-2024 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#ifndef SQUID_SRC_HTTP_FRAMETYPE_H +#define SQUID_SRC_HTTP_FRAMETYPE_H + +#include "sbuf/SBuf.h" + +namespace Http +{ + +/// HTTP Frame Type registrations +typedef enum : uint8_t { + /* RFC 9113 section 6.1 */ + FRAME_DATA = 0x00, + FRAME_HEADERS = 0x01, + FRAME_PRIORITY = 0x02, + FRAME_RST_STREAM = 0x03, + FRAME_SETTINGS = 0x04, + FRAME_PUSH_PROMISE = 0x05, + FRAME_PING = 0x06, + FRAME_GOAWAY = 0x07, + FRAME_WINDOW_UPDATE = 0x08, + FRAME_CONTINUATION = 0x09, + + /* RFC 7838 section 4 */ + FRAME_ALTSVC = 0x0A, + + /* RFC 8336 section 2.1 */ + FRAME_ORIGIN = 0x0C, + + /* RFC 9114 section 7.2 */ + FRAME_CANCEL_PUSH = FRAME_RST_STREAM, + FRAME_MAX_PUSH_ID = 0x0D + + /* types 0x1f * N + 0x21 reserved for experimental use */ + /* types 0xf0-0xff reserved for experimental use */ +} FrameType; + +extern const SBuf FrameType_sb[]; + +inline const SBuf & +FrameTypeStr(const FrameType m) +{ + return FrameType_sb[m]; +} + +} // namespace Http + +#endif /* SQUID_SRC_HTTP_FRAMETYPE_H */ diff --git a/src/http/Makefile.am b/src/http/Makefile.am index a976b2024d5..446f51db55b 100644 --- a/src/http/Makefile.am +++ b/src/http/Makefile.am @@ -14,6 +14,8 @@ noinst_LTLIBRARIES = libhttp.la libhttp_la_SOURCES = \ ContentLengthInterpreter.cc \ ContentLengthInterpreter.h \ + FrameType.cc \ + FrameType.h \ Message.cc \ Message.h \ MethodType.cc \ @@ -35,10 +37,14 @@ libhttp_la_SOURCES = \ libhttp_la_LIBADD= one/libhttp1.la +FrameType.cc: FrameType.h $(top_srcdir)/src/mk-string-arrays.awk + ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk sbuf=1 < $(srcdir)/FrameType.h | \ + sed -e 's%FRAME_%%' >$@) || ($(RM) -f $@ && exit 1) + MethodType.cc: MethodType.h $(top_srcdir)/src/mk-string-arrays.awk ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk sbuf=1 < $(srcdir)/MethodType.h | \ sed -e 's%METHOD_%%' -e 's%_C%-C%' >$@) || ($(RM) -f $@ && exit 1) -CLEANFILES += MethodType.cc +CLEANFILES += FrameType.cc MethodType.cc EXTRA_DIST = RegisteredHeadersHash.gperf From 900816748af920ed46f2221f6da3915686798501 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sat, 29 Jun 2024 14:47:24 +1200 Subject: [PATCH 2/2] Source Format Enforcement --- src/http/FrameType.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http/FrameType.h b/src/http/FrameType.h index 903b928721b..3c96646e8a8 100644 --- a/src/http/FrameType.h +++ b/src/http/FrameType.h @@ -38,8 +38,8 @@ typedef enum : uint8_t { FRAME_CANCEL_PUSH = FRAME_RST_STREAM, FRAME_MAX_PUSH_ID = 0x0D - /* types 0x1f * N + 0x21 reserved for experimental use */ - /* types 0xf0-0xff reserved for experimental use */ + /* types 0x1f * N + 0x21 reserved for experimental use */ + /* types 0xf0-0xff reserved for experimental use */ } FrameType; extern const SBuf FrameType_sb[];