dtls1_reset_seq_numbers(SSL *s, int rw)
	{
	unsigned char *seq;
	unsigned int seq_bytes = sizeof(s->s3->read_sequence);

	if ( rw & SSL3_CC_READ)
		{
		seq = s->s3->read_sequence;
		s->d1->r_epoch++;

		pq_64bit_assign(&(s->d1->bitmap.map), &(s->d1->next_bitmap.map));
		s->d1->bitmap.length = s->d1->next_bitmap.length;
		pq_64bit_assign(&(s->d1->bitmap.max_seq_num), 
			&(s->d1->next_bitmap.max_seq_num));

		pq_64bit_free(&(s->d1->next_bitmap.map));
		pq_64bit_free(&(s->d1->next_bitmap.max_seq_num));
		memset(&(s->d1->next_bitmap), 0x00, sizeof(DTLS1_BITMAP));
		pq_64bit_init(&(s->d1->next_bitmap.map));
		pq_64bit_init(&(s->d1->next_bitmap.max_seq_num));
		}
	else
		{
		seq = s->s3->write_sequence;
		memcpy(s->d1->last_write_sequence, seq, sizeof(s->s3->write_sequence));
		s->d1->w_epoch++;
		}

	memset(seq, 0x00, seq_bytes);
	}
dtls1_reset_seq_numbers(SSL *s, int rw)
	{
	unsigned char *seq;
	unsigned int seq_bytes = sizeof(s->s3->read_sequence);

	if ( rw & SSL3_CC_READ)
		{
		seq = s->s3->read_sequence;
		s->d1->r_epoch++;

		pq_64bit_assign(&(s->d1->bitmap.map), &(s->d1->next_bitmap.map));
		s->d1->bitmap.length = s->d1->next_bitmap.length;
		pq_64bit_assign(&(s->d1->bitmap.max_seq_num), 
			&(s->d1->next_bitmap.max_seq_num));

		pq_64bit_free(&(s->d1->next_bitmap.map));
		pq_64bit_free(&(s->d1->next_bitmap.max_seq_num));
		memset(&(s->d1->next_bitmap), 0x00, sizeof(DTLS1_BITMAP));
		pq_64bit_init(&(s->d1->next_bitmap.map));
		pq_64bit_init(&(s->d1->next_bitmap.max_seq_num));
		}
	else
		{
		seq = s->s3->write_sequence;
		memcpy(s->d1->last_write_sequence, seq, sizeof(s->s3->write_sequence));
		s->d1->w_epoch++;
		}

	memset(seq, 0x00, seq_bytes);
	}