X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/fa0f0f455ac5f0d6e3e0597842e9f4f4fe58d2b1..9fb46e529d8731bf8ea9981ee29f831b04a55672:/openssh/packet.c diff --git a/openssh/packet.c b/openssh/packet.c index 36656ba..62ef30f 100644 --- a/openssh/packet.c +++ b/openssh/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.148 2007/06/07 19:37:34 pvalchev Exp $ */ +/* $OpenBSD: packet.c,v 1.151 2008/02/22 20:44:02 dtucker Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -136,6 +136,8 @@ static int server_side = 0; /* Set to true if we are authenticated. */ static int after_authentication = 0; +int keep_alive_timeouts = 0; + /* Session key information for Encryption and MAC */ Newkeys *newkeys[MODE_MAX]; static struct packet_state { @@ -710,7 +712,7 @@ packet_enable_delayed_compress(void) /* * Finalize packet in SSH2 format (compress, mac, encrypt, enqueue) */ -static void +static int packet_send2_wrapped(void) { u_char type, *cp, *macbuf = NULL; @@ -822,11 +824,13 @@ packet_send2_wrapped(void) set_newkeys(MODE_OUT); else if (type == SSH2_MSG_USERAUTH_SUCCESS && server_side) packet_enable_delayed_compress(); + return(packet_length); } -static void +static int packet_send2(void) { + static int packet_length = 0; static int rekeying = 0; struct packet *p; u_char type, *cp; @@ -844,7 +848,7 @@ packet_send2(void) memcpy(&p->payload, &outgoing_packet, sizeof(Buffer)); buffer_init(&outgoing_packet); TAILQ_INSERT_TAIL(&outgoing, p, next); - return; + return(sizeof(Buffer)); } } @@ -852,7 +856,7 @@ packet_send2(void) if (type == SSH2_MSG_KEXINIT) rekeying = 1; - packet_send2_wrapped(); + packet_length = packet_send2_wrapped(); /* after a NEWKEYS message we can send the complete queue */ if (type == SSH2_MSG_NEWKEYS) { @@ -865,19 +869,22 @@ packet_send2(void) sizeof(Buffer)); TAILQ_REMOVE(&outgoing, p, next); xfree(p); - packet_send2_wrapped(); + packet_length += packet_send2_wrapped(); } } + return(packet_length); } -void +int packet_send(void) { + int packet_len = 0; if (compat20) - packet_send2(); + packet_len = packet_send2(); else packet_send1(); DBG(debug("packet_send done")); + return(packet_len); } /* @@ -1192,10 +1199,12 @@ packet_read_poll_seqnr(u_int32_t *seqnr_p) for (;;) { if (compat20) { type = packet_read_poll2(seqnr_p); + keep_alive_timeouts = 0; if (type) DBG(debug("received packet type %d", type)); switch (type) { case SSH2_MSG_IGNORE: + debug3("Received SSH2_MSG_IGNORE"); break; case SSH2_MSG_DEBUG: packet_get_char(); @@ -1415,21 +1424,23 @@ packet_disconnect(const char *fmt,...) /* Checks if there is any buffered output, and tries to write some of the output. */ -void +int packet_write_poll(void) { - int len = buffer_len(&output); + int len = 0; + len = buffer_len(&output); if (len > 0) { len = write(connection_out, buffer_ptr(&output), len); if (len <= 0) { if (errno == EAGAIN) - return; + return (0); else fatal("Write failed: %.100s", strerror(errno)); } buffer_consume(&output, len); } + return(len); } /* @@ -1437,14 +1448,15 @@ packet_write_poll(void) * written. */ -void +int packet_write_wait(void) { fd_set *setp; + u_int bytes_sent = 0; setp = (fd_set *)xcalloc(howmany(connection_out + 1, NFDBITS), sizeof(fd_mask)); - packet_write_poll(); + bytes_sent += packet_write_poll(); while (packet_have_data_to_write()) { memset(setp, 0, howmany(connection_out + 1, NFDBITS) * sizeof(fd_mask)); @@ -1452,9 +1464,10 @@ packet_write_wait(void) while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 && (errno == EAGAIN || errno == EINTR)) ; - packet_write_poll(); + bytes_sent += packet_write_poll(); } xfree(setp); + return (bytes_sent); } /* Returns true if there is buffered data to write to the connection. */ @@ -1575,8 +1588,8 @@ packet_send_ignore(int nbytes) rnd >>= 8; } } -int rekey_requested = 0; +int rekey_requested = 0; void packet_request_rekeying(void) { @@ -1618,3 +1631,9 @@ packet_set_authenticated(void) { after_authentication = 1; } + +int +packet_authentication_state(void) +{ + return(after_authentication); +}