From 3c8d31f8fbe4a0d91b93e9e1b905368ac7da1d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Fri, 16 Sep 2016 14:16:45 +0200 Subject: [PATCH] net: fix mac_from_string The MAC tokens are given in hex so treat them as such. Fixes #2107. --- repos/os/lib/mk/net.mk | 4 ++-- repos/os/src/lib/net/mac_address.cc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/repos/os/lib/mk/net.mk b/repos/os/lib/mk/net.mk index 5bb41f45e9..75b74246b9 100644 --- a/repos/os/lib/mk/net.mk +++ b/repos/os/lib/mk/net.mk @@ -1,3 +1,3 @@ -SRC_CC = ethernet.cc ipv4.cc +SRC_CC = ethernet.cc ipv4.cc mac_address.cc -vpath %.cc $(REP_DIR)/src/lib/net \ No newline at end of file +vpath %.cc $(REP_DIR)/src/lib/net diff --git a/repos/os/src/lib/net/mac_address.cc b/repos/os/src/lib/net/mac_address.cc index f7318d71be..c6ec7f3e79 100644 --- a/repos/os/src/lib/net/mac_address.cc +++ b/repos/os/src/lib/net/mac_address.cc @@ -22,29 +22,29 @@ using namespace Genode; struct Scanner_policy_number { static bool identifier_char(char c, unsigned i ) { - return is_digit(c) && c !=':'; } + return is_digit(c, true) && c !=':'; } }; -typedef Token Token; +typedef Token Mac_token; Mac_address Net::mac_from_string(const char * mac) { Mac_address mac_addr; - Token t(mac); + Mac_token t(mac); char tmpstr[3]; int cnt = 0; unsigned char ipb[6] = {0}; - while(t) { - if (t.type() == Token::WHITESPACE || t[0] == ':') { + while (t) { + if (t.type() == Mac_token::WHITESPACE || t[0] == ':') { t = t.next(); continue; } t.string(tmpstr, sizeof(tmpstr)); unsigned long tmpc = 0; - ascii_to(tmpstr, tmpc); + ascii_to_unsigned(tmpstr, tmpc, 16); ipb[cnt] = tmpc & 0xFF; t = t.next();