Changeset 2088

Show
Ignore:
Timestamp:
05/26/10 12:23:09 (21 months ago)
Author:
mwhitworth
Message:

Update to actually include all network stack progress so far.

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 
     1CFLAGS = -Wall -I../include -I../../libc/include -nostdlib -ffreestanding -fno-builtin -fPIC -m32 -O3 -Werror 
    22 
    3 OBJS = byteorder.o ipv4.o udp.o memory.o dns.o icmp.o tcp.o tcp_options.o channels.o init.o socket.o 
     3OBJS = 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 
    44 
    55.c.o: 
     
    88build: $(OBJS) 
    99        gcc -m32 -nostdlib -ffreestanding -fno-builtin -shared -L../libs/ \ 
    10         -L../../posix/ -lpthread -o ../libs/libnetwork.so -Wl,-init=NetworkInit \ 
     10        -L../../posix/ -lpthread -o ../libs/libnetwork.so -Wl,-init=NetworkPreInit \ 
    1111                $(OBJS) ../../libc/init/crt_begin.o ../../libc/init/crt_end.o 
    1212 
  • Whitix/branches/netchannel/user/sdk/network/socket.c

    r2086 r2088  
    108108                return socket->ops->shutdown(socket); 
    109109 
    110         /* TODO: Free socket */ 
     110        /* TODO: Free socket, channel */ 
     111        printf("SocketClose\n"); 
    111112 
    112113        return -1; 
  • Whitix/branches/netchannel/user/sdk/network/udp.c

    r2084 r2088  
    55#include <net/channels.h> 
    66#include <net/ipv4.h> 
     7 
     8#include "checksum.h" 
    79 
    810static struct SocketOps udpSocketOps; 
     
    127129} 
    128130 
     131int 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 
    129140int UdpSocketRecvFrom(Socket* socket, void* buffer, unsigned long length, int flags, 
    130141        struct SockAddr* dest) 
     
    134145        char* buf; 
    135146        int dataByteCnt; 
     147        struct IpHeader* ipHeader; 
     148        struct UdpHeader* udpHeader; 
    136149 
     150again: 
    137151        read = ChanBufferRecv(socket->channel, &chanBuff, &buf, 2000); 
    138152 
     
    142156                return read; 
    143157        } 
     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; 
    144164 
    145165        dataByteCnt = read - sizeof(struct UdpHeader) - sizeof(struct IpHeader);