*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "epan/value_string.h"
#include <epan/tap.h>
#include <epan/stat_cmd_args.h>
-#include "register.h"
#include <epan/dissectors/packet-http.h>
-
+
/* used to keep track of the statictics for an entire program interface */
typedef struct _http_stats_t {
char *filter;
{ 414, "Request-URI Too Large"},
{ 415, "Unsupported Media Type"},
{ 499, "Client Error - Others"},
-
+
{ 500, "Internal Server Error"},
{ 501, "Not Implemented"},
{ 502, "Bad Gateway"},
{
int i;
- sp->hash_responses = g_hash_table_new( g_int_hash, g_int_equal);
-
+ sp->hash_responses = g_hash_table_new( g_int_hash, g_int_equal);
+
for (i=0 ; vals_status_code[i].strptr ; i++ )
{
gint *key = g_malloc (sizeof(gint));
{
if (data->packets==0)
return;
- printf( format, data->response, data->packets);
+ printf( format, data->response, data->packets);
}
static void
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);
+ g_warning("No data available, key=%d\n", *key);
exit(EXIT_FAILURE);
}
if (data->packets==0)
/* " HTTP %3d %-35s %9d packets", */
printf(format, data->response_code, data->name, data->packets );
}
-
-
+
+
/* NOT USED at this moment */
/*
static void
}
*/
static void
-http_reset_hash_responses(gchar *key _U_ , http_response_code_t *data, gpointer ptr _U_ )
-{
+http_reset_hash_responses(gchar *key _U_ , http_response_code_t *data, gpointer ptr _U_ )
+{
data->packets = 0;
}
static void
-http_reset_hash_requests(gchar *key _U_ , http_request_methode_t *data, gpointer ptr _U_ )
-{
+http_reset_hash_requests(gchar *key _U_ , http_request_methode_t *data, gpointer ptr _U_ )
+{
data->packets = 0;
}
httpstat_reset(void *psp )
{
httpstat_t *sp=psp;
- if (!sp) {
- g_hash_table_foreach( sp->hash_responses, (GHFunc)http_reset_hash_responses, NULL);
- g_hash_table_foreach( sp->hash_responses, (GHFunc)http_reset_hash_requests, NULL);
- }
+
+ g_hash_table_foreach( sp->hash_responses, (GHFunc)http_reset_hash_responses, NULL);
+ g_hash_table_foreach( sp->hash_requests, (GHFunc)http_reset_hash_requests, NULL);
+
}
static int
if (value->response_code!=0) {
guint *key=g_malloc( sizeof(guint) );
http_response_code_t *sc;
-
+
*key=value->response_code;
- sc = g_hash_table_lookup(
- sp->hash_responses,
+ sc = g_hash_table_lookup(
+ sp->hash_responses,
key);
if (sc==NULL){
/* non standard status code ; we classify it as others
else{
*key=599;
}
- sc = g_hash_table_lookup(
- sp->hash_responses,
+ sc = g_hash_table_lookup(
+ sp->hash_responses,
key);
if (sc==NULL)
return 0;
}
sc->packets++;
- }
+ }
else if (value->request_method){
http_request_methode_t *sc;
- sc = g_hash_table_lookup(
- sp->hash_requests,
+ sc = g_hash_table_lookup(
+ sp->hash_requests,
value->request_method);
if (sc==NULL){
sc=g_malloc( sizeof(http_request_methode_t) );
printf("HTTP Statistics with filter %s\n", sp->filter);
printf( "* HTTP Status Codes in reply packets\n");
- g_hash_table_foreach( sp->hash_responses, (GHFunc)http_draw_hash_responses,
+ g_hash_table_foreach( sp->hash_responses, (GHFunc)http_draw_hash_responses,
" HTTP %3d %s\n");
printf("* List of HTTP Request methods\n");
- g_hash_table_foreach( sp->hash_requests, (GHFunc)http_draw_hash_requests,
+ g_hash_table_foreach( sp->hash_requests, (GHFunc)http_draw_hash_requests,
" %9s %d \n");
printf("===================================================================\n");
}
httpstat_t *sp;
const char *filter=NULL;
GString *error_string;
-
+
if (!strncmp (optarg, "http,stat,", 10)){
filter=optarg+10;
} else {
filter=NULL;
}
-
+
sp = g_malloc( sizeof(httpstat_t) );
if(filter){
- sp->filter=g_malloc(strlen(filter)+1);
- strcpy(sp->filter,filter);
+ sp->filter=g_strdup(filter);
} else {
sp->filter=NULL;
}
/*g_hash_table_foreach( http_status, (GHFunc)http_reset_hash_responses, NULL);*/
- error_string = register_tap_listener(
+ error_string = register_tap_listener(
"http",
sp,
filter,
+ 0,
httpstat_reset,
httpstat_packet,
httpstat_draw);
/* error, we failed to attach to the tap. clean up */
g_free(sp->filter);
g_free(sp);
- fprintf (stderr, "tethereal: Couldn't register http,stat tap: %s\n",
+ fprintf (stderr, "tshark: Couldn't register http,stat tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);