*/
#include "includes.h"
-RCSID("$OpenBSD: packet.c,v 1.76 2001/12/19 17:16:13 stevesk Exp $");
+RCSID("$OpenBSD: packet.c,v 1.77 2001/12/20 22:50:24 djm Exp $");
#include "xmalloc.h"
#include "buffer.h"
*/
int
-packet_read(int *payload_len_ptr)
+packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
{
int type, len;
fd_set *setp;
/* Stay in the loop until we have received a complete packet. */
for (;;) {
/* Try to read a packet from the buffer. */
- type = packet_read_poll(payload_len_ptr);
+ type = packet_read_poll_seqnr(payload_len_ptr, seqnr_p);
if (!compat20 && (
type == SSH_SMSG_SUCCESS
|| type == SSH_SMSG_FAILURE
/* NOTREACHED */
}
+int
+packet_read(int *payload_len_ptr)
+{
+ return packet_read_seqnr(payload_len_ptr, NULL);
+}
+
/*
* Waits until a packet has been received, verifies that its type matches
* that given, and gives a fatal error and exits if there is a mismatch.
/* Test check bytes. */
if (len != buffer_len(&incoming_packet))
- packet_disconnect("packet_read_poll: len %d != buffer_len %d.",
+ packet_disconnect("packet_read_poll1: len %d != buffer_len %d.",
len, buffer_len(&incoming_packet));
ucp = (u_char *) buffer_ptr(&incoming_packet) + len - 4;
}
static int
-packet_read_poll2(int *payload_len_ptr)
+packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p)
{
static u_int32_t seqnr = 0;
static u_int packet_length = 0;
DBG(debug("MAC #%d ok", seqnr));
buffer_consume(&input, mac->mac_len);
}
+ if (seqnr_p != NULL)
+ *seqnr_p = seqnr;
if (++seqnr == 0)
log("incoming seqnr wraps around");
}
int
-packet_read_poll(int *payload_len_ptr)
+packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
{
int reason;
u_char type;
for (;;) {
if (compat20) {
- type = packet_read_poll2(payload_len_ptr);
+ type = packet_read_poll2(payload_len_ptr, seqnr_p);
if (type)
DBG(debug("received packet type %d", type));
switch (type) {
}
}
+int
+packet_read_poll(int *payload_len_ptr)
+{
+ return packet_read_poll_seqnr(payload_len_ptr, NULL);
+}
+
/*
* Buffers the given amount of input characters. This is intended to be used
* together with packet_read_poll.