source: trunk/third/ssh/emulate.c @ 12646

Revision 12646, 1.8 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12645, which included commits to RCS files with non-trunk default branches.
Line 
1#include "includes.h"
2#include "ssh.h"
3#include "emulate.h"
4
5unsigned long emulation_information = 0;
6
7/* check_emulation: take the remote party's version number as
8   arguments and return our possibly modified version number back
9   (relevant only for clients).
10
11   Return values:
12   EMULATE_VERSION_OK means we can work together
13
14   EMULATE_VERSION_TOO_OLD if the other party has too old version
15   which we cannot emulate,
16
17   EMULATE_MAJOR_VERSION_MISMATCH if the other party has different
18   major version and thus will probably not understand anything we
19   say, and
20
21   EMULATE_VERSION_NEWER if the other party has never code than we
22   have.
23
24   */
25
26int check_emulation(int remote_major, int remote_minor,
27                    int *return_major, int *return_minor)
28{
29  if (return_major)
30    *return_major = PROTOCOL_MAJOR;
31  if (return_minor)
32    {
33      if (remote_minor < PROTOCOL_MINOR)
34        *return_minor = remote_minor;
35      else
36        *return_minor = PROTOCOL_MINOR;
37    }
38
39  if (remote_major < PROTOCOL_MAJOR)
40    return EMULATE_MAJOR_VERSION_MISMATCH;
41
42  if (remote_major == 1 && remote_minor == 0)
43    return EMULATE_VERSION_TOO_OLD;  /* We no longer support 1.0. */
44 
45  if (remote_major == 1 && remote_minor <= 3)
46    {
47      debug("Old channel code will be emulated.");
48      emulation_information |= EMULATE_OLD_CHANNEL_CODE;
49    }
50
51  if (remote_major == 1 && remote_minor <= 4)
52    {
53      emulation_information |= EMULATE_OLD_AGENT_BUG;
54      debug("Agent forwarding disabled (remote protocol too old)");
55    }
56
57  if (remote_major > PROTOCOL_MAJOR ||
58      (remote_major == PROTOCOL_MAJOR && remote_minor > PROTOCOL_MINOR))
59    {
60      /* The remote software is newer than we. If we are the client,
61         no matter - the server will decide. If we are the server, we
62         cannot emulate a newer client and decide to stop. */
63      return EMULATE_VERSION_NEWER;
64    }
65
66  return EMULATE_VERSION_OK;
67}
Note: See TracBrowser for help on using the repository browser.