summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-01-22 23:16:32 +1100
committerDamien Miller <djm@mindrot.org>2002-01-22 23:16:32 +1100
commitdff5099f13e2e679b93d3cfe7073c9cd92b19b06 (patch)
treef80cf1916ad026e5550e61da139e52899fa04629 /packet.c
parent76e1e368b561cabeb55c21dc205c3f6805179ad5 (diff)
- markus@cvs.openbsd.org 2001/12/28 14:50:54
[auth1.c auth-rsa.c channels.c dispatch.c kex.c kexdh.c kexgex.c packet.c packet.h serverloop.c session.c ssh.c sshconnect1.c sshconnect2.c sshd.c] packet_read* no longer return the packet length, since it's not used.
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/packet.c b/packet.c
index 593fb707c..3b2522356 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.81 2001/12/28 14:13:13 markus Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.82 2001/12/28 14:50:54 markus Exp $");
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "buffer.h" 43#include "buffer.h"
@@ -610,7 +610,7 @@ packet_send(void)
610 */ 610 */
611 611
612int 612int
613packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) 613packet_read_seqnr(u_int32_t *seqnr_p)
614{ 614{
615 int type, len; 615 int type, len;
616 fd_set *setp; 616 fd_set *setp;
@@ -626,7 +626,7 @@ packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
626 /* Stay in the loop until we have received a complete packet. */ 626 /* Stay in the loop until we have received a complete packet. */
627 for (;;) { 627 for (;;) {
628 /* Try to read a packet from the buffer. */ 628 /* Try to read a packet from the buffer. */
629 type = packet_read_poll_seqnr(payload_len_ptr, seqnr_p); 629 type = packet_read_poll_seqnr(seqnr_p);
630 if (!compat20 && ( 630 if (!compat20 && (
631 type == SSH_SMSG_SUCCESS 631 type == SSH_SMSG_SUCCESS
632 || type == SSH_SMSG_FAILURE 632 || type == SSH_SMSG_FAILURE
@@ -666,9 +666,9 @@ packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
666} 666}
667 667
668int 668int
669packet_read(int *payload_len_ptr) 669packet_read(void)
670{ 670{
671 return packet_read_seqnr(payload_len_ptr, NULL); 671 return packet_read_seqnr(NULL);
672} 672}
673 673
674/* 674/*
@@ -677,11 +677,11 @@ packet_read(int *payload_len_ptr)
677 */ 677 */
678 678
679void 679void
680packet_read_expect(int *payload_len_ptr, int expected_type) 680packet_read_expect(int expected_type)
681{ 681{
682 int type; 682 int type;
683 683
684 type = packet_read(payload_len_ptr); 684 type = packet_read();
685 if (type != expected_type) 685 if (type != expected_type)
686 packet_disconnect("Protocol error: expected packet type %d, got %d", 686 packet_disconnect("Protocol error: expected packet type %d, got %d",
687 expected_type, type); 687 expected_type, type);
@@ -694,16 +694,10 @@ packet_read_expect(int *payload_len_ptr, int expected_type)
694 * SSH_MSG_DISCONNECT is handled specially here. Also, 694 * SSH_MSG_DISCONNECT is handled specially here. Also,
695 * SSH_MSG_IGNORE messages are skipped by this function and are never returned 695 * SSH_MSG_IGNORE messages are skipped by this function and are never returned
696 * to higher levels. 696 * to higher levels.
697 *
698 * The returned payload_len does include space consumed by:
699 * Packet length
700 * Padding
701 * Packet type
702 * Check bytes
703 */ 697 */
704 698
705static int 699static int
706packet_read_poll1(int *payload_len_ptr) 700packet_read_poll1(void)
707{ 701{
708 u_int len, padded_len; 702 u_int len, padded_len;
709 u_char *ucp, type; 703 u_char *ucp, type;
@@ -776,12 +770,11 @@ packet_read_poll1(int *payload_len_ptr)
776 buffer_len(&compression_buffer)); 770 buffer_len(&compression_buffer));
777 } 771 }
778 type = buffer_get_char(&incoming_packet); 772 type = buffer_get_char(&incoming_packet);
779 *payload_len_ptr = buffer_len(&incoming_packet);
780 return type; 773 return type;
781} 774}
782 775
783static int 776static int
784packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) 777packet_read_poll2(u_int32_t *seqnr_p)
785{ 778{
786 static u_int32_t seqnr = 0; 779 static u_int32_t seqnr = 0;
787 static u_int packet_length = 0; 780 static u_int packet_length = 0;
@@ -887,7 +880,6 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p)
887 type = buffer_get_char(&incoming_packet); 880 type = buffer_get_char(&incoming_packet);
888 if (type == SSH2_MSG_NEWKEYS) 881 if (type == SSH2_MSG_NEWKEYS)
889 set_newkeys(MODE_IN); 882 set_newkeys(MODE_IN);
890 *payload_len_ptr = buffer_len(&incoming_packet);
891#ifdef PACKET_DEBUG 883#ifdef PACKET_DEBUG
892 fprintf(stderr, "read/plain[%d]:\r\n", type); 884 fprintf(stderr, "read/plain[%d]:\r\n", type);
893 buffer_dump(&incoming_packet); 885 buffer_dump(&incoming_packet);
@@ -898,7 +890,7 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p)
898} 890}
899 891
900int 892int
901packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) 893packet_read_poll_seqnr(u_int32_t *seqnr_p)
902{ 894{
903 int reason; 895 int reason;
904 u_char type; 896 u_char type;
@@ -906,7 +898,7 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
906 898
907 for (;;) { 899 for (;;) {
908 if (compat20) { 900 if (compat20) {
909 type = packet_read_poll2(payload_len_ptr, seqnr_p); 901 type = packet_read_poll2(seqnr_p);
910 if (type) 902 if (type)
911 DBG(debug("received packet type %d", type)); 903 DBG(debug("received packet type %d", type));
912 switch (type) { 904 switch (type) {
@@ -933,7 +925,7 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
933 break; 925 break;
934 } 926 }
935 } else { 927 } else {
936 type = packet_read_poll1(payload_len_ptr); 928 type = packet_read_poll1();
937 switch (type) { 929 switch (type) {
938 case SSH_MSG_IGNORE: 930 case SSH_MSG_IGNORE:
939 break; 931 break;
@@ -960,9 +952,9 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
960} 952}
961 953
962int 954int
963packet_read_poll(int *payload_len_ptr) 955packet_read_poll(void)
964{ 956{
965 return packet_read_poll_seqnr(payload_len_ptr, NULL); 957 return packet_read_poll_seqnr(NULL);
966} 958}
967 959
968/* 960/*