dhcp/packet.h

32 lines
938 B
C++

#pragma once
#include "eth.h"
#include "ip4.h"
#include "udp4.h"
#include "dhcp4.h"
namespace packet {
struct packet {
eth::header const * eth;
ip4::header const * ip4;
udp4::header const * udp4;
dhcp4::message const * dhcp4;
};
void parse(uint8_t const * buf, int length, packet * p);
const int eth_offset = 0;
const int ip4_offset = (sizeof (eth::header));
const int udp4_offset = (sizeof (eth::header)) + (sizeof (ip4::header));
const int dhcp4_offset = (sizeof (eth::header)) + (sizeof (ip4::header)) + (sizeof (udp4::header));
int make(uint8_t * buf,
uint8_t const * eth_source_address,
uint8_t const * eth_destination_address,
uint32_t const ip4_source_address,
uint32_t const ip4_destination_address,
uint32_t const dhcp_transaction_id,
uint32_t const dhcp_message_type,
dhcp4::message_parameters const * params);
};