#include <cutils/log.h>
#include "ClatdController.h"
+#include "Fwmark.h"
#include "NetdConstants.h"
#include "NetworkController.h"
}
if (!pid) {
- char netId[UINT32_STRLEN];
- snprintf(netId, sizeof(netId), "%u", mNetCtrl->getNetworkId(interface));
+ // Pass in the interface, a netid to use for DNS lookups, and a fwmark for outgoing packets.
+ unsigned netId = mNetCtrl->getNetworkId(interface);
+ char netIdString[UINT32_STRLEN];
+ snprintf(netIdString, sizeof(netIdString), "%u", netId);
+
+ Fwmark fwmark = { netId, true, true, PERMISSION_CONNECTIVITY_INTERNAL };
+ char fwmarkString[UINT32_HEX_STRLEN];
+ snprintf(fwmarkString, sizeof(fwmarkString), "0x%x", fwmark.intValue);
+
char *args[] = {
- (char*)"/system/bin/clatd",
- (char*)"-i",
+ (char *) "/system/bin/clatd",
+ (char *) "-i",
interface,
- (char*)"-n",
- netId,
+ (char *) "-n",
+ netIdString,
+ (char *) "-m",
+ fwmarkString,
NULL
};
#include <stdint.h>
union Fwmark {
- Fwmark() : intValue(0) {}
uint32_t intValue;
struct {
unsigned netId : 16;
bool protectedFromVpn : 1;
Permission permission : 2;
};
+ Fwmark() : intValue(0) {}
+ Fwmark(unsigned netId, bool explicitlySelected, bool protectedFromVpn, Permission permission)
+ : netId(netId), explicitlySelected(explicitlySelected),
+ protectedFromVpn(protectedFromVpn), permission(permission) {}
};
static const unsigned FWMARK_NET_ID_MASK = 0xffff;