/* circuit.c
* Routines for building lists of packets that are part of a "circuit"
*
- * $Id: circuit.c,v 1.5 2002/11/27 22:44:41 guy Exp $
+ * $Id: circuit.c,v 1.6 2002/11/28 08:12:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
circuit = g_mem_chunk_alloc(circuit_chunk);
circuit->next = NULL;
- circuit->first_frame = first_frame;
circuit->last_frame = 0; /* not known yet */
circuit->index = new_index;
circuit->data_list = NULL;
find_circuit(circuit_type ctype, guint32 circuit_id, guint32 frame)
{
circuit_key key;
- circuit_t *circuit;
+ circuit_t *circuit, *prev_circuit;
key.ctype = ctype;
key.circuit_id = circuit_id;
* OK, search the list of circuits with that type and ID for
* a circuit whose range of frames includes that frame number.
*/
- for (circuit = g_hash_table_lookup(circuit_hashtable, &key);
- circuit != NULL; circuit = circuit->next) {
+ for (circuit = g_hash_table_lookup(circuit_hashtable, &key), prev_circuit = NULL;
+ circuit != NULL; prev_circuit = circuit, circuit = circuit->next) {
/*
- * The frame includes that frame number if:
+ * This circuit includes that frame number if:
*
- * the circuit's first frame is unknown or is at or
- * before that frame
+ * there is no previous circuit or the previous
+ * circuit's last frame is before that frame
+ * (so that the previous circuit doesn't include
+ * that frame)
*
* and
*
* the circuit's last frame is unknown or is at or
* after that frame.
*/
- if ((circuit->first_frame == 0 || circuit->first_frame <= frame)
+ if ((prev_circuit == NULL || prev_circuit->last_frame < frame)
&& (circuit->last_frame == 0 || circuit->last_frame >= frame))
break;
}
/* circuit.h
* Routines for building lists of packets that are part of a "circuit"
*
- * $Id: circuit.h,v 1.3 2002/11/08 01:00:07 guy Exp $
+ * $Id: circuit.h,v 1.4 2002/11/28 08:12:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
typedef struct circuit {
struct circuit *next; /* pointer to next circuit with given circuit ID */
- guint32 first_frame; /* # of first frame for that circuit */
guint32 last_frame; /* # of last frame for that circuit */
guint32 index; /* unique ID for circuit */
GSList *data_list; /* list of data associated with circuit */