Added ndpi_guess_undetected_protocol_v4() to restore logic that
was removed in https://github.com/ntop/nDPI/commit/032e778a6dc1ee2173c4cdb2c671180c5b5df245
This commit is contained in:
@@ -433,6 +433,27 @@ extern "C" {
|
|||||||
ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int8_t proto);
|
u_int8_t proto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Superset of ndpi_guess_undetected_protocol with additional IPv4 guess based on host/port
|
||||||
|
*
|
||||||
|
* @par ndpi_struct = the detection module
|
||||||
|
* @par flow = the flow we're trying to guess, NULL if not available
|
||||||
|
* @par proto = the l4 protocol number
|
||||||
|
* @par shost = source address in host byte order
|
||||||
|
* @par sport = source port number
|
||||||
|
* @par dhost = destination address in host byte order
|
||||||
|
* @par dport = destination port number
|
||||||
|
* @return the struct ndpi_protocol that match the port base protocol
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ndpi_protocol ndpi_guess_undetected_protocol_v4(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow,
|
||||||
|
u_int8_t proto,
|
||||||
|
u_int32_t shost,
|
||||||
|
u_int16_t sport,
|
||||||
|
u_int32_t dhost,
|
||||||
|
u_int16_t dport);
|
||||||
/**
|
/**
|
||||||
* Check if the string passed match with a protocol
|
* Check if the string passed match with a protocol
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7933,6 +7933,44 @@ static ndpi_protocol ndpi_internal_guess_undetected_protocol(struct ndpi_detecti
|
|||||||
|
|
||||||
/* ****************************************************** */
|
/* ****************************************************** */
|
||||||
|
|
||||||
|
/* Extension of ndpi_guess_undetected_protocol() with IPv4 matching for host and protocol */
|
||||||
|
|
||||||
|
ndpi_protocol ndpi_guess_undetected_protocol_v4(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
|
struct ndpi_flow_struct *flow, u_int8_t proto,
|
||||||
|
u_int32_t shost /* host byte order */, u_int16_t sport,
|
||||||
|
u_int32_t dhost /* host byte order */, u_int16_t dport) {
|
||||||
|
u_int32_t rc;
|
||||||
|
ndpi_protocol ret = NDPI_PROTOCOL_NULL;
|
||||||
|
u_int8_t user_defined_proto;
|
||||||
|
|
||||||
|
if(!ndpi_str)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if((proto == IPPROTO_TCP) || (proto == IPPROTO_UDP)) {
|
||||||
|
rc = ndpi_search_tcp_or_udp_raw(ndpi_str, flow, proto, shost, dhost);
|
||||||
|
|
||||||
|
if(rc != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
ret.app_protocol = rc,
|
||||||
|
ret.master_protocol = ndpi_guess_protocol_id(ndpi_str, flow, proto, sport, dport, &user_defined_proto);
|
||||||
|
|
||||||
|
if(ret.app_protocol == ret.master_protocol)
|
||||||
|
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
|
||||||
|
} else {
|
||||||
|
ret.app_protocol = ndpi_guess_protocol_id(ndpi_str, flow, proto, sport, dport, &user_defined_proto),
|
||||||
|
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret.app_protocol != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
ret.category = ndpi_get_proto_category(ndpi_str, ret);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ndpi_guess_undetected_protocol(ndpi_str, flow, proto));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************** */
|
||||||
|
|
||||||
ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_str,
|
ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
struct ndpi_flow_struct *flow, u_int8_t proto) {
|
struct ndpi_flow_struct *flow, u_int8_t proto) {
|
||||||
ndpi_protocol p = ndpi_internal_guess_undetected_protocol(ndpi_str, flow, proto);
|
ndpi_protocol p = ndpi_internal_guess_undetected_protocol(ndpi_str, flow, proto);
|
||||||
|
|||||||
Reference in New Issue
Block a user