65
65
* Reference:
66
66
* Used mDNS messages:
67
67
* A (0x01): eg. esp8266.local A OP TTL 123.456.789.012
68
- * AAAA (01Cx ): eg. esp8266.local AAAA OP TTL 1234:5678::90
68
+ * AAAA (0x1C ): eg. esp8266.local AAAA OP TTL 1234:5678::90
69
69
* PTR (0x0C, srv name): eg. _http._tcp.local PTR OP TTL MyESP._http._tcp.local
70
70
* PTR (0x0C, srv type): eg. _services._dns-sd._udp.local PTR OP TTL _http._tcp.local
71
71
* PTR (0x0C, IP4): eg. 012.789.456.123.in-addr.arpa PTR OP TTL esp8266.local
107
107
#include " lwip/udp.h"
108
108
#include " debug.h"
109
109
#include " include/UdpContext.h"
110
- #include " LEATimeFlag.h"
110
+ #include < limits>
111
+ #include < PolledTimeout.h>
111
112
112
113
#include " ESP8266WiFi.h"
113
114
@@ -786,8 +787,9 @@ class MDNSResponder {
786
787
*/
787
788
struct stcProbeInformation {
788
789
enuProbingStatus m_ProbingStatus;
789
- uint8_t m_u8ProbesSent;
790
- clsMDNSTimeFlag m_NextProbeTimeFlag;
790
+ uint8_t m_u8SentCount; // Used for probes and announcements
791
+ esp8266::polledTimeout::oneShot m_Timeout; // Used for probes and announcements
792
+ // clsMDNSTimeFlag m_TimeFlag; // Used for probes and announcements
791
793
bool m_bConflict;
792
794
bool m_bTiebreakNeeded;
793
795
MDNSProbeResultCallbackFn m_fnProbeResultCallback;
@@ -842,14 +844,32 @@ class MDNSResponder {
842
844
* stcTTL
843
845
*/
844
846
struct stcTTL {
845
- clsMDNSTimeFlag m_TTLTimeFlag;
846
- bool m_bUpdateScheduled;
847
+ /* *
848
+ * timeoutLevel_t
849
+ */
850
+ typedef uint8_t timeoutLevel_t;
851
+ /* *
852
+ * TIMEOUTLEVELs
853
+ */
854
+ const timeoutLevel_t TIMEOUTLEVEL_UNSET = 0 ;
855
+ const timeoutLevel_t TIMEOUTLEVEL_BASE = 80 ;
856
+ const timeoutLevel_t TIMEOUTLEVEL_INTERVAL = 5 ;
857
+ const timeoutLevel_t TIMEOUTLEVEL_FINAL = 100 ;
847
858
848
- stcTTL (uint32_t p_u32TTL = 0 );
859
+ uint32_t m_u32TTL;
860
+ esp8266::polledTimeout::oneShot m_TTLTimeout;
861
+ timeoutLevel_t m_timeoutLevel;
862
+
863
+ stcTTL (void );
849
864
bool set (uint32_t p_u32TTL);
850
865
851
- bool has80Percent (void ) const ;
852
- bool isOutdated (void ) const ;
866
+ bool flagged (void ) const ;
867
+ bool restart (void );
868
+
869
+ bool prepareDeletion (void );
870
+ bool finalTimeoutLevel (void ) const ;
871
+
872
+ unsigned long timeout (void ) const ;
853
873
};
854
874
#ifdef MDNS_IP4_SUPPORT
855
875
/* *
@@ -861,7 +881,7 @@ class MDNSResponder {
861
881
stcTTL m_TTL;
862
882
863
883
stcIP4Address (IPAddress p_IPAddress,
864
- uint32_t p_u32TTL = 0 );
884
+ uint32_t p_u32TTL = 0 );
865
885
};
866
886
#endif
867
887
#ifdef MDNS_IP6_SUPPORT
@@ -872,6 +892,9 @@ class MDNSResponder {
872
892
stcIP6Address* m_pNext;
873
893
IP6Address m_IPAddress;
874
894
stcTTL m_TTL;
895
+
896
+ stcIP6Address (IPAddress p_IPAddress,
897
+ uint32_t p_u32TTL = 0 );
875
898
};
876
899
#endif
877
900
@@ -932,13 +955,15 @@ class MDNSResponder {
932
955
#endif
933
956
};
934
957
935
- stcMDNSServiceQuery* m_pNext;
936
- stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
937
- MDNSServiceQueryCallbackFn m_fnCallback;
938
- void * m_pUserdata;
939
- bool m_bLegacyQuery;
940
- bool m_bAwaitingAnswers;
941
- stcAnswer* m_pAnswers;
958
+ stcMDNSServiceQuery* m_pNext;
959
+ stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
960
+ MDNSServiceQueryCallbackFn m_fnCallback;
961
+ void * m_pUserdata;
962
+ bool m_bLegacyQuery;
963
+ uint8_t m_u8SentCount;
964
+ esp8266::polledTimeout::oneShot m_ResendTimeout;
965
+ bool m_bAwaitingAnswers;
966
+ stcAnswer* m_pAnswers;
942
967
943
968
stcMDNSServiceQuery (void );
944
969
~stcMDNSServiceQuery (void );
@@ -1012,6 +1037,7 @@ class MDNSResponder {
1012
1037
WiFiEventHandler m_GotIPHandler;
1013
1038
MDNSDynamicServiceTxtCallbackFn m_fnServiceTxtCallback;
1014
1039
void * m_pServiceTxtCallbackUserdata;
1040
+ bool m_bPassivModeEnabled;
1015
1041
stcProbeInformation m_HostProbeInformation;
1016
1042
1017
1043
/* * CONTROL **/
@@ -1047,7 +1073,8 @@ class MDNSResponder {
1047
1073
bool _cancelProbingForService (stcMDNSService& p_rService);
1048
1074
1049
1075
/* ANNOUNCE */
1050
- bool _announce (bool p_bAnnounce = true );
1076
+ bool _announce (bool p_bAnnounce,
1077
+ bool p_bIncludeServices);
1051
1078
bool _announceService (stcMDNSService& p_rService,
1052
1079
bool p_bAnnounce = true );
1053
1080
@@ -1064,7 +1091,8 @@ class MDNSResponder {
1064
1091
IPAddress p_IPAddress);
1065
1092
bool _sendMDNSServiceQuery (const stcMDNSServiceQuery& p_ServiceQuery);
1066
1093
bool _sendMDNSQuery (const stcMDNS_RRDomain& p_QueryDomain,
1067
- uint16_t p_u16QueryType);
1094
+ uint16_t p_u16QueryType,
1095
+ stcMDNSServiceQuery::stcAnswer* p_pKnownAnswers = 0 );
1068
1096
1069
1097
IPAddress _getResponseMulticastInterface (int p_iWiFiOpModes) const ;
1070
1098
0 commit comments