Commit 02a7182e authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Create strframetype to handle unknown frame types

parent 47c14470
...@@ -91,17 +91,30 @@ const char* strsettingsid(int32_t id) ...@@ -91,17 +91,30 @@ const char* strsettingsid(int32_t id)
} // namespace } // namespace
namespace { namespace {
const char *frame_names[] = { const char* strframetype(uint8_t type)
"DATA", {
"HEADERS", switch(type) {
"PRIORITY", case NGHTTP2_DATA:
"RST_STREAM", return "DATA";
"SETTINGS", case NGHTTP2_HEADERS:
"PUSH_PROMISE", return "HEADERS";
"PING", case NGHTTP2_PRIORITY:
"GOAWAY", return "PRIORITY";
"UNKNOWN", case NGHTTP2_RST_STREAM:
"WINDOW_UPDATE" return "RST_STREAM";
case NGHTTP2_SETTINGS:
return "SETTINGS";
case NGHTTP2_PUSH_PROMISE:
return "PUSH_PROMISE";
case NGHTTP2_PING:
return "PING";
case NGHTTP2_GOAWAY:
return "GOAWAY";
case NGHTTP2_WINDOW_UPDATE:
return "WINDOW_UPDATE";
default:
return "UNKNOWN";
}
}; };
} // namespace } // namespace
...@@ -231,7 +244,7 @@ void print_frame(print_type ptype, nghttp2_frame *frame) ...@@ -231,7 +244,7 @@ void print_frame(print_type ptype, nghttp2_frame *frame)
{ {
printf("%s%s%s frame ", printf("%s%s%s frame ",
frame_name_ansi_esc(ptype), frame_name_ansi_esc(ptype),
frame_names[frame->hd.type], strframetype(frame->hd.type),
ansi_escend()); ansi_escend());
print_frame_hd(frame->hd); print_frame_hd(frame->hd);
if(frame->hd.flags) { if(frame->hd.flags) {
...@@ -357,7 +370,7 @@ void on_frame_recv_parse_error_callback(nghttp2_session *session, ...@@ -357,7 +370,7 @@ void on_frame_recv_parse_error_callback(nghttp2_session *session,
print_timer(); print_timer();
printf(" [PARSE_ERROR] recv %s%s%s frame\n", printf(" [PARSE_ERROR] recv %s%s%s frame\n",
frame_name_ansi_esc(PRINT_RECV), frame_name_ansi_esc(PRINT_RECV),
frame_names[type], strframetype(type),
ansi_escend()); ansi_escend());
print_frame_attr_indent(); print_frame_attr_indent();
printf("Error: %s\n", nghttp2_strerror(error_code)); printf("Error: %s\n", nghttp2_strerror(error_code));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment