Skip to content

Commit

Permalink
add min/max macros
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarning committed Oct 29, 2018
1 parent afd3dcf commit 437dde6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@
#include "tc.h"


/**
* Limit upload/download rate for a client using traffic control via IFB (Intermediate Functional Block).
*/


int
tc_attach_client(const char down_dev[], int download_limit, const char up_dev[], int upload_limit, int idx, const char ip[])
{
int rc = 0;
s_config *config = config_get_config();
int dlimit = (download_limit < config->download_limit ? download_limit : config->download_limit);
int ulimit = (upload_limit < config->upload_limit ? upload_limit : config->upload_limit);
int dlimit = MIN(download_limit, config->download_limit);
int ulimit = MIN(upload_limit, config->upload_limit);
int id = 3 * idx + 10;

if (dlimit > 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#ifndef _UTIL_H_
#define _UTIL_H_

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))

/* @brief Execute a shell command */
int execute(const char fmt[], ...);
int execute_ret(char* msg, int msg_len, const char fmt[], ...);
Expand Down

0 comments on commit 437dde6

Please sign in to comment.