Skip to content

Commit 5e54531

Browse files
authored
Remove ndpi_set_proto_defaults() from the API (#2863)
Add an explicit field to indicate if the protocol is custom or internal
1 parent 084f46e commit 5e54531

File tree

5 files changed

+700
-377
lines changed

5 files changed

+700
-377
lines changed

example/ndpiReader.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ static void help(u_int long_help) {
753753
sizeof(((struct ndpi_flow_struct *)0)->protos));
754754

755755
printf("\n\nnDPI supported protocols:\n");
756-
printf("%3s %8s %-22s %-10s %-8s %-12s %-18s %-31s %-31s \n",
757-
"Id", "Userd-id", "Protocol", "Layer_4", "Nw_Proto", "Breed", "Category","Def UDP Port/s","Def TCP Port/s");
756+
printf("%3s %8s %-26s %-10s %-8s %-21s %-18s %-31s %-31s %6s\n",
757+
"Id", "Userd-id", "Protocol", "Layer_4", "Nw_Proto", "Breed", "Category","Def UDP Port/s","Def TCP Port/s", "Custom");
758758
num_threads = 1;
759759

760760
ndpi_dump_protocols(ndpi_str, stdout);

fuzz/fuzz_config.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
706706
ndpi_is_subprotocol_informative(ndpi_info_mod, pid);
707707
ndpi_get_proto_breed(ndpi_info_mod, pid);
708708

709-
ndpi_port_range d_port[MAX_DEFAULT_PORTS] = {};
710-
ndpi_set_proto_defaults(ndpi_info_mod, 0, 0, NDPI_PROTOCOL_SAFE, pid,
711-
protoname, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED,
712-
NDPI_PROTOCOL_QOE_CATEGORY_UNSPECIFIED,
713-
d_port, d_port);
714-
715709
ndpi_get_proto_by_name(ndpi_info_mod, NULL); /* Error */
716710
ndpi_get_proto_by_name(ndpi_info_mod, "foo"); /* Invalid protocol */
717711
ndpi_get_proto_name(ndpi_info_mod, pid);

src/include/ndpi_main.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,7 @@ extern "C" {
8585
int ndpi_handle_ipv6_extension_headers(u_int16_t l3len,
8686
const u_int8_t ** l4ptr, u_int16_t * l4len,
8787
u_int8_t * nxt_hdr);
88-
89-
void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_str,
90-
u_int8_t is_cleartext, u_int8_t is_app_protocol,
91-
ndpi_protocol_breed_t breed,
92-
u_int16_t protoId, char *protoName,
93-
ndpi_protocol_category_t protoCategory,
94-
ndpi_protocol_qoe_category_t qoeCategory,
95-
ndpi_port_range *tcpDefPorts,
96-
ndpi_port_range *udpDefPorts);
88+
9789
void ndpi_set_risk(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow,
9890
ndpi_risk_enum r, char *risk_message);
9991
void ndpi_unset_risk(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow, ndpi_risk_enum r);

src/include/ndpi_typedefs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,11 +1215,10 @@ typedef enum {
12151215
NDPI_PROTOCOL_QOE_CATEGORY_MAX /* Leave it as last entry !!! */
12161216
} ndpi_protocol_qoe_category_t;
12171217

1218-
/* ntop extensions */
12191218
typedef struct ndpi_proto_defaults {
12201219
char *protoName;
12211220
ndpi_protocol_category_t protoCategory;
1222-
u_int8_t isClearTextProto:1, isAppProtocol:1, _notused:6;
1221+
u_int8_t isClearTextProto:1, isAppProtocol:1, isCustomProto:1, _notused:5;
12231222
u_int16_t *subprotocols;
12241223
u_int32_t subprotocol_count;
12251224
u_int16_t protoId, dissector_idx;

0 commit comments

Comments
 (0)