diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2005-10-01 10:41:00 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2005-10-01 10:41:00 +0000 |
commit | 99104fe179bcbb0fbfbcf94fd7166c2af9e1c61b (patch) | |
tree | 211e2e8ac4b5a50abf0d69e4381a290723749593 /plugins/tpg | |
parent | aef8dd5c4c728c61fb8ea64c76e867823712267e (diff) |
match changes to tpg infrastructure.
svn path=/trunk/; revision=16063
Diffstat (limited to 'plugins/tpg')
-rw-r--r-- | plugins/tpg/http.tpg | 65 | ||||
-rw-r--r-- | 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". <version> %field version hyttp.version "HTTP Version" FT_STRING . -%sequence http_version = "HTTP/" & versions<version> . +%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]+<response_code:RESPONSE> & ... ( crlf ) . <response:%plain_text> { - %root response - %code %{ - TT_DATA->is_response = TRUE; - TT_DATA->response_code = TPG_UINT(RESPONSE); - %} -} + +%sequence %tree response = http_version & sp & [0-9]+<response_code:RESPONSE> & ... ( crlf ) . <response:%plain_text> %{ + 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]+<method:METHOD> & sp & [^ ]+<uri:URI> & sp & http_version & crlf . <request:%plain_text> { - %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]+<method:METHOD> & sp & [^ ]+<uri:URI> & sp & http_version & crlf . <request:%plain_text> %{ + 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]+ . <MEDIA> { - %code %{ +%sequence media = [a-z]+ & "/" & [a-z]+ . <media:MEDIA> %{ TT_DATA->media = TPG_STRING(MEDIA); - %} -} +%} + +%sequence content_type_value = media & ... ( crlf %leave ) . <content_type> %field content_type hyttp.content_type "Content-Type" FT_STRING . -%sequence content_type_hdr = 'Content-type: ' & media<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]+<content_length:LENGTH> & crlf. { - %code %{ - TT_DATA->content_length = TPG_UINT(LENGTH); - %} -} +%sequence content_length = 'Content-length: ' & [0-9]+<content_length:LENGTH> & crlf. %{ + TT_DATA->content_length = TPG_UINT(LENGTH); +%} %field transfer_encoding hyttp.transfer_encoding "Transfer-Encoding" FT_STRING . -%sequence transfer_encoding = 'Transfer-encoding: ' & ...<transfer_encoding:ENCODING> ( crlf %leave ) & crlf. { - %code %{ - TT_DATA->transfer_encoding = TPG_STRING(ENCODING); - %} -} +%sequence transfer_encoding = 'Transfer-encoding: ' & ...<transfer_encoding:ENCODING> ( crlf %leave ) & crlf. %{ + TT_DATA->transfer_encoding = TPG_STRING(ENCODING); +%} %field authorization hyttp.authorization "Authorization" FT_STRING . %sequence authorization = 'Authorization: ' & ...<authorization> ( crlf %leave ) & crlf. @@ -123,7 +114,9 @@ typedef struct _http_info_value_t %sequence user_agent = 'User-Agent: ' & ...<user_agent> ( crlf %leave ) & crlf. %field host hyttp.host "Host" FT_STRING . -%sequence host = 'Host: ' & ...<host> ( crlf %leave ) & crlf. +%sequence host = 'Host: ' & ...<host:HOST> ( crlf %leave ) & crlf. %{ + TT_DATA->http_host = TPG_STRING(HOST); +%} %field accept hyttp.accept "Accept" FT_STRING . %sequence accept = '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 . <header:%plain_text> { - %root header -} + | other_header . <header:%plain_text> %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[] = { |