增加对ssh协议支持
This commit is contained in:
@@ -37,6 +37,7 @@ typedef enum _tsg_protocol
|
|||||||
PROTO_SIP,
|
PROTO_SIP,
|
||||||
PROTO_BGP,
|
PROTO_BGP,
|
||||||
PROTO_STREAMING_MEDIA,
|
PROTO_STREAMING_MEDIA,
|
||||||
|
PROTO_SSH,
|
||||||
PROTO_MAX
|
PROTO_MAX
|
||||||
}tsg_protocol_t;
|
}tsg_protocol_t;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
|
|||||||
|
|
||||||
add_definitions(-fPIC)
|
add_definitions(-fPIC)
|
||||||
|
|
||||||
set(SRC tsg_entry.cpp tsg_rule.cpp tsg_ssl_utils.cpp tsg_send_log.cpp tsg_statistic.cpp)
|
set(SRC tsg_entry.cpp tsg_rule.cpp tsg_ssl_utils.cpp tsg_send_log.cpp tsg_statistic.cpp tsg_ssh_utils.cpp)
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/inc)
|
include_directories(${CMAKE_SOURCE_DIR}/inc)
|
||||||
include_directories(/opt/MESA/include/MESA/)
|
include_directories(/opt/MESA/include/MESA/)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "tsg_statistic.h"
|
#include "tsg_statistic.h"
|
||||||
#include "tsg_send_log_internal.h"
|
#include "tsg_send_log_internal.h"
|
||||||
#include "tsg_ssl_utils.h"
|
#include "tsg_ssl_utils.h"
|
||||||
|
#include "tsg_ssh_utils.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -247,6 +248,9 @@ static char *schema_index2string(tsg_protocol_t proto)
|
|||||||
case PROTO_STREAMING_MEDIA:
|
case PROTO_STREAMING_MEDIA:
|
||||||
schema_field_value=(char *)"STREAMING_MEDIA";
|
schema_field_value=(char *)"STREAMING_MEDIA";
|
||||||
break;
|
break;
|
||||||
|
case PROTO_SSH:
|
||||||
|
schema_field_value=(char *)"SSH";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -402,7 +406,13 @@ static int identify_application_protocol(struct streaminfo *a_stream, struct _id
|
|||||||
}
|
}
|
||||||
|
|
||||||
//mail
|
//mail
|
||||||
|
ret = ssh_protocol_identify((unsigned char *)a_stream->ptcpdetail->pdata, (unsigned int)a_stream->ptcpdetail->datalen,g_tsg_para.logger);
|
||||||
|
if(ret > 0)
|
||||||
|
{
|
||||||
|
identify_info->proto=PROTO_SSH;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
//ssh
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ const struct _str2index g_tsg_proto_string[PROTO_MAX+1]={{PROTO_UNKONWN, 0, (cha
|
|||||||
{PROTO_SIP, 4, (char *)"SIP."},
|
{PROTO_SIP, 4, (char *)"SIP."},
|
||||||
{PROTO_BGP, 4, (char *)"BGP."},
|
{PROTO_BGP, 4, (char *)"BGP."},
|
||||||
{PROTO_STREAMING_MEDIA, 16, (char *)"STREAMING_MEDIA."},
|
{PROTO_STREAMING_MEDIA, 16, (char *)"STREAMING_MEDIA."},
|
||||||
|
{PROTO_SSH, 4, (char *)"SSH."},
|
||||||
{PROTO_MAX, 0, (char *)""}
|
{PROTO_MAX, 0, (char *)""}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
22
src/tsg_ssh_utils.cpp
Normal file
22
src/tsg_ssh_utils.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "tsg_ssh_utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define SSH_PROTOCOL_FIELD "SSH"
|
||||||
|
#define SSH_PROTOCOL_FIELD_LEN 3
|
||||||
|
|
||||||
|
|
||||||
|
int ssh_protocol_identify(const unsigned char* buff, size_t buff_len, void* argp)
|
||||||
|
{
|
||||||
|
void *logger=argp;
|
||||||
|
if(buff == NULL || buff_len < SSH_PROTOCOL_FIELD_LEN)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(memcmp((void *)buff,SSH_PROTOCOL_FIELD, SSH_PROTOCOL_FIELD_LEN) == 0)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
7
src/tsg_ssh_utils.h
Normal file
7
src/tsg_ssh_utils.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __TSG_SSH_UTILS_H__
|
||||||
|
#define __TSG_SSH_UTILS_H__
|
||||||
|
#include <string.h>
|
||||||
|
#include <MESA/MESA_handle_logger.h>
|
||||||
|
int ssh_protocol_identify(const unsigned char* buff, size_t buff_len, void* argp);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user