@@ -36,26 +36,26 @@ IPv6Address::IPv6Address(const uint32_t *address)
36
36
memcpy (_address.bytes , (const uint8_t *)address, sizeof (_address.bytes ));
37
37
}
38
38
39
- IPv6Address& IPv6Address::operator =(const uint8_t *address)
39
+ IPv6Address & IPv6Address::operator =(const uint8_t *address)
40
40
{
41
41
memcpy (_address.bytes , address, sizeof (_address.bytes ));
42
42
return *this ;
43
43
}
44
44
45
- bool IPv6Address::operator ==(const uint8_t * addr) const
45
+ bool IPv6Address::operator ==(const uint8_t * addr) const
46
46
{
47
47
return memcmp (addr, _address.bytes , sizeof (_address.bytes )) == 0 ;
48
48
}
49
49
50
- size_t IPv6Address::printTo (Print& p) const
50
+ size_t IPv6Address::printTo (Print & p) const
51
51
{
52
52
size_t n = 0 ;
53
- for (int i = 0 ; i < 16 ; i+= 2 ) {
54
- if (i){
53
+ for (int i = 0 ; i < 16 ; i += 2 ) {
54
+ if (i) {
55
55
n += p.print (' :' );
56
56
}
57
57
n += p.printf (" %02x" , _address.bytes [i]);
58
- n += p.printf (" %02x" , _address.bytes [i+ 1 ]);
58
+ n += p.printf (" %02x" , _address.bytes [i + 1 ]);
59
59
60
60
}
61
61
return n;
@@ -64,24 +64,24 @@ size_t IPv6Address::printTo(Print& p) const
64
64
String IPv6Address::toString () const
65
65
{
66
66
char szRet[40 ];
67
- sprintf (szRet," %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x" ,
68
- _address.bytes [0 ], _address.bytes [1 ], _address.bytes [2 ], _address.bytes [3 ],
69
- _address.bytes [4 ], _address.bytes [5 ], _address.bytes [6 ], _address.bytes [7 ],
70
- _address.bytes [8 ], _address.bytes [9 ], _address.bytes [10 ], _address.bytes [11 ],
71
- _address.bytes [12 ], _address.bytes [13 ], _address.bytes [14 ], _address.bytes [15 ]);
67
+ sprintf (szRet, " %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x" ,
68
+ _address.bytes [0 ], _address.bytes [1 ], _address.bytes [2 ], _address.bytes [3 ],
69
+ _address.bytes [4 ], _address.bytes [5 ], _address.bytes [6 ], _address.bytes [7 ],
70
+ _address.bytes [8 ], _address.bytes [9 ], _address.bytes [10 ], _address.bytes [11 ],
71
+ _address.bytes [12 ], _address.bytes [13 ], _address.bytes [14 ], _address.bytes [15 ]);
72
72
return String (szRet);
73
73
}
74
74
75
75
bool IPv6Address::fromString (const char *address)
76
76
{
77
77
// format 0011:2233:4455:6677:8899:aabb:ccdd:eeff
78
- if (strlen (address) != 39 ){
78
+ if (strlen (address) != 39 ) {
79
79
return false ;
80
80
}
81
81
char * pos = (char *)address;
82
82
size_t i = 0 ;
83
- for (i = 0 ; i < 16 ; i+= 2 ) {
84
- if (!sscanf (pos, " %2hhx" , &_address.bytes [i]) || !sscanf (pos+ 2 , " %2hhx" , &_address.bytes [i+ 1 ])){
83
+ for (i = 0 ; i < 16 ; i += 2 ) {
84
+ if (!sscanf (pos, " %2hhx" , &_address.bytes [i]) || !sscanf (pos + 2 , " %2hhx" , &_address.bytes [i + 1 ])) {
85
85
return false ;
86
86
}
87
87
pos += 5 ;
0 commit comments