diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-03-26 21:47:34 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-03-26 21:47:34 +0000 |
commit | 4430cf503d014b707ea01f0ab9c4c7b9c201e3ce (patch) | |
tree | ac54ab9c1489c3c00b3ec29cfa1c89b4fba2622d /packet-ajp13.c | |
parent | da624293e3fa881d887d7fa6d601e535ce76c22d (diff) |
Use "gboolean" for Boolean variables.
Allocate the per-conversation and per-frame data items from a GMemChunk
(which saves memory and CPU time, *and* lets us free all those items
quickly - as opposed to not freeing them at all, as had been the case).
Don't assume that, just because a conversation for the TCP connection
exists, it necessarily has an AJP13 data chunk attached to it; the
conversation might have, for example, been created by the TCP sequence
number analysis code.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7374 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-ajp13.c')
-rw-r--r-- | packet-ajp13.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/packet-ajp13.c b/packet-ajp13.c index 29f0331311..24d2e9c738 100644 --- a/packet-ajp13.c +++ b/packet-ajp13.c @@ -2,7 +2,7 @@ * Routines for AJP13 dissection * Copyright 2002, Christopher K. St. John <cks@distributopia.com> * - * $Id: packet-ajp13.c,v 1.9 2003/01/27 22:19:10 deniel Exp $ + * $Id: packet-ajp13.c,v 1.10 2003/03/26 21:47:34 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -219,15 +219,18 @@ static gint ett_ajp13 = -1; typedef struct ajp13_conv_data { int content_length; - int was_get_body_chunk; + gboolean was_get_body_chunk; /* XXX - not used */ } ajp13_conv_data; +static GMemChunk *ajp13_conv_data_chunk = NULL; typedef struct ajp13_frame_data { - int is_request_body; + gboolean is_request_body; } ajp13_frame_data; +static GMemChunk *ajp13_frame_data_chunk = NULL; +static int ajp13_packet_init_count = 100; /* ajp13, in sort of a belt-and-suspenders move, encodes strings with * both a leading length field, and a trailing null. Mostly, see @@ -642,12 +645,13 @@ dissect_ajp13_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (!conv) { conv = conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); - cd = (ajp13_conv_data*)malloc(sizeof(ajp13_conv_data)); + } + cd = (ajp13_conv_data*)conversation_get_proto_data(conv, proto_ajp13); + if (!cd) { + cd = (ajp13_conv_data*)g_mem_chunk_alloc(ajp13_conv_data_chunk); cd->content_length = 0; - cd->was_get_body_chunk = 0; + cd->was_get_body_chunk = FALSE; conversation_add_proto_data(conv, proto_ajp13, cd); - } else { - cd = (ajp13_conv_data*)conversation_get_proto_data(conv, proto_ajp13); } /* we use the per segment user data to record the conversational @@ -661,16 +665,16 @@ dissect_ajp13_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * time we've see the packet, and it must be the first "in order" * pass through the data. */ - fd = (ajp13_frame_data*)malloc(sizeof(ajp13_frame_data)); + fd = (ajp13_frame_data*)g_mem_chunk_alloc(ajp13_frame_data_chunk); p_add_proto_data(pinfo->fd, proto_ajp13, fd); - fd->is_request_body = 0; + fd->is_request_body = FALSE; if (cd->content_length) { /* this is screwy, see AJPv13.html. the idea is that if the * request has a body (as determined by the content-length * header), then there's always an immediate follow-up PDU with * no GET_BODY_CHUNK from the container. */ - fd->is_request_body = 1; + fd->is_request_body = TRUE; } } @@ -747,6 +751,25 @@ dissect_ajp13(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static void +ajp13_init_protocol(void) +{ + if (ajp13_conv_data_chunk) + g_mem_chunk_destroy(ajp13_conv_data_chunk); + if (ajp13_frame_data_chunk) + g_mem_chunk_destroy(ajp13_frame_data_chunk); + + ajp13_conv_data_chunk = g_mem_chunk_new("ajp13_conv_data_chunk", + sizeof(ajp13_conv_data), + ajp13_packet_init_count * sizeof(ajp13_conv_data), + G_ALLOC_ONLY); + + ajp13_frame_data_chunk = g_mem_chunk_new("ajp13_frame_data_chunk", + sizeof(ajp13_frame_data), + ajp13_packet_init_count * sizeof(ajp13_frame_data), + G_ALLOC_ONLY); +} + void proto_register_ajp13(void) { @@ -839,6 +862,8 @@ proto_register_ajp13(void) proto_register_field_array(proto_ajp13, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + register_init_routine(&ajp13_init_protocol); } |