import of dnsmasq-2.34.tar.gz

This commit is contained in:
Simon Kelley
2006-10-16 20:04:18 +01:00
parent 208b65c5cf
commit 1697269ce7
33 changed files with 3660 additions and 2711 deletions

View File

@@ -410,3 +410,48 @@ char *print_mac(struct daemon *daemon, unsigned char *mac, int len)
return daemon->namebuff;
}
void bump_maxfd(int fd, int *max)
{
if (fd > *max)
*max = fd;
}
void log_start(struct daemon *daemon)
{
if (daemon->options & OPT_DEBUG)
{
#ifdef LOG_PERROR
openlog("dnsmasq", LOG_PERROR, daemon->log_fac);
#else
openlog("dnsmasq", 0, daemon->log_fac);
#endif
}
else
openlog("dnsmasq", LOG_PID, daemon->log_fac);
}
int read_write(int fd, unsigned char *packet, int size, int rw)
{
ssize_t n, done;
for (done = 0; done < size; done += n)
{
retry:
if (rw)
n = read(fd, &packet[done], (size_t)(size - done));
else
n = write(fd, &packet[done], (size_t)(size - done));
if (n == 0)
return 0;
else if (n == -1)
{
if (errno == EINTR || errno == ENOMEM || errno == ENOBUFS)
goto retry;
else
return 0;
}
}
return 1;
}