Skip to content

Commit

Permalink
bandwidth default; allow 0 bandwith
Browse files Browse the repository at this point in the history
  • Loading branch information
jagt committed May 9, 2021
1 parent d9d4b74 commit ce1a98f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/bandwidth.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define NAME "bandwidth"
#define BANDWIDTH_MIN "0"
#define BANDWIDTH_MAX "99999"
#define BANDWIDTH_DEFAULT 10

//---------------------------------------------------------------------
// rate stats
Expand Down Expand Up @@ -47,7 +48,7 @@ static Ihandle *inboundCheckbox, *outboundCheckbox, *bandwidthInput;
static volatile short bandwidthEnabled = 0,
bandwidthInbound = 1, bandwidthOutbound = 1;

static volatile LONG bandwidthLimit = 0;
static volatile LONG bandwidthLimit = BANDWIDTH_DEFAULT;
static CRateStats *rateStats = NULL;


Expand All @@ -61,7 +62,7 @@ static Ihandle* bandwidthSetupUI() {
);

IupSetAttribute(bandwidthInput, "VISIBLECOLUMNS", "4");
IupSetAttribute(bandwidthInput, "VALUE", "0");
IupSetAttribute(bandwidthInput, "VALUE", STR(BANDWIDTH_DEFAULT));
IupSetCallback(bandwidthInput, "VALUECHANGED_CB", uiSyncInt32);
IupSetAttribute(bandwidthInput, SYNCED_VALUE, (char*)&bandwidthLimit);
IupSetAttribute(bandwidthInput, INTEGER_MAX, BANDWIDTH_MAX);
Expand Down Expand Up @@ -107,7 +108,8 @@ static short bandwidthProcess(PacketNode *head, PacketNode* tail) {
DWORD now_ts = timeGetTime();
int limit = bandwidthLimit * 1024;

if (limit <= 0 || rateStats == NULL) {
// allow 0 limit which should drop all
if (limit < 0 || rateStats == NULL) {
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ extern Module oodModule;
extern Module dupModule;
extern Module tamperModule;
extern Module resetModule;
extern Module capModule;
extern Module bandwidthModule;
extern Module* modules[MODULE_CNT]; // all modules in a list

Expand Down
1 change: 0 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Module* modules[MODULE_CNT] = {
&tamperModule,
&resetModule,
&bandwidthModule,
//&capModule
};

volatile short sendState = SEND_STATUS_NONE;
Expand Down

0 comments on commit ce1a98f

Please sign in to comment.