A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
Diff: ip6/udptcp6.c
- Revision:
- 74:c3756bfa960e
- Parent:
- 73:43e3d7fb3d60
- Child:
- 80:4ef1500fca1d
--- a/ip6/udptcp6.c Tue Oct 23 06:46:50 2018 +0000 +++ b/ip6/udptcp6.c Mon Oct 29 09:33:44 2018 +0000 @@ -1,18 +1,22 @@ #include <stdint.h> #include <string.h> -#include "log.h" -#include "net.h" -#include "action.h" -#include "eth.h" -#include "dhcp.h" -#include "ns.h" -#include "ip.h" +#include "log.h" +#include "net.h" +#include "action.h" +#include "eth.h" +#include "dhcp.h" +#include "ns.h" +#include "ip.h" #include "ip6addr.h" -#include "slaac.h" -#include "tcp.h" -#include "udp.h" -#include "tcphdr.h" +#include "slaac.h" +#include "tcp.h" +#include "tcprecv.h" +#include "tcpsend.h" +#include "tcphdr.h" +#include "udp.h" +#include "led.h" +#include "ar6.h" static uint16_t calculateChecksum(uint8_t pro, char* pSrcIp, char* pDstIp, int size, void* pPacket) { @@ -42,7 +46,7 @@ switch (pro) { - case TCP: TcpHdrWrite(size, pPacket); break; + case TCP: TcpHdrWriteToPacket(pPacket); break; case UDP: UdpMakeHeader(size, pPacket); break; } @@ -50,7 +54,7 @@ switch (pro) { - case TCP: TcpHdrAddChecksum(pPacket, checksum); break; + case TCP: TcpHdrAddChecksumToPacket(pPacket, checksum); break; case UDP: UdpAddChecksum(pPacket, checksum); break; } @@ -77,13 +81,13 @@ } } -int Tcp6HandleReceivedPacket(void (*traceback)(void), int scope, void* pPacketRx, int sizeRx, void* pPacketTx, int* pSizeTx, char* pSrcIp, char* pDstIp, char* pCachedRemIp) +int Tcp6HandleReceivedPacket(void (*traceback)(void), int scope, void* pPacketRx, int sizeRx, void* pPacketTx, int* pSizeTx, char* pSrcIp, char* pDstIp, int remArIndex) { pTraceBack = traceback; tracePacketProtocol = TCP; calculatedChecksum = calculateChecksum(TCP, pSrcIp, pDstIp, sizeRx, pPacketRx); - int action = TcpHandleReceivedPacket(trace, sizeRx, pPacketRx, pSizeTx, pPacketTx, IPV6, pCachedRemIp); + int action = TcpHandleReceivedPacket(trace, sizeRx, pPacketRx, pSizeTx, pPacketTx, IPV6, remArIndex); Ip6AddressCopy(pDstIp, pSrcIp); @@ -107,8 +111,10 @@ return action; } int Tcp6PollForPacketToSend(void* pPacket, int* pSize, char* pSrcIp, char* pDstIp) -{ - int action = TcpPollForPacketToSend(pSize, pPacket, IPV6, pDstIp); +{ + int remArIndex = -1; + int action = TcpPollForPacketToSend(pSize, pPacket, IPV6, &remArIndex); + if (action && remArIndex >= 0) Ar6IndexToIp(remArIndex, pDstIp); int scope = SCOPE_LOCAL;