/* Given a circuit type and ID, and a frame number, search for a circuit with that type and ID whose range of frames includes that frame number. Returns NULL if not found.  */
circuit_t* find_circuit(circuit_type ctype, guint32 circuit_id, guint32 frame)
/* Given a circuit type and ID, and a frame number, search for a circuit with that type and ID whose range of frames includes that frame number. Returns NULL if not found.  */
circuit_t* find_circuit(circuit_type ctype, guint32 circuit_id, guint32 frame)
{
	circuit_key key;
	circuit_t *circuit;
	key.ctype = ctype;
	key.circuit_id = circuit_id;
	for (circuit = (circuit_t *)g_hash_table_lookup(circuit_hashtable, &key);
	    circuit != NULL; circuit = circuit->next) {
		if ((circuit->first_frame == 0 || circuit->first_frame <= frame)
		    && (circuit->last_frame == 0 || circuit->last_frame >= frame))
			break;
	}
	return circuit;
}