~ubuntu-branches/ubuntu/edgy/openssh/edgy

« back to all changes in this revision

Viewing changes to packet.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2004-10-07 18:03:06 UTC
  • Revision ID: james.westby@ubuntu.com-20041007180306-0l8ii961txetbucx
Tags: 1:3.8.1p1-11ubuntu3
* Nathaniel McCallum:
  - debian/openssh-server.init: pretty initscript
  - debian/control: versioned depend on lsb-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
static int connection_in = -1;
80
80
static int connection_out = -1;
81
81
 
 
82
static int setup_timeout = -1;
 
83
 
82
84
/* Protocol flags for the remote side. */
83
85
static u_int remote_protocol_flags = 0;
84
86
 
146
148
 * packet_set_encryption_key is called.
147
149
 */
148
150
void
149
 
packet_set_connection(int fd_in, int fd_out)
 
151
packet_set_connection(int fd_in, int fd_out, int new_setup_timeout)
150
152
{
151
153
        Cipher *none = cipher_by_name("none");
152
154
 
154
156
                fatal("packet_set_connection: cannot load cipher 'none'");
155
157
        connection_in = fd_in;
156
158
        connection_out = fd_out;
 
159
        setup_timeout = new_setup_timeout;
157
160
        cipher_init(&send_context, none, "", 0, NULL, 0, CIPHER_ENCRYPT);
158
161
        cipher_init(&receive_context, none, "", 0, NULL, 0, CIPHER_DECRYPT);
159
162
        newkeys[MODE_IN] = newkeys[MODE_OUT] = NULL;
828
831
        int type, len;
829
832
        fd_set *setp;
830
833
        char buf[8192];
 
834
        struct timeval tv, *tvp;
831
835
        DBG(debug("packet_read()"));
832
836
 
833
837
        setp = (fd_set *)xmalloc(howmany(connection_in+1, NFDBITS) *
859
863
                    sizeof(fd_mask));
860
864
                FD_SET(connection_in, setp);
861
865
 
 
866
                if (setup_timeout > 0) {
 
867
                  tvp = &tv;
 
868
                  tv.tv_sec = setup_timeout;
 
869
                  tv.tv_usec = 0;
 
870
                } else
 
871
                  tvp = 0;
 
872
 
862
873
                /* Wait for some data to arrive. */
863
 
                while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 &&
 
874
                while (select(connection_in + 1, setp, NULL, NULL, tvp) == -1 &&
864
875
                    (errno == EAGAIN || errno == EINTR))
865
876
                        ;
866
877
 
 
878
                if (!FD_ISSET(connection_in, setp))
 
879
                  fatal("packet_read: Setup timeout expired, giving up");
 
880
 
867
881
                /* Read data from the socket. */
868
882
                len = read(connection_in, buf, sizeof(buf));
869
883
                if (len == 0) {