int BandwidthController::runIpxtablesCmd(const char *cmd, IptRejectOp rejectHandling) {
int res = 0;
- LOGV("runIpxtablesCmd(cmd=%s)", cmd);
+ ALOGV("runIpxtablesCmd(cmd=%s)", cmd);
res |= runIptablesCmd(cmd, rejectHandling, IptIpV4);
res |= runIptablesCmd(cmd, rejectHandling, IptIpV6);
return res;
int BandwidthController::runCommands(int numCommands, const char *commands[],
RunCmdErrHandling cmdErrHandling) {
int res = 0;
- LOGV("runCommands(): %d commands", numCommands);
+ ALOGV("runCommands(): %d commands", numCommands);
for (int cmdNum = 0; cmdNum < numCommands; cmdNum++) {
res = runIpxtablesCmd(commands[cmdNum], IptRejectNoAdd);
if (res && cmdErrHandling != RunCmdFailureBad)
char *buff;
const char *opFlag;
- LOGV("makeIptablesQuotaCmd(%d, %lld)", op, quota);
+ ALOGV("makeIptablesQuotaCmd(%d, %lld)", op, quota);
switch (op) {
case IptOpInsert:
return -1;
}
scanRes = fscanf(fp, "%lld", bytes);
- LOGV("Read quota res=%d bytes=%lld", scanRes, *bytes);
+ ALOGV("Read quota res=%d bytes=%lld", scanRes, *bytes);
fclose(fp);
return scanRes == 1 ? 0 : -1;
}
} else {
res = runIptablesAlertCmd(IptOpInsert, alertName, bytes);
if (globalAlertTetherCount) {
- LOGV("setGlobalAlert for %d tether", globalAlertTetherCount);
+ ALOGV("setGlobalAlert for %d tether", globalAlertTetherCount);
res |= runIptablesAlertFwdCmd(IptOpInsert, alertName, bytes);
}
}
int res = 0;
globalAlertTetherCount++;
- LOGV("setGlobalAlertInForwardChain(): %d tether", globalAlertTetherCount);
+ ALOGV("setGlobalAlertInForwardChain(): %d tether", globalAlertTetherCount);
/*
* If there is no globalAlert active we are done.
iface0[0] = iface1[0] = rest[0] = packets = bytes = 0;
res = sscanf(buffPtr, "%lld %lld ACCEPT all -- %s %s 0.%s",
&packets, &bytes, iface0, iface1, rest);
- LOGV("parse res=%d iface0=<%s> iface1=<%s> pkts=%lld bytes=%lld rest=<%s> orig line=<%s>", res,
+ ALOGV("parse res=%d iface0=<%s> iface1=<%s> pkts=%lld bytes=%lld rest=<%s> orig line=<%s>", res,
iface0, iface1, packets, bytes, rest, buffPtr);
if (res != 5) {
continue;
}
if ((stats.ifaceIn == iface0) && (stats.ifaceOut == iface1)) {
- LOGV("iface_in=%s iface_out=%s rx_bytes=%lld rx_packets=%lld ", iface0, iface1, bytes, packets);
+ ALOGV("iface_in=%s iface_out=%s rx_bytes=%lld rx_packets=%lld ", iface0, iface1, bytes, packets);
stats.rxPackets = packets;
stats.rxBytes = bytes;
} else if ((stats.ifaceOut == iface0) && (stats.ifaceIn == iface1)) {
- LOGV("iface_in=%s iface_out=%s tx_bytes=%lld tx_packets=%lld ", iface1, iface0, bytes, packets);
+ ALOGV("iface_in=%s iface_out=%s tx_bytes=%lld tx_packets=%lld ", iface1, iface0, bytes, packets);
stats.txPackets = packets;
stats.txBytes = bytes;
}
} else if (buffer[b] == '\n') {
buffer[b] = '\0';
- LOG(LOG_INFO, tag, "%s", &buffer[a]);
+ ALOG(LOG_INFO, tag, "%s", &buffer[a]);
a = b + 1;
}
}
if (a == 0 && b == sizeof(buffer) - 1) {
// buffer is full, flush
buffer[b] = '\0';
- LOG(LOG_INFO, tag, "%s", &buffer[a]);
+ ALOG(LOG_INFO, tag, "%s", &buffer[a]);
b = 0;
} else if (a != b) {
// Keep left-overs
// Flush remaining data
if (a != b) {
buffer[b] = '\0';
- LOG(LOG_INFO, tag, "%s", &buffer[a]);
+ ALOG(LOG_INFO, tag, "%s", &buffer[a]);
}
status = 0xAAAA;
if (wait(&status) != -1) { // Wait for child
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) != 0) {
- LOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
WEXITSTATUS(status));
}
return WEXITSTATUS(status);
} else if (WIFSIGNALED(status))
- LOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", tag,
WTERMSIG(status));
else if (WIFSTOPPED(status))
- LOG(LOG_INFO, "logwrapper", "%s stopped by signal %d", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s stopped by signal %d", tag,
WSTOPSIG(status));
} else
- LOG(LOG_INFO, "logwrapper", "%s wait() failed: %s (%d)", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s wait() failed: %s (%d)", tag,
strerror(errno), errno);
return -EAGAIN;
}
// XXX: PROTECT FROM VIKING KILLER
if (execv(argv_child[0], argv_child)) {
- LOG(LOG_ERROR, "logwrapper",
+ ALOG(LOG_ERROR, "logwrapper",
"executing %s failed: %s", argv_child[0], strerror(errno));
}
_exit(1);
/* Use ptty instead of socketpair so that STDOUT is not buffered */
parent_ptty = open("/dev/ptmx", O_RDWR);
if (parent_ptty < 0) {
- LOG(LOG_ERROR, "logwrapper", "Cannot create parent ptty");
- return -errno;
+ ALOG(LOG_ERROR, "logwrapper", "Cannot create parent ptty");
+ return -errno;
}
if (grantpt(parent_ptty) || unlockpt(parent_ptty) ||
ptsname_r(parent_ptty, child_devname, sizeof(child_devname))) {
close(parent_ptty);
- LOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
- return -1;
+ ALOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
+ return -1;
}
pid = fork();
if (pid < 0) {
close(parent_ptty);
- LOG(LOG_ERROR, "logwrapper", "Failed to fork");
+ ALOG(LOG_ERROR, "logwrapper", "Failed to fork");
return -errno;
} else if (pid == 0) {
/*
child_ptty = open(child_devname, O_RDWR);
if (child_ptty < 0) {
close(parent_ptty);
- LOG(LOG_ERROR, "logwrapper", "Problem with child ptty");
+ ALOG(LOG_ERROR, "logwrapper", "Problem with child ptty");
_exit(errno < 128 ? errno : 1); // XXX lame
}
char text[64];
sprintf(text, "%d", getpid());
if (write(fd, text, strlen(text)) < 0) {
- LOG(LOG_WARN, "logwrapper",
+ ALOG(LOG_WARN, "logwrapper",
"Unable to background process (%s)", strerror(errno));
}
close(fd);
} else {
- LOG(LOG_WARN, "logwrapper",
+ ALOG(LOG_WARN, "logwrapper",
"Unable to background process (%s)", strerror(errno));
}
}