Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255304
b: refs/heads/master
c: 37a4065
h: refs/heads/master
v: v3
  • Loading branch information
Sven Eckelmann committed May 30, 2011
1 parent 71e1417 commit d4b4dfd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 747e4221a03cde62402b614ca1f8e961b8416130
refs/heads/master: 37a4065ec79dcf172c44cb2741c1b9983ecfc492
19 changes: 10 additions & 9 deletions trunk/net/batman-adv/gateway_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
}

static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
long *up, long *down)
int *up, int *down)
{
int ret, multi = 1;
char *slash_ptr, *tmp_ptr;
long ldown, lup;

slash_ptr = strchr(buff, '/');
if (slash_ptr)
Expand All @@ -96,15 +97,15 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0';
}

ret = strict_strtoul(buff, 10, down);
ret = strict_strtoul(buff, 10, &ldown);
if (ret) {
bat_err(net_dev,
"Download speed of gateway mode invalid: %s\n",
buff);
return false;
}

*down *= multi;
*down = ldown * multi;

/* we also got some upload info */
if (slash_ptr) {
Expand All @@ -121,15 +122,15 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0';
}

ret = strict_strtoul(slash_ptr + 1, 10, up);
ret = strict_strtoul(slash_ptr + 1, 10, &lup);
if (ret) {
bat_err(net_dev,
"Upload speed of gateway mode invalid: "
"%s\n", slash_ptr + 1);
return false;
}

*up *= multi;
*up = lup * multi;
}

return true;
Expand All @@ -138,7 +139,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
long gw_bandwidth_tmp = 0, up = 0, down = 0;
long gw_bandwidth_tmp = 0;
int up = 0, down = 0;
bool ret;

ret = parse_gw_bandwidth(net_dev, buff, &up, &down);
Expand All @@ -158,12 +160,11 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
* speeds, hence we need to calculate it back to show the number
* that is going to be propagated
**/
gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp,
(int *)&down, (int *)&up);
gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up);

gw_deselect(bat_priv);
bat_info(net_dev, "Changing gateway bandwidth from: '%i' to: '%ld' "
"(propagating: %ld%s/%ld%s)\n",
"(propagating: %d%s/%d%s)\n",
atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
(down > 2048 ? down / 1024 : down),
(down > 2048 ? "MBit" : "KBit"),
Expand Down

0 comments on commit d4b4dfd

Please sign in to comment.