+void
+packet_set_timeout(int timeout, int count)
+{
+ if (timeout == 0 || count == 0) {
+ active_state->packet_timeout_ms = -1;
+ return;
+ }
+ if ((INT_MAX / 1000) / count < timeout)
+ active_state->packet_timeout_ms = INT_MAX;
+ else
+ active_state->packet_timeout_ms = timeout * count * 1000;
+}
+
+static void
+packet_stop_discard(void)
+{
+ if (active_state->packet_discard_mac) {
+ char buf[1024];
+
+ memset(buf, 'a', sizeof(buf));
+ while (buffer_len(&active_state->incoming_packet) <
+ PACKET_MAX_SIZE)
+ buffer_append(&active_state->incoming_packet, buf,
+ sizeof(buf));
+ (void) mac_compute(active_state->packet_discard_mac,
+ active_state->p_read.seqnr,
+ buffer_ptr(&active_state->incoming_packet),
+ PACKET_MAX_SIZE);
+ }
+ logit("Finished discarding for %.200s", get_remote_ipaddr());
+ cleanup_exit(255);
+}
+
+static void
+packet_start_discard(Enc *enc, Mac *mac, u_int packet_length, u_int discard)
+{
+ if (enc == NULL || !cipher_is_cbc(enc->cipher))
+ packet_disconnect("Packet corrupt");
+ if (packet_length != PACKET_MAX_SIZE && mac && mac->enabled)
+ active_state->packet_discard_mac = mac;
+ if (buffer_len(&active_state->input) >= discard)
+ packet_stop_discard();
+ active_state->packet_discard = discard -
+ buffer_len(&active_state->input);
+}
+