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

Revision:
195:bd5b123143ca
Parent:
173:9bc30cd82a76
Child:
196:0876a7609a60
diff -r f35c6e218de1 -r bd5b123143ca udp/udp.c
--- a/udp/udp.c	Thu Mar 04 12:08:14 2021 +0000
+++ b/udp/udp.c	Sun Apr 18 19:04:48 2021 +0000
@@ -16,6 +16,7 @@
 #include "ns.h"
 #include "ntpclient.h"
 #include "restart.h"
+#include "user.h"
 
 bool UdpTrace = true;
 
@@ -70,6 +71,8 @@
 
 static int handlePort(void (*traceback)(void), int dataLengthRx, char* pDataRx, int* pPataLengthTx, char* pDataTx)
 {
+    if (UserHandleReceivedUdpPacket && (dstPort == UserUdpPort1 || dstPort == UserUdpPort2)) return UserHandleReceivedUdpPacket(dstPort, traceback, dataLengthRx, pDataRx, pPataLengthTx, pDataTx);
+    
     switch (dstPort)
     {
         //Handle these
@@ -187,6 +190,15 @@
             dstPort = TFTP_SERVER_PORT;
         }
     }
+    if (!action)
+    {
+        action = UserPollForUdpPacketToSend(type, pDataLength, pData);
+        if (action)
+        {
+            srcPort = UserUdpDstPort;
+            dstPort = UserUdpSrcPort;
+        }
+    }
     
     return action;
 }