32 lines
933 B
C++
32 lines
933 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,
|
|
uint32_t const requested_ip_address);
|
|
};
|