Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow_age_stats: Added categorization based on FLOW_END_REASON #234

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vaclavbartos
Copy link
Contributor

Module can now output statistics and graphs for each value of FLOW_END_REASON separately.

@vaclavbartos vaclavbartos requested a review from SiskaPavel July 25, 2024 15:43
Comment on lines 90 to 92
bin* bins;
stat* first;
stat* last;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bin* bins;
stat* first;
stat* last;
bin *bins;
stat *first;
stat *last;

stat* last;
uint8_t reason;
int count;
struct category_t* next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct category_t* next;
struct category_t *next;

//declaration of functions
bin* createNode(uint64_t max, uint64_t count);
void categorizeIntoCats(category* curr, uint64_t first_diff, uint64_t last_diff, uint8_t end_reason);
category* createCategory(category* next, uint8_t reason);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
category* createCategory(category* next, uint8_t reason);
category *createCategory(category* next, uint8_t reason);

Comment on lines 133 to 135
void destroyCategory(category* current);
void printCategories(category* head, int flow_count);
void outputInFiles(category* head, int flow_count);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void destroyCategory(category* current);
void printCategories(category* head, int flow_count);
void outputInFiles(category* head, int flow_count);
void destroyCategory(category *current);
void printCategories(category *head, int flow_count);
void outputInFiles(category *head, int flow_count);

@@ -173,20 +193,29 @@ int main(int argc, char **argv)
fprintf(stderr, "Error: Input template could not be created.\n");
return -1;
}
if(endReas == 5){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(endReas == 5){
if (endReas == 5){

current = current->next;
}
current->next = createNode(0, 0);
category* head = createCategory(NULL, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
category* head = createCategory(NULL, 0);
category *head = createCategory(NULL, 0);

if(head == NULL){
destroyCategory(head);
}
category* curr = head;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
category* curr = head;
category *curr = head;

Comment on lines 287 to 288
}
else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else{
} else {



//should be outputed to file if specified
if (file == 1){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (file == 1){
if (file == 1) {


// clean categories
while (head != NULL){
category* next = head->next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
category* next = head->next;
category *next = head->next;

* @param count counts inside the Node are initialized to this value
*/
bin* createNode(uint64_t max, uint64_t count){
bin* new_node = (bin*)malloc(sizeof(bin));
Copy link
Contributor

@cejkato2 cejkato2 Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bin* new_node = (bin*)malloc(sizeof(bin));
bin *new_node = (bin *) malloc(sizeof(bin));

Comment on lines 363 to 364
category* createCategory(category* next, uint8_t reason){
category* newCat = (category*)malloc(sizeof(category));
Copy link
Contributor

@cejkato2 cejkato2 Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
category* createCategory(category* next, uint8_t reason){
category* newCat = (category*)malloc(sizeof(category));
category *createCategory(category *next, uint8_t reason)
{
category *newCat = (category *) malloc(sizeof(category));

current->next = createNode(0, 0);

//creating stat structs
newCat->first = (stat*)malloc(sizeof(stat));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
newCat->first = (stat*)malloc(sizeof(stat));
newCat->first = (stat *) malloc(sizeof(stat));

newCat->first->min = UINT64_MAX;
newCat->first->max = 0;

newCat->last = (stat*)malloc(sizeof(stat));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
newCat->last = (stat*)malloc(sizeof(stat));
newCat->last = (stat *) malloc(sizeof(stat));

*
* @param current category to be destroyed
*/
void destroyCategory(category* current){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void destroyCategory(category* current){
void destroyCategory(category *current)
{

* @param current category to be destroyed
*/
void destroyCategory(category* current){
if(current == NULL){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(current == NULL){
if (current == NULL) {

@cejkato2
Copy link
Contributor

There are too many coding style issues, please improve the code according to https://nemea.liberouter.org/developer/coding-style-c
I suggested some of the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants