The code in an HTTP reply is a response code, not a response method.

svn path=/trunk/; revision=8346
This commit is contained in:
Guy Harris 2003-09-02 23:09:11 +00:00
parent 75ae0e30c7
commit fdfd8b58af
4 changed files with 50 additions and 51 deletions

View File

@ -1,7 +1,7 @@
/* http_stat.c
* http_stat 2003 Jean-Michel FAYARD
*
* $Id: http_stat.c,v 1.1 2003/09/02 22:47:59 guy Exp $
* $Id: http_stat.c,v 1.2 2003/09/02 23:09:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -59,14 +59,15 @@ typedef struct _http_stats_t {
/* used to keep track of the stats for a specific response code
* for example it can be { 3, 404, "Not Found" ,...}
* which means we captured 3 reply http/1.1 404 Not Found */
typedef struct _http_response_methode_t {
typedef struct _http_response_code_t {
guint32 packets; /* 3 */
guint response_method; /* 404 */
guint response_code; /* 404 */
gchar *name; /* Not Found */
GtkWidget *widget; /* Label where we display it */
GtkWidget *table; /* Table in which we put it, e.g. client_error_box */
httpstat_t *sp;
} http_response_methode_t;
} http_response_code_t;
/* used to keep track of the stats for a specific request string */
typedef struct _http_request_methode_t {
gchar *response; /* eg. : GET */
@ -142,10 +143,10 @@ http_init_hash( httpstat_t *sp)
for (i=0 ; vals_status_code[i].strptr ; i++ )
{
gint *key = g_malloc (sizeof(gint));
http_response_methode_t *sc = g_malloc (sizeof(http_response_methode_t));
http_response_code_t *sc = g_malloc (sizeof(http_response_code_t));
*key = vals_status_code[i].value;
sc->packets=0;
sc->response_method = *key;
sc->response_code = *key;
sc->name=vals_status_code[i].strptr;
sc->widget=NULL;
sc->table=NULL;
@ -172,17 +173,17 @@ http_draw_hash_requests( gchar *key _U_ , http_request_methode_t *data, gchar *
static void
http_draw_hash_responses( gint * key _U_ , http_response_methode_t *data, gchar * string_buff)
http_draw_hash_responses( gint * key _U_ , http_response_code_t *data, gchar * string_buff)
{
if (data==NULL)
g_warning("C'est quoi ce borderl key=%d\n", *key);
if (data->packets==0)
return;
/*sprintf(string_buff, "%d packets %d:%s", data->packets, data->response_method, data->name); */
/*sprintf(string_buff, "%d packets %d:%s", data->packets, data->response_code, data->name); */
if (data->widget==NULL){ /* create an entry in the relevant box of the window */
guint16 x;
GtkWidget *tmp;
guint i = data->response_method;
guint i = data->response_code;
if ( (i<100)||(i>=600) )
return;
@ -198,7 +199,7 @@ http_draw_hash_responses( gint * key _U_ , http_response_methode_t *data, gchar
data->table = data->sp->server_errors_table;
x=GTK_TABLE( data->table)->nrows;
sprintf(string_buff, "HTTP %3d %s ", data->response_method, data->name );
sprintf(string_buff, "HTTP %3d %s ", data->response_code, data->name );
tmp = gtk_label_new( string_buff );
gtk_table_attach_defaults( GTK_TABLE(data->table), tmp, 0,1, x, x+1);
@ -230,7 +231,7 @@ http_free_hash( gpointer key, gpointer value, gpointer user_data _U_ )
g_free(value);
}
static void
http_reset_hash_responses(gchar *key _U_ , http_response_methode_t *data, gpointer ptr _U_ )
http_reset_hash_responses(gchar *key _U_ , http_response_code_t *data, gpointer ptr _U_ )
{
data->packets = 0;
}
@ -261,11 +262,11 @@ httpstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, voi
/* We are only interested in reply packets with a status code */
/* Request or reply packets ? */
if (value->response_method!=0) {
if (value->response_code!=0) {
guint *key=g_malloc( sizeof(guint) );
http_response_methode_t *sc;
http_response_code_t *sc;
*key=value->response_method ;
*key=value->response_code;
sc = g_hash_table_lookup(
sp->hash_responses,
key);
@ -273,7 +274,7 @@ httpstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, voi
/* non standard status code ; we classify it as others
* in the relevant category (Informational,Success,Redirection,Client Error,Server Error)
*/
int i = value->response_method;
int i = value->response_code;
if ((i<100) || (i>=600)) {
return 0;
}

View File

@ -6,7 +6,7 @@
* Copyright 2002, Tim Potter <tpot@samba.org>
* Copyright 1999, Andrew Tridgell <tridge@samba.org>
*
* $Id: packet-http.c,v 1.66 2003/09/02 22:47:57 guy Exp $
* $Id: packet-http.c,v 1.67 2003/09/02 23:09:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -58,7 +58,7 @@ static int hf_http_response = -1;
static int hf_http_request = -1;
static int hf_http_basic = -1;
static int hf_http_request_method = -1;
static int hf_http_response_method = -1;
static int hf_http_response_code = -1;
static gint ett_http = -1;
static gint ett_http_ntlmssp = -1;
@ -219,7 +219,7 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree *req_tree;
stat_info =g_malloc( sizeof(http_info_value_t));
stat_info->response_method = 0;
stat_info->response_code = 0;
stat_info->request_method = NULL;
switch (pinfo->match_port) {
@ -454,20 +454,20 @@ basic_request_dissector(tvbuff_t *tvb, proto_tree *tree, int req_strlen)
{
proto_tree_add_item(tree, hf_http_request_method, tvb, 0, req_strlen, FALSE);
}
static void
response_method_request_dissector(tvbuff_t *tvb, proto_tree *tree, int req_strlen _U_ )
basic_response_dissector(tvbuff_t *tvb, proto_tree *tree, int req_strlen _U_)
{
const guchar *data;
int minor, major, status_code;
data = tvb_get_ptr(tvb, 0, 12);
if (sscanf(data, "HTTP/%d.%d %d", &minor, &major, &status_code)==3)
{
proto_tree_add_uint(tree, hf_http_response_method, tvb, 9, 3, status_code);
stat_info->response_method = status_code;
data = tvb_get_ptr(tvb, 5, 12);
if (sscanf(data, "%d.%d %d", &minor, &major, &status_code) == 3) {
proto_tree_add_uint(tree, hf_http_response_code, tvb, 9, 3, status_code);
stat_info->response_code = status_code;
}
}
/*
* XXX - this won't handle HTTP 0.9 replies, but they're all data
* anyway.
@ -499,16 +499,11 @@ is_http_request_or_reply(const guchar *data, int linelen, http_type_t *type,
* SEARCH
*/
if (linelen >= 5 && strncmp(data, "HTTP/", 5) == 0) {
*type = HTTP_RESPONSE;
isHttpRequestOrReply = TRUE; /* response */
if (req_dissector && (linelen >= 12) )
{
*req_dissector = response_method_request_dissector ;
*req_strlen = 3;
} else
if (req_dissector) {
*req_dissector = NULL; /* no dissector for this yet. */
*req_dissector = basic_response_dissector;
*req_strlen = linelen - 5;
}
} else {
const guchar * ptr = (const guchar *)data;
@ -653,10 +648,10 @@ proto_register_http(void)
{ "Request Method", "http.request.method",
FT_STRING, BASE_NONE, NULL, 0x0,
"HTTP Request Method", HFILL }},
{ &hf_http_response_method,
{ "Response Method", "http.response.method",
{ &hf_http_response_code,
{ "Response Code", "http.response.code",
FT_UINT16, BASE_DEC, NULL, 0x0,
"HTTP Response Method", HFILL }},
"HTTP Response Code", HFILL }},
};
static gint *ett[] = {
&ett_http,

View File

@ -1,6 +1,6 @@
/* packet-http.h
*
* $Id: packet-http.h,v 1.8 2003/09/02 22:47:57 guy Exp $
* $Id: packet-http.h,v 1.9 2003/09/02 23:09:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -23,13 +23,15 @@
#ifndef __PACKET_HTTP_H__
#define __PACKET_HTTP_H__
#include <epan/packet.h>
void http_dissector_add(guint32 port, dissector_handle_t handle);
typedef struct _http_info_value_t
{
guint response_method;
gchar *request_method;
} http_info_value_t ;
guint response_code;
} http_info_value_t;
#endif

View File

@ -1,7 +1,7 @@
/* tap-httpstat.c
* tap-httpstat 2003 Jean-Michel FAYARD
*
* $Id: tap-httpstat.c,v 1.1 2003/09/02 22:47:58 guy Exp $
* $Id: tap-httpstat.c,v 1.2 2003/09/02 23:09:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -46,12 +46,13 @@ typedef struct _http_stats_t {
/* used to keep track of the stats for a specific response code
* for example it can be { 3, 404, "Not Found" ,...}
* which means we captured 3 reply http/1.1 404 Not Found */
typedef struct _http_response_methode_t {
typedef struct _http_response_code_t {
guint32 packets; /* 3 */
guint response_method; /* 404 */
guint response_code; /* 404 */
gchar *name; /* Not Found */
httpstat_t *sp;
} http_response_methode_t;
} http_response_code_t;
/* used to keep track of the stats for a specific request string */
typedef struct _http_request_methode_t {
gchar *response; /* eg. : GET */
@ -122,10 +123,10 @@ http_init_hash( httpstat_t *sp)
for (i=0 ; vals_status_code[i].strptr ; i++ )
{
gint *key = g_malloc (sizeof(gint));
http_response_methode_t *sc = g_malloc (sizeof(http_response_methode_t));
http_response_code_t *sc = g_malloc (sizeof(http_response_code_t));
*key = vals_status_code[i].value;
sc->packets=0;
sc->response_method = *key;
sc->response_code = *key;
sc->name=vals_status_code[i].strptr;
sc->sp = sp;
g_hash_table_insert( sc->sp->hash_responses, key, sc);
@ -141,7 +142,7 @@ http_draw_hash_requests( gchar *key _U_ , http_request_methode_t *data, gchar *
}
static void
http_draw_hash_responses( gint * key _U_ , http_response_methode_t *data, char * format)
http_draw_hash_responses( gint * key _U_ , http_response_code_t *data, char * format)
{
if (data==NULL){
g_warning("C'est quoi ce borderl key=%d\n", *key);
@ -150,7 +151,7 @@ http_draw_hash_responses( gint * key _U_ , http_response_methode_t *data, char *
if (data->packets==0)
return;
/* " HTTP %3d %-35s %9d packets", */
printf(format, data->response_method, data->name, data->packets );
printf(format, data->response_code, data->name, data->packets );
}
@ -165,7 +166,7 @@ http_free_hash( gpointer key, gpointer value, gpointer user_data _U_ )
}
*/
static void
http_reset_hash_responses(gchar *key _U_ , http_response_methode_t *data, gpointer ptr _U_ )
http_reset_hash_responses(gchar *key _U_ , http_response_code_t *data, gpointer ptr _U_ )
{
data->packets = 0;
}
@ -193,11 +194,11 @@ httpstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, voi
/* We are only interested in reply packets with a status code */
/* Request or reply packets ? */
if (value->response_method!=0) {
if (value->response_code!=0) {
guint *key=g_malloc( sizeof(guint) );
http_response_methode_t *sc;
http_response_code_t *sc;
*key=value->response_method ;
*key=value->response_code ;
sc = g_hash_table_lookup(
sp->hash_responses,
key);
@ -205,7 +206,7 @@ httpstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, voi
/* non standard status code ; we classify it as others
* in the relevant category (Informational,Success,Redirection,Client Error,Server Error)
*/
int i = value->response_method;
int i = value->response_code;
if ((i<100) || (i>=600)) {
return 0;
}