mdns+xnet: add test that replicates issue in cyw43439

This commit is contained in:
Patricio Whittingslow
2026-03-26 17:41:27 -03:00
parent c06a4fa99b
commit 33f492557a
4 changed files with 188 additions and 0 deletions
+7
View File
@@ -22,6 +22,7 @@ func NewFrame(buf []byte) (Frame, error) {
// Frame encapsulates the raw data of an IPv4 packet
// and provides methods for manipulating, validating and
// retreiving fields and payload data. See [RFC791].
// Below is an example of setting IPv4 fields for MDNS:
//
// [RFC791]: https://tools.ietf.org/html/rfc791
type Frame struct {
@@ -156,6 +157,12 @@ func (ifrm Frame) CRCWriteTCPPseudo(crc *lneto.CRC791) {
crc.AddUint16(uint16(ifrm.Protocol()))
}
// CRCWriteUDPPseudo writes the IPv4 UDP pseudo-header into crc for checksum
// calculation. Typical usage for computing or validating a UDP checksum:
//
// ifrm.CRCWriteUDPPseudo(&crc, ufrm.Length())
// // ufrm.SetCRC(0) // Zero before computing checksum for transmission.
// crcValue := crc.PayloadSum16(ifrm.Payload()) // For received frames, crcValue should be zero if valid.
func (ifrm Frame) CRCWriteUDPPseudo(crc *lneto.CRC791, udpLength uint16) {
crc.WriteEven(ifrm.sourceAndDestinationAddr())
crc.AddUint16(udpLength)