diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2005-09-29 20:05:24 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2005-09-29 20:05:24 +0000 |
commit | 8ee088f9cde1830e06226a76bfd6246311ce9ab1 (patch) | |
tree | 2b07e2bc2a46c247e78580026c9ac7bf514db67f /plugins/tpg/packet-http.c | |
parent | 2b57849529b7a2e8dc9ccbcce9be3182e5e5380e (diff) | |
download | wireshark-8ee088f9cde1830e06226a76bfd6246311ce9ab1.tar.gz |
at this point this makes a good parser for http headers...
svn path=/trunk/; revision=16053
Diffstat (limited to 'plugins/tpg/packet-http.c')
-rw-r--r-- | plugins/tpg/packet-http.c | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/plugins/tpg/packet-http.c b/plugins/tpg/packet-http.c index db27c0ebff..266fecfc50 100644 --- a/plugins/tpg/packet-http.c +++ b/plugins/tpg/packet-http.c @@ -15,14 +15,24 @@ static const value_string http_response_codes[] = { static gint ett_http = -1; static int proto_http = -1; -static tvbparse_wanted_t* rule_http_crlf; -static tvbparse_wanted_t* rule_http_header; -static tvbparse_wanted_t* rule_http_req_resp; +static int hf_http_is_response = -1; +static int hf_http_request_method = -1; +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_request_uri = -1; static dissector_handle_t http_handle; + +struct _elem_tree_stack_frame { + proto_tree* tree; + tvbparse_elem_t* elem; +}; + static void dissect_http(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree) { - http_info_value_t* msgdata = ep_alloc(sizeof(http_info_value_t)); + http_info_value_t* msgdata = ep_alloc0(sizeof(http_info_value_t)); tvbparse_elem_t* reqresp; tpg_parser_data_t* tpg; proto_item* pi = proto_tree_add_item(tree,proto_http,tvb,0,-1,FALSE); @@ -30,41 +40,58 @@ static void dissect_http(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree tpg = tpg_start(pt,tvb,0,-1,msgdata); - if (( reqresp = TPG_GET(tpg,rule_http_req_resp) )) { + if (( reqresp = TPG_GET(tpg,http_tpg_data.wanted_http_req_resp) )) { tvbparse_elem_t* hdr; - while(( hdr = TPG_GET(tpg,rule_http_header) )) ; + while(( hdr = TPG_GET(tpg,http_tpg_data.wanted_http_header) )) ; - if ( TPG_GET(tpg,rule_http_crlf) ) { - return; + if ( TPG_GET(tpg,http_tpg_data.wanted_http_crlf) ) { + 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); + if (msgdata->transfer_encoding) proto_tree_add_string(pt,hf_http_transfer_encoding,tvb,0,0,msgdata->transfer_encoding); + 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->request_uri) proto_tree_add_string(pt,hf_http_request_uri,tvb,0,0,msgdata->request_uri); + } + + } else { + /* header fragment */ } - } else { + /* no header */ return; } } static void proto_register_http(void) { static hf_register_info hf[] = { - HF_HTTP_PARSER + HF_HTTP_PARSER, + { &hf_http_is_response, { "=Is Response", "hyttp.info.is_response", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "", HFILL }}, + { &hf_http_request_method, { "=Method", "hyttp.info.method", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }}, + { &hf_http_response_code, { "=Response Code", "hyttp.info.response.code", FT_UINT32, BASE_DEC, VALS( http_response_codes ), 0x0, "", HFILL }}, + { &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 }} }; - static gint *ett[] = { + gint *ett[] = { ETT_HTTP_PARSER, &ett_http }; tpg_http_init(); - proto_http = proto_register_protocol("HyTeTrP", - "HyTeTrP", "hytetrpr"); + proto_http = proto_register_protocol("HyTTP", + "HyTTP", "hyttp"); proto_register_field_array(proto_http, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - rule_http_crlf = wanted_http_crlf(); - rule_http_header = wanted_http_header(); - rule_http_req_resp = wanted_http_req_resp(); - + } |