equal
deleted
inserted
replaced
35 |
35 |
36 static char |
36 static char |
37 AsciiToLowCase (char c) |
37 AsciiToLowCase (char c) |
38 { |
38 { |
39 if (c >= ASCII_a && c <= ASCII_z) { |
39 if (c >= ASCII_a && c <= ASCII_z) { |
40 return c; |
40 return c; |
41 } else if (c >= ASCII_A && c <= ASCII_Z) { |
41 } else if (c >= ASCII_A && c <= ASCII_Z) { |
42 return c + (ASCII_a - ASCII_A); |
42 return c + (ASCII_a - ASCII_A); |
43 } else { |
43 } else { |
44 return c; |
44 return c; |
45 } |
45 } |
46 } |
46 } |
47 |
47 |
48 |
48 |
49 Mac64Address::Mac64Address () |
49 Mac64Address::Mac64Address () |
50 { |
50 { |
55 int i = 0; |
55 int i = 0; |
56 while (*str != 0 && i < 8) |
56 while (*str != 0 && i < 8) |
57 { |
57 { |
58 uint8_t byte = 0; |
58 uint8_t byte = 0; |
59 while (*str != ASCII_COLON && *str != 0) |
59 while (*str != ASCII_COLON && *str != 0) |
60 { |
60 { |
61 byte <<= 4; |
61 byte <<= 4; |
62 char low = AsciiToLowCase (*str); |
62 char low = AsciiToLowCase (*str); |
63 if (low >= ASCII_a) |
63 if (low >= ASCII_a) |
64 { |
64 { |
65 byte |= low - ASCII_a + 10; |
65 byte |= low - ASCII_a + 10; |
66 } |
66 } |
67 else |
67 else |
68 { |
68 { |
69 byte |= low - ASCII_ZERO; |
69 byte |= low - ASCII_ZERO; |
70 } |
70 } |
71 str++; |
71 str++; |
72 } |
72 } |
73 m_address[i] = byte; |
73 m_address[i] = byte; |
74 i++; |
74 i++; |
75 if (*str == 0) |
75 if (*str == 0) |
76 { |
76 { |
77 break; |
77 break; |
78 } |
78 } |
79 str++; |
79 str++; |
80 } |
80 } |
81 NS_ASSERT (i == 6); |
81 NS_ASSERT (i == 6); |
82 } |
82 } |
83 void |
83 void |
145 b.CopyTo (adb); |
145 b.CopyTo (adb); |
146 return memcmp (ada, adb, 8) == 0; |
146 return memcmp (ada, adb, 8) == 0; |
147 } |
147 } |
148 bool operator != (const Mac64Address &a, const Mac64Address &b) |
148 bool operator != (const Mac64Address &a, const Mac64Address &b) |
149 { |
149 { |
150 return ! (a == b); |
150 return !(a == b); |
151 } |
151 } |
152 |
152 |
153 std::ostream& operator<< (std::ostream& os, const Mac64Address & address) |
153 std::ostream& operator<< (std::ostream& os, const Mac64Address & address) |
154 { |
154 { |
155 uint8_t ad[8]; |
155 uint8_t ad[8]; |