mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-03 11:30:53 +00:00
made ip-address-to-string method public
This commit is contained in:
parent
1917ea574f
commit
4811d7f378
@ -122,14 +122,14 @@ public class IPAddress extends MoteInterface {
|
||||
return ipString;
|
||||
}
|
||||
|
||||
public String getUncompressedIPv6Address() {
|
||||
public byte[] getIPv6Address() {
|
||||
byte[] ip = null;
|
||||
|
||||
/* IpV6: Struct sizes and offsets */
|
||||
int ipv6NetworkInterfaceAddressOffset = moteMem.getByteValueOf("uip_ds6_netif_addr_list_offset");
|
||||
int ipv6AddressStructSize = moteMem.getByteValueOf("uip_ds6_addr_size");
|
||||
if (ipv6NetworkInterfaceAddressOffset == 0 || ipv6AddressStructSize == 0) {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
/* TODO No need to copy the entire array! */
|
||||
@ -164,7 +164,10 @@ public class IPAddress extends MoteInterface {
|
||||
ip = new byte[16];
|
||||
ipv6AddressIndex = -1;
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
public static String getUncompressedIPv6AddressString(byte[] ip) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i=0; i < 14; i+=2) {
|
||||
sb.append(String.format("%02x%02x:", 0xFF&ip[i+0], 0xFF&ip[i+1]));
|
||||
@ -173,6 +176,14 @@ public class IPAddress extends MoteInterface {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getUncompressedIPv6Address() {
|
||||
byte[] ip = getIPv6Address();
|
||||
if (ip == null) {
|
||||
return "";
|
||||
}
|
||||
return getUncompressedIPv6AddressString(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if mote has an IPv4 address
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user