LCOV - code coverage report
Current view: top level - src/server - quota.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 13 0.0 %
Date: 2015-10-31 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             : 
       8           0 : static void quota_log_bytes(struct async *as,
       9             :         const char *msg, uint64_t byte, uint64_t quota)
      10             : {
      11           0 :         as->asfd->write_str(as->asfd, CMD_WARNING, msg);
      12           0 :         logp("Bytes estimated: %"PRIu64"%s\n", byte, bytes_to_human(byte));
      13           0 :         logp("%s: %"PRIu64"%s\n", msg, quota, bytes_to_human(quota));
      14           0 : }
      15             : 
      16             : // Return O for OK, -1 if the estimated size is greater than hard_quota 
      17           0 : int check_quota(struct async *as, struct cntr *cntr,
      18             :         uint64_t hard_quota, uint64_t soft_quota)
      19             : {
      20             :         uint64_t byte;
      21             : 
      22           0 :         byte=cntr->ent[(uint8_t)CMD_BYTES_ESTIMATED]->count;
      23             : 
      24           0 :         if(hard_quota && byte>hard_quota)
      25             :         {
      26           0 :                 quota_log_bytes(as, "Hard quota exceeded", byte, soft_quota);
      27           0 :                 return -1;
      28             :         }
      29             : 
      30           0 :         if(soft_quota && byte>soft_quota)
      31           0 :                 quota_log_bytes(as, "Soft quota exceeded", byte, soft_quota);
      32             :         
      33           0 :         return 0;
      34             : }

Generated by: LCOV version 1.10