Commit c6428e52 authored by David Woodhouse's avatar David Woodhouse

solos: Fix various bugs in status packet handling

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent a0641cc4
...@@ -294,12 +294,14 @@ static char *next_string(struct sk_buff *skb) ...@@ -294,12 +294,14 @@ static char *next_string(struct sk_buff *skb)
int i = 0; int i = 0;
char *this = skb->data; char *this = skb->data;
while (i < skb->len) { for (i = 0; i < skb->len; i++) {
if (this[i] == '\n') { if (this[i] == '\n') {
this[i] = 0; this[i] = 0;
skb_pull(skb, i); skb_pull(skb, i + 1);
return this; return this;
} }
if (!isprint(this[i]))
return NULL;
} }
return NULL; return NULL;
} }
...@@ -316,7 +318,7 @@ static char *next_string(struct sk_buff *skb) ...@@ -316,7 +318,7 @@ static char *next_string(struct sk_buff *skb)
static int process_status(struct solos_card *card, int port, struct sk_buff *skb) static int process_status(struct solos_card *card, int port, struct sk_buff *skb)
{ {
char *str, *end, *state_str; char *str, *end, *state_str;
int ver, rate_up, rate_down, state, snr, attn; int ver, rate_up, rate_down, state;
if (!card->atmdev[port]) if (!card->atmdev[port])
return -ENODEV; return -ENODEV;
...@@ -333,16 +335,22 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb ...@@ -333,16 +335,22 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
} }
str = next_string(skb); str = next_string(skb);
if (!str)
return -EIO;
rate_up = simple_strtol(str, &end, 10); rate_up = simple_strtol(str, &end, 10);
if (*end) if (*end)
return -EIO; return -EIO;
str = next_string(skb); str = next_string(skb);
if (!str)
return -EIO;
rate_down = simple_strtol(str, &end, 10); rate_down = simple_strtol(str, &end, 10);
if (*end) if (*end)
return -EIO; return -EIO;
state_str = next_string(skb); state_str = next_string(skb);
if (!state_str)
return -EIO;
if (!strcmp(state_str, "Showtime")) if (!strcmp(state_str, "Showtime"))
state = ATM_PHY_SIG_FOUND; state = ATM_PHY_SIG_FOUND;
else { else {
...@@ -350,25 +358,24 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb ...@@ -350,25 +358,24 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
release_vccs(card->atmdev[port]); release_vccs(card->atmdev[port]);
} }
str = next_string(skb); if (state == ATM_PHY_SIG_LOST) {
snr = simple_strtol(str, &end, 10);
if (*end)
return -EIO;
str = next_string(skb);
attn = simple_strtol(str, &end, 10);
if (*end)
return -EIO;
if (state == ATM_PHY_SIG_LOST && !rate_up && !rate_down)
dev_info(&card->dev->dev, "Port %d ATM state: %s\n", dev_info(&card->dev->dev, "Port %d ATM state: %s\n",
port, state_str); port, state_str);
else } else {
dev_info(&card->dev->dev, "Port %d ATM state: %s (%d/%d kb/s, SNR %ddB, Attn %ddB)\n", char *snr, *attn;
port, state_str, rate_up/1000, rate_down/1000,
snr, attn);
card->atmdev[port]->link_rate = rate_down; snr = next_string(skb);
if (!str)
return -EIO;
attn = next_string(skb);
if (!attn)
return -EIO;
dev_info(&card->dev->dev, "Port %d: %s (%d/%d kb/s%s%s%s%s)\n",
port, state_str, rate_down/1000, rate_up/1000,
snr[0]?", SNR ":"", snr, attn[0]?", Attn ":"", attn);
}
card->atmdev[port]->link_rate = rate_down / 424;
card->atmdev[port]->signal = state; card->atmdev[port]->signal = state;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment