LCOV - code coverage report
Current view: top level - src/server - quota.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 12 0.0 %
Date: 2020-07-31 05:59:47 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "../burp.h"
       2             : #include "../asfd.h"
       3             : #include "../async.h"
       4             : #include "../cmd.h"
       5             : #include "../cntr.h"
       6             : #include "../log.h"
       7             : #include "quota.h"
       8             : 
       9           0 : static void quota_log_bytes(struct async *as,
      10             :         const char *msg, uint64_t byte, uint64_t quota)
      11             : {
      12           0 :         as->asfd->write_str(as->asfd, CMD_WARNING, msg);
      13           0 :         logp("Bytes estimated: %" PRIu64 "%s\n", byte, bytes_to_human(byte));
      14           0 :         logp("%s: %" PRIu64 "%s\n", msg, quota, bytes_to_human(quota));
      15           0 : }
      16             : 
      17             : // Return O for OK, -1 if the estimated size is greater than hard_quota 
      18           0 : int check_quota(struct async *as, struct cntr *cntr,
      19             :         uint64_t hard_quota, uint64_t soft_quota)
      20             : {
      21             :         uint64_t byte;
      22             : 
      23           0 :         byte=cntr->ent[(uint8_t)CMD_BYTES_ESTIMATED]->count;
      24             : 
      25           0 :         if(hard_quota && byte>hard_quota)
      26             :         {
      27           0 :                 quota_log_bytes(as, "Hard quota exceeded", byte, soft_quota);
      28           0 :                 return -1;
      29             :         }
      30             : 
      31           0 :         if(soft_quota && byte>soft_quota)
      32           0 :                 quota_log_bytes(as, "Soft quota exceeded", byte, soft_quota);
      33             :         
      34             :         return 0;
      35             : }

Generated by: LCOV version 1.13