]> andersk Git - openssh.git/blobdiff - packet.c
- djm@cvs.openbsd.org 2001/12/20 22:50:24
[openssh.git] / packet.c
index 4b3eafc880b7b76b55a406ab886d8d5c673ed7dc..17165b69691a44528ea7d041a6098c0135f0e191 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
  */
 
 #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"
@@ -610,7 +610,7 @@ packet_send(void)
  */
 
 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;
@@ -626,7 +626,7 @@ packet_read(int *payload_len_ptr)
        /* 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
@@ -665,6 +665,12 @@ packet_read(int *payload_len_ptr)
        /* 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.
@@ -753,7 +759,7 @@ packet_read_poll1(int *payload_len_ptr)
 
        /* 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;
@@ -775,7 +781,7 @@ packet_read_poll1(int *payload_len_ptr)
 }
 
 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;
@@ -848,6 +854,8 @@ packet_read_poll2(int *payload_len_ptr)
                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");
 
@@ -890,7 +898,7 @@ packet_read_poll2(int *payload_len_ptr)
 }
 
 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;
@@ -898,7 +906,7 @@ packet_read_poll(int *payload_len_ptr)
 
        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) {
@@ -951,6 +959,12 @@ packet_read_poll(int *payload_len_ptr)
        }
 }
 
+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.
This page took 0.121678 seconds and 4 git commands to generate.