| 142 | } |
| 143 | |
| 144 | int SendUDP(void* data, size_t length, IPv4Address& destination, BigEndianUInt16 sourcePort, BigEndianUInt16 destinationPort){ |
| 145 | uint8_t buffer[1600]; |
| 146 | |
| 147 | if(length > 1518){ |
| 148 | return -EMSGSIZE; |
| 149 | } |
| 150 | |
| 151 | UDPHeader* header = (UDPHeader*)buffer; |
| 152 | header->destPort = destinationPort; |
| 153 | header->srcPort = sourcePort; |
| 154 | header->length = sizeof(UDPHeader) + length; |
| 155 | header->checksum = 0; |
| 156 | header->checksum = CaclulateChecksum(header, sizeof(UDPHeader)); |
| 157 | |
| 158 | memcpy(header->data, data, length); |
| 159 | |
| 160 | return SendIPv4(header, header->length, destination, IPv4ProtocolUDP); |
| 161 | } |
| 162 | } |
no test coverage detected