src/Reporter.c
/*
 * Process reports starting with "reporthdr"
 */
Process reports starting with "reporthdr"
Process reports starting with " reporthdr "
int reporter_process_report ( ReportHeader *reporthdr ) {
    int need_free = 0;
    if ( reporthdr->next != NULL ) {
        if ( reporter_process_report( reporthdr->next ) ) {
            ReportHeader *temp = reporthdr->next;
            reporthdr->next = reporthdr->next->next;
            free( temp );
        }
    }
    if ( (reporthdr->report.type & SETTINGS_REPORT) != 0 ) {
        reporthdr->report.type &= ~SETTINGS_REPORT;
        return reporter_print( &reporthdr->report, SETTINGS_REPORT, 1 );
    } else if ( (reporthdr->report.type & CONNECTION_REPORT) != 0 ) {
        reporthdr->report.type &= ~CONNECTION_REPORT;
        reporter_print( &reporthdr->report, CONNECTION_REPORT,
                               (reporthdr->report.type == 0 ? 1 : 0) );
        if ( reporthdr->multireport != NULL && isMultipleReport( (&reporthdr->report) )) {
            if ( (reporthdr->multireport->report->type & CONNECTION_REPORT) != 0 ) {
                reporthdr->multireport->report->type &= ~CONNECTION_REPORT;
                reporter_print( reporthdr->multireport->report, CONNECTION_REPORT,
                                (reporthdr->report.type == 0 ? 1 : 0) );
            }
        }
    } else if ( (reporthdr->report.type & SERVER_RELAY_REPORT) != 0 ) {
        reporthdr->report.type &= ~SERVER_RELAY_REPORT;
        return reporter_print( &reporthdr->report, SERVER_RELAY_REPORT, 1 );
    }
    if ( (reporthdr->report.type & TRANSFER_REPORT) != 0 ) {
        if ( reporthdr->reporterindex >= 0 ) {
            while ( reporthdr->reporterindex != reporthdr->agentindex - 1 ) {
                if ( reporthdr->reporterindex == NUM_REPORT_STRUCTS - 1 ) {
                    if ( reporthdr->agentindex == 0 ) {
                        break;
                    } else {
                        reporthdr->reporterindex = 0;
                    }
                } else {
                    reporthdr->reporterindex++;
                }
                if ( reporter_handle_packet( reporthdr ) ) {
                    reporthdr->reporterindex = -1;
                    break;
                }
            }
        }
        if ( reporthdr->agentindex == -1 ) {
            need_free = 1;
        }
    }
    return need_free;
}
int reporter_process_report ( ReportHeader * reporthdr ) { int need_free = 0 ; if ( reporthdr -> next != NULL ) { if ( reporter_process_report ( reporthdr -> next ) ) { ReportHeader * temp = reporthdr -> next ; reporthdr -> next = reporthdr -> next -> next ; free ( temp ) ; } } if ( ( reporthdr -> report . type & SETTINGS_REPORT ) != 0 ) { reporthdr -> report . type &= ~ SETTINGS_REPORT ; return reporter_print ( & reporthdr -> report , SETTINGS_REPORT , 1 ) ; } else if ( ( reporthdr -> report . type & CONNECTION_REPORT ) != 0 ) { reporthdr -> report . type &= ~ CONNECTION_REPORT ; reporter_print ( & reporthdr -> report , CONNECTION_REPORT , ( reporthdr -> report . type == 0 ? 1 : 0 ) ) ; if ( reporthdr -> multireport != NULL && isMultipleReport ( ( & reporthdr -> report ) ) ) { if ( ( reporthdr -> multireport -> report -> type & CONNECTION_REPORT ) != 0 ) { reporthdr -> multireport -> report -> type &= ~ CONNECTION_REPORT ; reporter_print ( reporthdr -> multireport -> report , CONNECTION_REPORT , ( reporthdr -> report . type == 0 ? 1 : 0 ) ) ; } } } else if ( ( reporthdr -> report . type & SERVER_RELAY_REPORT ) != 0 ) { reporthdr -> report . type &= ~ SERVER_RELAY_REPORT ; return reporter_print ( & reporthdr -> report , SERVER_RELAY_REPORT , 1 ) ; } if ( ( reporthdr -> report . type & TRANSFER_REPORT ) != 0 ) { if ( reporthdr -> reporterindex >= 0 ) { while ( reporthdr -> reporterindex != reporthdr -> agentindex - 1 ) { if ( reporthdr -> reporterindex == NUM_REPORT_STRUCTS - 1 ) { if ( reporthdr -> agentindex == 0 ) { break ; } else { reporthdr -> reporterindex = 0 ; } } else { reporthdr -> reporterindex ++ ; } if ( reporter_handle_packet ( reporthdr ) ) { reporthdr -> reporterindex = -1 ; break ; } } } if ( reporthdr -> agentindex == -1 ) { need_free = 1 ; } } return need_free ; }
Process reports starting with "reporthdr"
Process reports starting with " reporthdr "
// Recursively process reports // If we are done with this report then free it // If there are more packets to process then handle them // Need to make sure we do not pass the "agent" // No more packets to process // If the agent is done with the report then free it