comparison common-session.c @ 24:469950e86d0f

switching to global vars
author Matt Johnston <matt@ucc.asn.au>
date Tue, 20 Jul 2004 12:05:00 +0000
parents c1e5d9195402
children 0969767bca0d
comparison
equal deleted inserted replaced
23:c896a4dd65da 24:469950e86d0f
33 #include "random.h" 33 #include "random.h"
34 #include "kex.h" 34 #include "kex.h"
35 #include "channel.h" 35 #include "channel.h"
36 #include "atomicio.h" 36 #include "atomicio.h"
37 37
38 struct sshsession ses; 38 struct sshsession ses; /* GLOBAL */
39 39
40 /* need to know if the session struct has been initialised, this way isn't the 40 /* need to know if the session struct has been initialised, this way isn't the
41 * cleanest, but works OK */ 41 * cleanest, but works OK */
42 int sessinitdone = 0; 42 int sessinitdone = 0; /* GLOBAL */
43 43
44 /* this is set when we get SIGINT or SIGTERM, the handler is in main.c */ 44 /* this is set when we get SIGINT or SIGTERM, the handler is in main.c */
45 int exitflag = 0; 45 int exitflag = 0; /* GLOBAL */
46 46
47 static int ident_readln(int fd, char* buf, int count); 47 static int ident_readln(int fd, char* buf, int count);
48 48
49 49
50 void(*session_remoteclosed)() = NULL; 50 void(*session_remoteclosed)() = NULL;
51 51
52 52
53 /* called only at the start of a session, set up initial state */ 53 /* called only at the start of a session, set up initial state */
54 void common_session_init(int sock, runopts *opts) { 54 void common_session_init(int sock) {
55 55
56 TRACE(("enter session_init")); 56 TRACE(("enter session_init"));
57 57
58 ses.remoteaddr = NULL; 58 ses.remoteaddr = NULL;
59 ses.remotehost = NULL; 59 ses.remotehost = NULL;
60 60
61 ses.sock = sock; 61 ses.sock = sock;
62 ses.maxfd = sock; 62 ses.maxfd = sock;
63
64 ses.opts = opts;
65 63
66 ses.connecttimeout = 0; 64 ses.connecttimeout = 0;
67 65
68 kexinitialise(); /* initialise the kex state */ 66 kexinitialise(); /* initialise the kex state */
69 chaninitialise(); /* initialise the channel state */ 67 chaninitialise(); /* initialise the channel state */
126 TRACE(("leave session_cleanup: !sessinitdone")); 124 TRACE(("leave session_cleanup: !sessinitdone"));
127 return; 125 return;
128 } 126 }
129 127
130 m_free(ses.session_id); 128 m_free(ses.session_id);
131 freerunopts(ses.opts);
132 m_burn(ses.keys, sizeof(struct key_context)); 129 m_burn(ses.keys, sizeof(struct key_context));
133 m_free(ses.keys); 130 m_free(ses.keys);
134 131
135 chancleanup(); 132 chancleanup();
136 133