Skip to content

Commit

Permalink
Cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Jul 13, 2023
1 parent 1f55dc5 commit 33c42f9
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4316,7 +4316,8 @@ int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_str, cons
char *line = buffer;
int line_len = buffer_len;

while((line = fgets(line, line_len, fd)) != NULL && line[strlen(line) - 1] != '\n') {
while(((line = fgets(line, line_len, fd)) != NULL)
&& (line[strlen(line) - 1] != '\n')) {
i = strlen(line);
old_buffer = buffer;
old_buffer_len = buffer_len;
Expand All @@ -4332,16 +4333,26 @@ int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_str, cons

line = &buffer[i];
line_len = chunk_len;
}
} /* while */

if(!line) /* safety check */
break;

i = strlen(buffer);
if((i <= 1) || (buffer[0] == '#'))
continue;
else
else {
buffer[i - 1] = '\0';
i--;

if((i > 0) && (buffer[i-1] == '\r'))
buffer[i - 1] = '\0';

if(buffer[0] == '\0')
continue;
}

/* printf("Processing: \"%s\"\n", buffer); */

if(ndpi_handle_rule(ndpi_str, buffer, 1) != 0)
NDPI_LOG_INFO(ndpi_str, "Discraded rule '%s'\n", buffer);
Expand Down Expand Up @@ -6099,15 +6110,15 @@ static void ndpi_reconcile_msteams_udp(struct ndpi_detection_module_struct *ndpi
static int ndpi_reconcile_msteams_call_udp_port(struct ndpi_detection_module_struct *ndpi_str,
struct ndpi_flow_struct *flow,
u_int16_t sport, u_int16_t dport) {

/*
https://extremeportal.force.com/ExtrArticleDetail?an=000101782
Audio: UDP 50000-50019; 3478; 3479
Video: UDP 50020-50039; 3480
Sharing: UDP 50040-50059; 3481
*/

if((dport == 3478) || (dport == 3479) || ((sport >= 50000) && (sport <= 50019)))
flow->flow_multimedia_type = ndpi_multimedia_audio_flow;
else if((dport == 3480) || ((sport >= 50020) && (sport <= 50039)))
Expand All @@ -6118,7 +6129,7 @@ static int ndpi_reconcile_msteams_call_udp_port(struct ndpi_detection_module_str
flow->flow_multimedia_type = ndpi_multimedia_unknown_flow;
return(0);
}

return(1);
}

Expand Down

0 comments on commit 33c42f9

Please sign in to comment.