33 lines
723 B
C++
33 lines
723 B
C++
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "ip4.h"
|
|
|
|
namespace udp4 {
|
|
struct header {
|
|
uint16_t source_port;
|
|
uint16_t destination_port;
|
|
uint16_t length;
|
|
uint16_t checksum;
|
|
};
|
|
|
|
static_assert((sizeof (header)) == 8);
|
|
|
|
struct ip4_psuedo_header {
|
|
uint32_t source_address;
|
|
uint32_t destination_address;
|
|
uint8_t zeros;
|
|
uint8_t protocol;
|
|
uint16_t udp_length;
|
|
};
|
|
|
|
header * make_header(void * buf,
|
|
uint32_t source_port,
|
|
uint32_t destination_port,
|
|
uint32_t source_address,
|
|
uint32_t destination_address,
|
|
void const * payload,
|
|
int payload_length);
|
|
}
|