00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <ctype.h>
00023
00024 #ifdef HAVE_STRING_H
00025 #include <string.h>
00026 #endif
00027
00028 #ifdef HAVE_ERRNO_H
00029 #include <errno.h>
00030 #endif
00031
00032 #include "protocol.h"
00033
00044 int check_ssh(Port_T p) {
00045
00046 char buf[STRLEN];
00047
00048 ASSERT(p);
00049
00050 if(port_recv(p, buf, sizeof(buf), 0) <= 0) {
00051 log("SSH: error receiving identification string -- %s\n", STRERROR);
00052 return FALSE;
00053 }
00054
00055 chomp(buf);
00056
00057 if(strncmp(buf, "SSH-", 4) != 0) {
00058 log("SSH: protocol error %s\n", buf);
00059 return FALSE;
00060 }
00061
00062
00063 if(port_send(p, buf, strlen(buf), 0) <= 0) {
00064 log("SSH: error sending identification string -- %s\n", STRERROR);
00065 return FALSE;
00066 }
00067
00068 return TRUE;
00069 }