mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
cea22866a8
commit
734d174f33
@ -17,11 +17,6 @@
|
||||
/* OS includes */
|
||||
#include <net/netaddress.h>
|
||||
|
||||
namespace Net
|
||||
{
|
||||
using Mac_address = Net::Network_address<6, ':', true>;
|
||||
|
||||
Mac_address mac_from_string(const char * mac);
|
||||
}
|
||||
namespace Net { using Mac_address = Net::Network_address<6, ':', true>; }
|
||||
|
||||
#endif /* _NET__MAC_ADDRESS_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
SRC_CC += ethernet.cc ipv4.cc dhcp.cc arp.cc udp.cc tcp.cc mac_address.cc
|
||||
SRC_CC += ethernet.cc ipv4.cc dhcp.cc arp.cc udp.cc tcp.cc
|
||||
SRC_CC += icmp.cc internet_checksum.cc
|
||||
|
||||
vpath %.cc $(REP_DIR)/src/lib/net
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* \brief Media access control (MAC) address
|
||||
* \author Martin Stein
|
||||
* \date 2016-06-22
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <net/mac_address.h>
|
||||
#include <util/token.h>
|
||||
#include <util/string.h>
|
||||
|
||||
using namespace Net;
|
||||
using namespace Genode;
|
||||
|
||||
struct Scanner_policy_number
|
||||
{
|
||||
static bool identifier_char(char c, unsigned) {
|
||||
return is_digit(c, true) && c !=':'; }
|
||||
};
|
||||
|
||||
typedef Token<Scanner_policy_number> Mac_token;
|
||||
|
||||
|
||||
Mac_address Net::mac_from_string(const char * mac)
|
||||
{
|
||||
Mac_address mac_addr;
|
||||
Mac_token t(mac);
|
||||
char tmpstr[3];
|
||||
int cnt = 0;
|
||||
unsigned char ipb[6] = {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_unsigned(tmpstr, tmpc, 16);
|
||||
ipb[cnt] = tmpc & 0xFF;
|
||||
t = t.next();
|
||||
|
||||
if (cnt == 6) { break; }
|
||||
cnt++;
|
||||
}
|
||||
if (cnt == 6) {
|
||||
mac_addr.addr[0] = ipb[0];
|
||||
mac_addr.addr[1] = ipb[1];
|
||||
mac_addr.addr[2] = ipb[2];
|
||||
mac_addr.addr[3] = ipb[3];
|
||||
mac_addr.addr[4] = ipb[4];
|
||||
mac_addr.addr[5] = ipb[5];
|
||||
}
|
||||
return mac_addr;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user