From 99104fe179bcbb0fbfbcf94fd7166c2af9e1c61b Mon Sep 17 00:00:00 2001 From: Luis Ontanon Date: Sat, 1 Oct 2005 10:41:00 +0000 Subject: [PATCH] match changes to tpg infrastructure. svn path=/trunk/; revision=16063 --- plugins/tpg/http.tpg | 65 +++++++++++++++++---------------------- plugins/tpg/packet-http.c | 6 +++- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/plugins/tpg/http.tpg b/plugins/tpg/http.tpg index 8a64de9154..9bc45d7537 100644 --- a/plugins/tpg/http.tpg +++ b/plugins/tpg/http.tpg @@ -48,61 +48,52 @@ typedef struct _http_info_value_t %rule sp = [ ]+ . -%choice versions = "1.0" | "1.1". +%choice versions = "1.0" | "1.1". %field version hyttp.version "HTTP Version" FT_STRING . -%sequence http_version = "HTTP/" & versions . +%sequence http_version = "HTTP/" & versions . %field response hyttp.response "Response" FT_STRING . %field response_code hyttp.response.code "Response Code" FT_UINT32 BASE_DEC %{ http_response_codes %} . -%sequence response = http_version & sp & [0-9]+ & ... ( crlf ) . { - %root response - %code %{ - TT_DATA->is_response = TRUE; - TT_DATA->response_code = TPG_UINT(RESPONSE); - %} -} + +%sequence %tree response = http_version & sp & [0-9]+ & ... ( crlf ) . %{ + TT_DATA->is_response = TRUE; + TT_DATA->response_code = TPG_UINT(RESPONSE); +%} %field request hyttp.request "Request" FT_STRING . %field method hyttp.request.method "Request Method" FT_STRING . %field uri hyttp.request.uri "Request URI" FT_STRING . -%sequence request = [A-Z]+ & sp & [^ ]+ & sp & http_version & crlf . { - %root request - %code %{ - TT_DATA->is_response = FALSE; - TT_DATA->request_method = TPG_STRING(METHOD); - TT_DATA->request_uri = TPG_STRING(URI); - %} -} +%sequence %tree request = [A-Z]+ & sp & [^ ]+ & sp & http_version & crlf . %{ + TT_DATA->is_response = FALSE; + TT_DATA->request_method = TPG_STRING(METHOD); + TT_DATA->request_uri = TPG_STRING(URI); +%} %choice req_resp = request | response. %field media hyttp.content_type.media "Content-Type Media" FT_STRING . -%sequence media = [a-z]+ & "/" & [a-z]+ . { - %code %{ +%sequence media = [a-z]+ & "/" & [a-z]+ . %{ TT_DATA->media = TPG_STRING(MEDIA); - %} -} +%} + +%sequence content_type_value = media & ... ( crlf %leave ) . %field content_type hyttp.content_type "Content-Type" FT_STRING . -%sequence content_type_hdr = 'Content-type: ' & media & ... ( crlf %leave ) & crlf . +%sequence content_type_hdr = 'Content-type: ' & content_type_value & crlf . %field content_length hyttp.headers.content_length "Content-Length" FT_UINT32 BASE_DEC . -%sequence content_length = 'Content-length: ' & [0-9]+ & crlf. { - %code %{ - TT_DATA->content_length = TPG_UINT(LENGTH); - %} -} +%sequence content_length = 'Content-length: ' & [0-9]+ & crlf. %{ + TT_DATA->content_length = TPG_UINT(LENGTH); +%} %field transfer_encoding hyttp.transfer_encoding "Transfer-Encoding" FT_STRING . -%sequence transfer_encoding = 'Transfer-encoding: ' & ... ( crlf %leave ) & crlf. { - %code %{ - TT_DATA->transfer_encoding = TPG_STRING(ENCODING); - %} -} +%sequence transfer_encoding = 'Transfer-encoding: ' & ... ( crlf %leave ) & crlf. %{ + TT_DATA->transfer_encoding = TPG_STRING(ENCODING); +%} %field authorization hyttp.authorization "Authorization" FT_STRING . %sequence authorization = 'Authorization: ' & ... ( crlf %leave ) & crlf. @@ -123,7 +114,9 @@ typedef struct _http_info_value_t %sequence user_agent = 'User-Agent: ' & ... ( crlf %leave ) & crlf. %field host hyttp.host "Host" FT_STRING . -%sequence host = 'Host: ' & ... ( crlf %leave ) & crlf. +%sequence host = 'Host: ' & ... ( crlf %leave ) & crlf. %{ + TT_DATA->http_host = TPG_STRING(HOST); +%} %field accept hyttp.accept "Accept" FT_STRING . %sequence accept = 'Accept: ' & ... ( crlf %leave ) & crlf. @@ -161,7 +154,7 @@ typedef struct _http_info_value_t %sequence other_header = [A-Z] & [a-zA-Z-]+ & ": " & ... ( crlf %leave ) & crlf. %field header hyttp.headers.line "HTTP Header Line" FT_BOOLEAN . -%choice header = +%choice %tree header = content_type_hdr | transfer_encoding | content_length @@ -183,9 +176,7 @@ typedef struct _http_info_value_t | etag | last_modified | server - | other_header . { - %root header -} + | other_header . %tail %{ diff --git a/plugins/tpg/packet-http.c b/plugins/tpg/packet-http.c index 9e01aadfd9..c37ea25235 100644 --- a/plugins/tpg/packet-http.c +++ b/plugins/tpg/packet-http.c @@ -21,6 +21,7 @@ static int hf_http_response_code = -1; static int hf_http_transfer_encoding = -1; static int hf_http_content_length = -1; static int hf_http_media = -1; +static int hf_http_host = -1; static int hf_http_request_uri = -1; static dissector_handle_t http_handle; @@ -43,6 +44,7 @@ static void dissect_http(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree pi = proto_tree_add_boolean(pt,hf_http_is_response,tvb,0,0,msgdata->is_response); pt = proto_item_add_subtree(pi,ett_http); + if (msgdata->is_response) { proto_tree_add_uint(pt,hf_http_response_code,tvb,0,0,msgdata->response_code); proto_tree_add_uint(pt,hf_http_content_length,tvb,0,0,msgdata->content_length); @@ -50,6 +52,7 @@ static void dissect_http(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree if (msgdata->media) proto_tree_add_string(pt,hf_http_media,tvb,0,0,msgdata->media); } else { if (msgdata->request_method) proto_tree_add_string(pt,hf_http_request_method,tvb,0,0,msgdata->request_method); + if (msgdata->http_host) proto_tree_add_string(pt,hf_http_host,tvb,0,0,msgdata->http_host); if (msgdata->request_uri) proto_tree_add_string(pt,hf_http_request_uri,tvb,0,0,msgdata->request_uri); } @@ -71,7 +74,8 @@ static void proto_register_http(void) { { &hf_http_transfer_encoding, { "=Transfer-Encoding", "hyttp.info.transfer_encoding", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }}, { &hf_http_content_length, { "=Content-Length", "hyttp.info.content_length", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }}, { &hf_http_request_uri, { "=Request URI", "hyttp.info.uri", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }}, - { &hf_http_media, { "=Media", "hyttp.info.media", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }} + { &hf_http_media, { "=Media", "hyttp.info.media", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }}, + { &hf_http_host, { "=Host", "hyttp.info.host", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }} }; gint *ett[] = {