I am creating a FTP sever . According to FTP specifications they have added new command called LPRT .
Its format is LPRT 6,16,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2,193,160
Now i am able to get FTP port from it using logic below.But I need IPV6 address as well from this string .
public static void main(String[] args) {
StringTokenizer st = new StringTokenizer(
"6,16,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2,193,160");
final String portStr = st.nextToken();
final int lastDelimIdx =portStr.lastIndexOf(',', portStr.lastIndexOf(',') - 1);
final StringTokenizer portst = new StringTokenizer(portStr.substring(lastDelimIdx + 1, portStr.length()), ",");
final int p1 = Integer.parseInt(portst.nextToken());
final int p2 = Integer.parseInt(portst.nextToken());
final int dataPort = (p1 << 8) | p2;
System.out.println(dataPort);
}
Can some one help me to find the IPv6 address from this string.
LPRT and LPSV are considered obsolete, see https://www.iana.org/assignments/ftp-commands-extensions/ftp-commands-extensions.txt. To use IPv6 use EPSV and EPRT which are specified in RFC2428.
If you still need to know how do deal with LPRT look into the obsolete RFC1639. For example:
means that the 16 numbers after the host length argument are the bytes of the address and then follows the port address length with 2 bytes, i.e.