Dont need plibc

This commit is contained in:
Erik Ekman 2009-01-25 16:42:28 +00:00
parent 430fc39ff5
commit 62f75fb2e7
5 changed files with 13 additions and 31 deletions

View file

@ -41,7 +41,6 @@
#endif
#include "common.h"
#include "plibc.h"
/* daemon(3) exists only in 4.4BSD or later, and in GNU libc */
#if !defined(WINDOWS32) && !(defined(BSD) && (BSD >= 199306)) && !defined(__GLIBC__)
@ -114,20 +113,20 @@ open_dns(int localport, in_addr_t listen_ip)
/* listen_ip already in network byte order from inet_addr, or 0 */
addr.sin_addr.s_addr = listen_ip;
if ((fd = SOCKET(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
printf("got fd %d\n", fd);
err(1, "socket");
}
flag = 1;
#ifdef SO_REUSEPORT
SETSOCKOPT(fd, SOL_SOCKET, SO_REUSEPORT, (const void*) &flag, sizeof(flag));
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (const void*) &flag, sizeof(flag));
#endif
SETSOCKOPT(fd, SOL_SOCKET, SO_REUSEADDR, (const void*) &flag, sizeof(flag));
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void*) &flag, sizeof(flag));
#ifndef WINDOWS32
/* To get destination address from each UDP datagram, see iodined.c:read_dns() */
SETSOCKOPT(fd, IPPROTO_IP, DSTADDR_SOCKOPT, (const void*) &flag, sizeof(flag));
setsockopt(fd, IPPROTO_IP, DSTADDR_SOCKOPT, (const void*) &flag, sizeof(flag));
#endif
if(bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0)

View file

@ -43,7 +43,6 @@
#include <netdb.h>
#endif
#include "plibc.h"
#include "common.h"
#include "encoding.h"
#include "base32.h"
@ -172,13 +171,13 @@ read_dns(int fd, char *buf, int buflen)
{
struct sockaddr_in from;
char data[64*1024];
int addrlen;
socklen_t addrlen;
struct query q;
int rv;
int r;
addrlen = sizeof(struct sockaddr);
if ((r = RECVFROM(fd, data, sizeof(data), 0,
if ((r = recvfrom(fd, data, sizeof(data), 0,
(struct sockaddr*)&from, &addrlen)) == -1) {
warn("recvfrom");
return 0;
@ -315,7 +314,7 @@ tunnel(int tun_fd, int dns_fd)
}
FD_SET(dns_fd, &fds);
i = SELECT(MAX(tun_fd, dns_fd) + 1, &fds, NULL, NULL, &tv);
i = select(MAX(tun_fd, dns_fd) + 1, &fds, NULL, NULL, &tv);
if (running == 0)
break;
@ -907,10 +906,6 @@ main(int argc, char **argv)
b32 = get_base32_encoder();
dataenc = get_base32_encoder();
#ifdef WINDOWS32
plibc_init("Kryo", "iodine");
#endif
#if !defined(BSD) && !defined(__GLIBC__)
__progname = strrchr(argv[0], '/');
if (__progname == NULL)

View file

@ -48,7 +48,6 @@
#include <netdb.h>
#endif
#include "plibc.h"
#include "common.h"
#include "dns.h"
#include "encoding.h"
@ -780,7 +779,7 @@ static int
read_dns(int fd, struct query *q)
{
struct sockaddr_in from;
int addrlen;
socklen_t addrlen;
char packet[64*1024];
int r;
#ifndef WINDOWS32
@ -804,7 +803,7 @@ read_dns(int fd, struct query *q)
r = recvmsg(fd, &msg, 0);
#else
addrlen = sizeof(struct sockaddr);
r = RECVFROM(fd, packet, sizeof(packet), 0, (struct sockaddr*)&from, &addrlen);
r = recvfrom(fd, packet, sizeof(packet), 0, (struct sockaddr*)&from, &addrlen);
#endif /* !WINDOWS32 */
if (r > 0) {

View file

@ -14,13 +14,13 @@ link)
echo '-lnetwork';
;;
windows32)
echo '-lplibc -lws2_32';
echo '-lws2_32';
;;
esac
;;
cflags)
case $1 in
BeOS)
BeOS | windows32)
echo '-Dsocklen_t=int';
;;
esac

View file

@ -50,7 +50,6 @@ struct tun_data data;
char if_name[50];
#endif
#include "plibc.h"
#include "tun.h"
#include "common.h"
@ -354,11 +353,10 @@ write_tun(int tun_fd, char *data, size_t len)
ssize_t
read_tun(int tun_fd, char *buf, size_t len)
{
#ifndef WINDOWS32
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD)
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD) || defined(WINDOWS32)
/* FreeBSD/Darwin/NetBSD has no header */
int bytes;
bytes = read(tun_fd, buf + 4, len - 4);
bytes = recv(tun_fd, buf + 4, len, 0);
if (bytes < 0) {
return bytes;
} else {
@ -367,15 +365,6 @@ read_tun(int tun_fd, char *buf, size_t len)
#else /* !FREEBSD */
return read(tun_fd, buf, len);
#endif /* !FREEBSD */
#else /* !WINDOWS32 */
int bytes;
bytes = RECV(tun_fd, buf + 4, len, 0);
if (bytes < 0) {
return bytes;
} else {
return bytes + 4;
}
#endif
}
int