瀏覽代碼

test for ipv6 and if_name2index and socklen_t.

master
Felix von Leitner 19 年之前
父節點
當前提交
cc26b4b5bb
共有 9 個文件被更改,包括 115 次插入23 次删除
  1. +34
    -8
      Makefile
  2. +0
    -2
      haveip6.h
  3. +0
    -1
      haven2i.h
  4. +27
    -3
      socket/socket_tcp6.c
  5. +26
    -3
      socket/socket_udp6.c
  6. +5
    -6
      t.c
  7. +8
    -0
      tryip6.c
  8. +8
    -0
      tryn2i.c
  9. +7
    -0
      trysl.c

+ 34
- 8
Makefile 查看文件

@@ -2,12 +2,12 @@ all: t byte.a fmt.a scan.a str.a uint.a open.a stralloc.a unix.a socket.a buffer

VPATH=str:byte:fmt:scan:uint:open:stralloc:unix:socket:buffer:mmap

# comment out the following line if you don't want to build with the
# diet libc (http://www.fefe.de/dietlibc/).
DIET=diet -Os
CC=gcc
CFLAGS=-I. -pipe -Wall -O2 -pipe -fomit-frame-pointer
#CFLAGS=-I. -pipe -Wall -Os -march=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
#CFLAGS=-I. -I../dietlibc/include -pipe -Wall -Os -malign-functions=2 -fschedule-insns2 -g
#CFLAGS=-I../dietlibc/include -I. -pipe -Wall -Os -march=pentiumpro -mcpu=athlon -fomit-frame-pointer -fschedule-insns2 -Wall
#CFLAGS=-I../dietlibc/include -pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
#CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall

BYTE_OBJS=$(patsubst byte/%.c,%.o,$(wildcard byte/*.c))
FMT_OBJS=$(patsubst fmt/%.c,%.o,$(wildcard fmt/*.c))
@@ -49,14 +49,40 @@ $(BUFFER_OBJS) $(MMAP_OBJS)

%.a:
ar cr $@ $^
-ranlib $@

t: t.o socket.a stralloc.a buffer.a scan.a uint.a mmap.a open.a fmt.a \
str.a byte.a
$(DIET)$(CC) -g -o $@ $^
$(DIET) $(CC) -g -o $@ $^

.PHONY: clean tar
clean:
rm -f *.o *.a core t
rm -f *.o *.a core t haveip6.h haven2i.h

VERSION=libowfat-$(shell head -1 CHANGES|sed 's/://')
CURNAME=$(notdir $(shell pwd))

tar: clean rename
cd ..; tar cvvf $(VERSION).tar.bz2 $(VERSION) --use=bzip2 --exclude CVS

rename:
if test $(CURNAME) != $(VERSION); then cd .. && mv $(CURNAME) $(VERSION); fi

haveip6.h:
-rm -f $@
if $(DIET) $(CC) -c tryip6.c >/dev/null 2>&1; then echo "#define LIBC_HAS_IP6"; fi > $@

haven2i.h:
-rm -f $@
if $(DIET) $(CC) -o t tryn2i.c >/dev/null 2>&1; then echo "#define HAVE_N2I"; fi > $@

havesl.h:
-rm -f $@
if $(DIET) $(CC) -o t trysl.c >/dev/null 2>&1; then echo "#define HAVE_SOCKLEN_T"; fi > $@

socket_accept6.o socket_connect6.o socket_local6.o socket_mchopcount6.o \
socket_mcjoin6.o socket_mcleave6.o socket_mcloop6.o socket_recv6.o \
socket_remote6.o socket_send6.o socket_tcp6.o socket_udp6.o: haveip6.h

socket_getifidx.o socket_getifname.o: haven2i.h

tar:
cd .. && tar cf libowfat.tar.bz2 libowfat --use=bzip2 --exclude CVS

+ 0
- 2
haveip6.h 查看文件

@@ -1,2 +0,0 @@

#define LIBC_HAS_IP6

+ 0
- 1
haven2i.h 查看文件

@@ -1 +0,0 @@
#define HAVE_N2I

+ 27
- 3
socket/socket_tcp6.c 查看文件

@@ -1,9 +1,33 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#include <errno.h>
#include "haveip6.h"
#include "socket.h"

int socket_tcp6(void) {
return socket(PF_INET6,SOCK_STREAM,IPPROTO_TCP);
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT EINVAL
#endif

int socket_tcp6(void)
{
#ifdef LIBC_HAS_IP6
int s;

if (noipv6) goto compat;
s = socket(PF_INET6,SOCK_STREAM,0);
if (s == -1) {
if (errno == EINVAL || errno == EAFNOSUPPORT) {
compat:
s=socket(AF_INET,SOCK_STREAM,0);
noipv6=1;
if (s==-1) return -1;
} else
return -1;
}
return s;
#else
return socket_tcp();
#endif
}


+ 26
- 3
socket/socket_udp6.c 查看文件

@@ -1,9 +1,32 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#include <errno.h>
#include "haveip6.h"
#include "socket.h"

int socket_udp6(void) {
return socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT EINVAL
#endif

int socket_udp6(void)
{
#ifdef LIBC_HAS_IP6
int s;

if (noipv6) goto compat;
s = socket(PF_INET6,SOCK_DGRAM,0);
if (s == -1) {
if (errno == EINVAL || errno == EAFNOSUPPORT) {
compat:
s=socket(AF_INET,SOCK_DGRAM,0);
noipv6=1;
if (s==-1) return -1;
} else
return -1;
}
return s;
#else
return socket_udp();
#endif
}

+ 5
- 6
t.c 查看文件

@@ -14,12 +14,11 @@
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")

int main(int argc,char* argv[]) {
char buf[100];
buf[fmt_ulong(buf,0)]=0;
puts(buf);
#if 0
buffer_putspace(buffer_1);
buffer_flush(buffer_1);
#if 1
buffer_putulong(buffer_1,23);
// buffer_putspace(buffer_1);
buffer_putsflush(buffer_1,"\n");
// buffer_flush(buffer_1);
#endif
#if 0
long a,b,c;


+ 8
- 0
tryip6.c 查看文件

@@ -0,0 +1,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

main() {
struct sockaddr_in6 sa;
sa.sin6_family = PF_INET6;
}

+ 8
- 0
tryn2i.c 查看文件

@@ -0,0 +1,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>

int main() {
static char ifname[IFNAMSIZ];
char *tmp=if_indextoname(0,ifname);
}

+ 7
- 0
trysl.c 查看文件

@@ -0,0 +1,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

main() {
socklen_t t;
}

Loading…
取消
儲存