[CLATJ#21] ClatCoordinator: start clatd
launch clatd with the given cli arguments.
Bug: 212345928
Test: flash and boot
- run "atest ClatCoordinatorTest" in a follow commit.
- manual test
1. Connect to ipv6-only wifi.
2. Try IPv4 traffic.
$ ping 8.8.8.8
Change-Id: Ie57a7c7a9d3d77396e91fa9f94c02f1ad05487c1
This commit is contained in:
@@ -170,12 +170,12 @@ public class ClatCoordinator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe start bpf.
|
||||
* Start clatd.
|
||||
*/
|
||||
public int maybeStartBpf(@NonNull FileDescriptor tunfd, @NonNull FileDescriptor readsock6,
|
||||
public int startClatd(@NonNull FileDescriptor tunfd, @NonNull FileDescriptor readsock6,
|
||||
@NonNull FileDescriptor writesock6, @NonNull String iface, @NonNull String pfx96,
|
||||
@NonNull String v4, @NonNull String v6) throws IOException {
|
||||
return native_maybeStartBpf(tunfd, readsock6, writesock6, iface, pfx96, v4, v6);
|
||||
return native_startClatd(tunfd, readsock6, writesock6, iface, pfx96, v4, v6);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,6 +219,9 @@ public class ClatCoordinator {
|
||||
public String clatStart(final String iface, final int netId,
|
||||
@NonNull final IpPrefix nat64Prefix)
|
||||
throws IOException {
|
||||
if (mIface != null || mPid != INVALID_PID) {
|
||||
throw new IOException("Clatd has started on " + mIface + " (pid " + mPid + ")");
|
||||
}
|
||||
if (nat64Prefix.getPrefixLength() != 96) {
|
||||
throw new IOException("Prefix must be 96 bits long: " + nat64Prefix);
|
||||
}
|
||||
@@ -327,20 +330,19 @@ public class ClatCoordinator {
|
||||
throw new IOException("configure packet socket failed: " + e);
|
||||
}
|
||||
|
||||
// [5] Maybe start bpf.
|
||||
// [5] Start clatd.
|
||||
try {
|
||||
mDeps.maybeStartBpf(tunFd.getFileDescriptor(), readSock6.getFileDescriptor(),
|
||||
mPid = mDeps.startClatd(tunFd.getFileDescriptor(), readSock6.getFileDescriptor(),
|
||||
writeSock6.getFileDescriptor(), iface, pfx96, v4, v6);
|
||||
mIface = iface;
|
||||
mNat64Prefix = pfx96;
|
||||
mXlatLocalAddress4 = v4;
|
||||
mXlatLocalAddress6 = v6;
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Error start bpf on " + iface + ": " + e);
|
||||
throw new IOException("Error start clatd on " + iface + ": " + e);
|
||||
}
|
||||
|
||||
// TODO: start clatd and returns local xlat464 v6 address.
|
||||
return null;
|
||||
return v6;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,7 +374,7 @@ public class ClatCoordinator {
|
||||
int ifindex) throws IOException;
|
||||
private static native void native_configurePacketSocket(FileDescriptor sock, String v6,
|
||||
int ifindex) throws IOException;
|
||||
private static native int native_maybeStartBpf(FileDescriptor tunfd, FileDescriptor readsock6,
|
||||
private static native int native_startClatd(FileDescriptor tunfd, FileDescriptor readsock6,
|
||||
FileDescriptor writesock6, String iface, String pfx96, String v4, String v6)
|
||||
throws IOException;
|
||||
private static native void native_maybeStopBpf(String iface, String pfx96, String v4,
|
||||
|
||||
Reference in New Issue
Block a user