Changeset 2088
- Timestamp:
- 05/26/10 12:23:09 (21 months ago)
- Location:
- Whitix/branches/netchannel/user/sdk/network
- Files:
-
- 10 added
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/netchannel/user/sdk/network/Makefile
r2085 r2088 1 CFLAGS = -Wall -I../include -I../../libc/include -nostdlib -ffreestanding -fno-builtin -fPIC -m32 -O3 1 CFLAGS = -Wall -I../include -I../../libc/include -nostdlib -ffreestanding -fno-builtin -fPIC -m32 -O3 -Werror 2 2 3 OBJS = byteorder.o ipv4.o udp.o memory.o dns.o icmp.o tcp.o tcp_options.o channels.o init.o socket.o3 OBJS = aio.o byteorder.o ipv4.o udp.o memory.o dns.o icmp.o tcp.o tcp_options.o channels.o init.o socket.o stats.o 4 4 5 5 .c.o: … … 8 8 build: $(OBJS) 9 9 gcc -m32 -nostdlib -ffreestanding -fno-builtin -shared -L../libs/ \ 10 -L../../posix/ -lpthread -o ../libs/libnetwork.so -Wl,-init=Network Init \10 -L../../posix/ -lpthread -o ../libs/libnetwork.so -Wl,-init=NetworkPreInit \ 11 11 $(OBJS) ../../libc/init/crt_begin.o ../../libc/init/crt_end.o 12 12 -
Whitix/branches/netchannel/user/sdk/network/socket.c
r2086 r2088 108 108 return socket->ops->shutdown(socket); 109 109 110 /* TODO: Free socket */ 110 /* TODO: Free socket, channel */ 111 printf("SocketClose\n"); 111 112 112 113 return -1; -
Whitix/branches/netchannel/user/sdk/network/udp.c
r2084 r2088 5 5 #include <net/channels.h> 6 6 #include <net/ipv4.h> 7 8 #include "checksum.h" 7 9 8 10 static struct SocketOps udpSocketOps; … … 127 129 } 128 130 131 int UdpCalcChecksum(struct IpHeader* ipHeader, struct UdpHeader* udpHeader, int read) 132 { 133 ushort sum = udpHeader->checkSum; 134 135 udpHeader->checkSum = 0; 136 137 udpHeader->checkSum = sum; 138 } 139 129 140 int UdpSocketRecvFrom(Socket* socket, void* buffer, unsigned long length, int flags, 130 141 struct SockAddr* dest) … … 134 145 char* buf; 135 146 int dataByteCnt; 147 struct IpHeader* ipHeader; 148 struct UdpHeader* udpHeader; 136 149 150 again: 137 151 read = ChanBufferRecv(socket->channel, &chanBuff, &buf, 2000); 138 152 … … 142 156 return read; 143 157 } 158 159 /* Verify checksum */ 160 ipHeader = (struct IpHeader*)buf; 161 udpHeader = (struct UdpHeader*)(buf + sizeof(struct IpHeader)); 162 if (NetToHostShort(udpHeader->checkSum) != UdpCalcChecksum(ipHeader, udpHeader, read)) 163 goto again; 144 164 145 165 dataByteCnt = read - sizeof(struct UdpHeader) - sizeof(struct IpHeader);
