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:
42:222a4f45f916
Parent:
37:793b39683406
Child:
43:bc028d5a6424
--- a/udp/udp.cpp	Fri Oct 06 10:18:01 2017 +0000
+++ b/udp/udp.cpp	Sun Oct 15 17:54:09 2017 +0000
@@ -41,18 +41,20 @@
         case DNS_LLMNR_SERVER_PORT:     return  DnsHandlePacketReceived(traceback, DNS_PROTOCOL_LLMNR, pDataLength, pData);  // 5355
         
         //Quietly drop these
-        case DHCP_SERVER_PORT:                                                          //67
-        case   137:                                                                     //NETBIOS name service
-        case   138:                                                                     //NETBIOS datagram service
-        case   139:                                                                     //NETBIOS session service
-        case  1900:                                                                     //SSDP Simple Service Discovery Protocol (uPnP)
-        case  3076:                                                                     //Call of Duty - Xbox
-        case  5224:                                                                     //Don't know but a burst was broadcast by Kate's phone containing '_logitech-reverse-bonjour._tcp.local.5446 192.168.1.36 string'
-        case  9956:                                                                     //Alljoyn part af Allseen IoT services
-        case  9997:                                                                     //VLC
-        case  9998:                                                                     //VLC
-        case  9999:                                                                     //VLC
-        case 17500:                                                                     //Dropbox LAN sync
+        case DHCP_SERVER_PORT:  //67
+        case   137:             //NETBIOS name service
+        case   138:             //NETBIOS datagram service
+        case   139:             //NETBIOS session service
+        case   500:             //Key exchange - Xbox live                  
+        case  1900:             //SSDP Simple Service Discovery Protocol (uPnP)
+        case  3074:             //Xbox live
+        case  3076:             //Call of Duty - Xbox
+        case  5224:             //Don't know but a burst was broadcast by Kate's phone containing '_logitech-reverse-bonjour._tcp.local.5446 192.168.1.36 string'
+        case  9956:             //Alljoyn part af Allseen IoT services
+        case  9997:             //VLC
+        case  9998:             //VLC
+        case  9999:             //VLC
+        case 17500:             //Dropbox LAN sync
             return DO_NOTHING;
             
         //Report anything else
@@ -79,6 +81,7 @@
 static int pollForPacketToSend(int type, int* pDataLength, void* pData)
 {
     int action = DO_NOTHING;
+    uint16_t preferredPolledIpType = NetPreferIp4Polled ? IPV4 : IPV6;
     
     if (!action && type == IPV4) //DHCP only works under IPv4
     {
@@ -90,7 +93,7 @@
         }
     }
     
-    if (!action) //DNS is agnostic
+    if (!action && type == preferredPolledIpType) //DNS is agnostic
     {
         action = DnsPollForPacketToSend(pData, pDataLength);
         int dest = ActionGetDestPart(action);
@@ -109,7 +112,7 @@
             }
         }
     }
-    if (!action) //NTP needs to choose depending of what address is specified
+    if (!action && type == preferredPolledIpType) //NTP is agnostic
     {
         action = NtpPollForPacketToSend(type, pData, pDataLength);
         if (action)