Changeset 2088 for Whitix/branches/netchannel/user/sdk/network/udp.c
- Timestamp:
- 05/26/10 12:23:09 (2 years ago)
- Files:
-
- 1 modified
-
Whitix/branches/netchannel/user/sdk/network/udp.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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);
