Removed socket library, there is a socket library in libc now
This commit is contained in:
parent
343bd97aeb
commit
5c9d34b62a
|
@ -30,7 +30,6 @@ all:
|
|||
test `arch` = i86 || { cd regex && $(MAKE); }
|
||||
cd rts && $(MAKE)
|
||||
cd stdio && $(MAKE)
|
||||
#cd socket && $(MAKE)
|
||||
cd syscall && $(MAKE)
|
||||
cd syslib && $(MAKE)
|
||||
cd util && $(MAKE)
|
||||
|
@ -144,7 +143,6 @@ install_i386: \
|
|||
$(LIB386)/libcurses.a \
|
||||
$(LIB386)/libedit.a \
|
||||
$(LIB386)/liby.a \
|
||||
# $(LIB386)/libsocket.a \
|
||||
# $(LIB86)/libc.a \
|
||||
# $(LIB86)/end.a \
|
||||
|
||||
|
@ -202,9 +200,6 @@ $(LIB386)/libedit.a: libedit.a
|
|||
$(LIB386)/liby.a: liby.a
|
||||
install -c -o bin $? $@
|
||||
|
||||
#$(LIB386)/libsocket.a: libsocket.a
|
||||
# install -c -o bin $? $@
|
||||
#
|
||||
#$(LIB86)/libc.a: libc86.a
|
||||
# install -c -o bin $? $@
|
||||
#
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
|
||||
CFLAGS = -O -D_MINIX -D_POSIX_SOURCE -I../../servers
|
||||
CC1 = $(CC) $(CFLAGS) -c
|
||||
|
||||
LIBRARY = ../libsocket.a
|
||||
all: $(LIBRARY)
|
||||
|
||||
OBJECTS = \
|
||||
$(LIBRARY)(socket.o) \
|
||||
$(LIBRARY)(listen.o) \
|
||||
$(LIBRARY)(connect.o) \
|
||||
$(LIBRARY)(shutdown.o) \
|
||||
$(LIBRARY)(extra.o) \
|
||||
$(LIBRARY)(bind.o)
|
||||
|
||||
$(LIBRARY): $(OBJECTS)
|
||||
aal cr $@ *.o
|
||||
rm *.o
|
||||
|
||||
$(LIBRARY)(socket.o): socket.c
|
||||
$(CC1) socket.c
|
||||
|
||||
$(LIBRARY)(connect.o): connect.c
|
||||
$(CC1) connect.c
|
||||
|
||||
$(LIBRARY)(listen.o): listen.c
|
||||
$(CC1) listen.c
|
||||
|
||||
$(LIBRARY)(shutdown.o): shutdown.c
|
||||
$(CC1) shutdown.c
|
||||
|
||||
$(LIBRARY)(extra.o): extra.c
|
||||
$(CC1) extra.c
|
||||
|
||||
$(LIBRARY)(bind.o): bind.c
|
||||
$(CC1) bind.c
|
||||
|
||||
clean:
|
||||
-rm *.o $(LIBRARY)
|
|
@ -1,34 +0,0 @@
|
|||
|
||||
/* bsd-socket(2)-lookalike */
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/ioctl.h>
|
||||
#include <net/gen/socket.h>
|
||||
#include <net/gen/emu.h>
|
||||
#include <net/gen/tcp.h>
|
||||
#include <net/gen/in.h>
|
||||
#include <net/gen/tcp_hdr.h>
|
||||
#include <net/gen/tcp_io.h>
|
||||
|
||||
int
|
||||
bind(int s, struct sockaddr *addr, socklen_t len)
|
||||
{
|
||||
nwio_tcpconf_t tcpconf;
|
||||
struct sockaddr_in *in_local;
|
||||
|
||||
in_local = (struct sockaddr_in *) addr;
|
||||
|
||||
memset(&tcpconf, 0, sizeof(tcpconf));
|
||||
tcpconf.nwtc_flags = NWTC_EXCL | NWTC_LP_SET | NWTC_UNSET_RA | NWTC_UNSET_RP;
|
||||
tcpconf.nwtc_locport = in_local->sin_port;
|
||||
|
||||
if(ioctl(s, NWIOSTCPCONF, &tcpconf) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
/* bsd-socket(2)-lookalike */
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/ioctl.h>
|
||||
#include <net/gen/in.h>
|
||||
#include <net/gen/socket.h>
|
||||
#include <net/gen/emu.h>
|
||||
#include <net/gen/tcp.h>
|
||||
#include <net/gen/tcp_hdr.h>
|
||||
#include <net/gen/tcp_io.h>
|
||||
|
||||
int
|
||||
connect(int s, struct sockaddr *peer, socklen_t len)
|
||||
{
|
||||
nwio_tcpcl_t tcpopt;
|
||||
nwio_tcpconf_t tcpconf;
|
||||
struct sockaddr_in *in_peer;
|
||||
|
||||
if(!peer || peer->sa_family != AF_INET ||
|
||||
len != sizeof(struct sockaddr_in)) {
|
||||
errno = EAFNOSUPPORT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
in_peer = (struct sockaddr_in *) peer;
|
||||
|
||||
memset(&tcpconf, 0, sizeof(tcpconf));
|
||||
tcpconf.nwtc_flags = NWTC_EXCL | NWTC_LP_SEL | NWTC_SET_RA | NWTC_SET_RP;
|
||||
tcpconf.nwtc_remaddr = in_peer->sin_addr.s_addr;
|
||||
tcpconf.nwtc_remport = in_peer->sin_port;
|
||||
|
||||
if(ioctl(s, NWIOSTCPCONF, &tcpconf) < 0)
|
||||
return -1;
|
||||
|
||||
tcpopt.nwtcl_flags = 0;
|
||||
tcpopt.nwtcl_ttl = 0;
|
||||
|
||||
if(ioctl(s, NWIOTCPCONN, &tcpopt) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
/* bsd-socket(2)-lookalike */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <net/gen/socket.h>
|
||||
#include <net/gen/emu.h>
|
||||
#include <net/gen/tcp.h>
|
||||
#include <net/gen/in.h>
|
||||
#include <net/gen/tcp_hdr.h>
|
||||
#include <net/gen/tcp_io.h>
|
||||
|
||||
ssize_t
|
||||
recv(int s, void *buf, size_t len, int flags)
|
||||
{
|
||||
return read(s, buf, len);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
send(int s, void *buf, size_t len, int flags)
|
||||
{
|
||||
return write(s, buf, len);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
/* bsd-socket(2)-lookalike */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <net/gen/socket.h>
|
||||
#include <net/gen/in.h>
|
||||
#include <net/ioctl.h>
|
||||
#include <net/gen/emu.h>
|
||||
#include <net/gen/tcp.h>
|
||||
#include <net/gen/tcp_hdr.h>
|
||||
#include <net/gen/tcp_io.h>
|
||||
|
||||
int
|
||||
listen(int s, int backlog)
|
||||
{
|
||||
nwio_tcpcl_t tcpopt;
|
||||
struct sockaddr_in *in_peer;
|
||||
|
||||
tcpopt.nwtcl_flags = tcpopt.nwtcl_ttl = 0;
|
||||
|
||||
if(ioctl(s, NWIOTCPLISTEN, &tcpopt) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
/* bsd-socket(2)-lookalike */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/gen/socket.h>
|
||||
#include <net/gen/emu.h>
|
||||
#include <net/gen/tcp.h>
|
||||
#include <net/gen/in.h>
|
||||
#include <net/gen/tcp_hdr.h>
|
||||
#include <net/gen/tcp_io.h>
|
||||
|
||||
int
|
||||
shutdown(int s, int how)
|
||||
{
|
||||
nwio_tcpcl_t tcpopt;
|
||||
|
||||
if(ioctl(s, NWIOTCPSHUTDOWN, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
|
||||
/* bsd-socket(2)-lookalike */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/gen/socket.h>
|
||||
#include <net/gen/emu.h>
|
||||
#include <net/gen/tcp.h>
|
||||
#include <net/gen/in.h>
|
||||
#include <net/gen/tcp_hdr.h>
|
||||
#include <net/gen/tcp_io.h>
|
||||
|
||||
int
|
||||
socket(int domain, int type, int protocol)
|
||||
{
|
||||
int s;
|
||||
char *tcpname;
|
||||
|
||||
/* only domain is AF_INET */
|
||||
if(domain != AF_INET) {
|
||||
errno = EAFNOSUPPORT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* only type is SOCK_STREAM */
|
||||
if(type != SOCK_STREAM) {
|
||||
errno = EPROTONOSUPPORT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* default protocol type is TCP */
|
||||
if(!protocol)
|
||||
protocol = IPPROTO_TCP;
|
||||
|
||||
/* only protocol type is TCP */
|
||||
if(protocol != IPPROTO_TCP) {
|
||||
errno = EPROTONOSUPPORT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* tcp device name */
|
||||
if(!tcpname)
|
||||
tcpname = getenv("TCP_DEVICE");
|
||||
if(!tcpname || !*tcpname)
|
||||
tcpname = "/dev/tcp";
|
||||
|
||||
if((s = open(tcpname, O_RDWR)) < 0) {
|
||||
perror(tcpname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in a new issue