wire namespace
This file contains code derived from the DHCP server implementation originally developed by Espressif Systems and distributed as part of ESP-IDF.
Contains code adapted from Espressif DHCP server (tmp/dhcpserver.c/.h), Apache-2.0.
Original source: ESP-IDF DHCP server (dhcpserver.c / dhcpserver.h) Copyright (c) Espressif Systems.
Portions of the original implementation have been adapted and modified for use in the PacketRF project.
The original code is licensed under the Apache License, Version 2.0. In accordance with the license terms, the portions of this file derived from that implementation are also distributed under the Apache License, Version 2.0.
SPDX-License-Identifier: Apache-2.0
DHCP server, wire format implementation used by the PacketRF networking stack.
This implementation is derived from the DHCP server originally provided in ESP-IDF by Espressif Systems. Parts of the original C implementation (dhcpserver.c / dhcpserver.h) have been adapted and refactored for use in the PacketRF firmware.
The derived portions of this code are distributed under the Apache License Version 2.0, in accordance with the license of the original implementation.
Classes
- struct Packet
- struct ParsedMessage
- struct ReplyDestination
- struct ReplySpec
Enums
- enum class MessageType: uint8_t { Invalid = 0u, Discover = 1u, Offer = 2u, Request = 3u, Decline = 4u, Ack = 5u, Nak = 6u, Release = 7u }
- enum class OptionCode: uint8_t { Pad = 0u, SubnetMask = 1u, Router = 3u, DomainNameServer = 6u, HostName = 12u, DomainName = 15u, InterfaceMtu = 26u, BroadcastAddress = 28u, NetworkTimeProtocolServers = 42u, RequestedIpAddress = 50u, IpAddressLeaseTime = 51u, DhcpMessageType = 53u, ServerIdentifier = 54u, ParameterRequestList = 55u, RenewalT1TimeValue = 58u, RebindingT2TimeValue = 59u, ClientIdentifier = 61u, End = 255u }
Functions
- auto broadcast_address(const uint32_t ip, const uint32_t subnet_mask) -> uint32_t
- auto encode_reply(const ReplySpec& spec, std::array<uint8_t, kMaxReplyBytes>*const out, size_t*const out_size) -> bool
- auto encode_reply(const ReplySpec& spec, uint8_t*const out, const size_t capacity, size_t*const out_size) -> bool
- auto parse_message(const std::span<const uint8_t> bytes, ParsedMessage*const out) -> bool
- auto rebinding_t2_s(const uint32_t lease_time_s) -> uint32_t
- auto renewal_t1_s(const uint32_t lease_time_s) -> uint32_t
- void sanitize_hostname(const std::span<const uint8_t> raw, std::array<uint8_t, kMaxHostnameLen>*const out, bool*const out_present)
- auto select_reply_destination(const ParsedMessage& request, const uint32_t reply_yiaddr, const uint32_t fallback_broadcast_ip) -> ReplyDestination
Variables
- uint8_t kBootReply constexpr
- uint8_t kBootRequest constexpr
- uint32_t kBroadcastIpv4 constexpr
- uint16_t kClientPort constexpr
- uint16_t kFlagBroadcast constexpr
- uint8_t kHlenEthernet constexpr
- uint8_t kHtypeEthernet constexpr
- uint32_t kMagicCookie constexpr
- size_t kMaxClientIdentifierLen constexpr
- size_t kMaxHostnameLen constexpr
- size_t kMaxReplyBytes constexpr
- size_t kOptionsCapacity constexpr
- uint16_t kServerPort constexpr
Enum documentation
enum class prf:: net:: dhcps:: wire:: MessageType: uint8_t
#include <net/dhcps/dhcp_wire.hpp>
enum class prf:: net:: dhcps:: wire:: OptionCode: uint8_t
#include <net/dhcps/dhcp_wire.hpp>
Function documentation
uint32_t prf:: net:: dhcps:: wire:: broadcast_address(const uint32_t ip,
const uint32_t subnet_mask)
#include <net/dhcps/dhcp_wire.hpp>
bool prf:: net:: dhcps:: wire:: encode_reply(const ReplySpec& spec,
std::array<uint8_t, kMaxReplyBytes>*const out,
size_t*const out_size)
#include <net/dhcps/dhcp_wire.hpp>
bool prf:: net:: dhcps:: wire:: encode_reply(const ReplySpec& spec,
uint8_t*const out,
const size_t capacity,
size_t*const out_size)
#include <net/dhcps/dhcp_wire.hpp>
bool prf:: net:: dhcps:: wire:: parse_message(const std::span<const uint8_t> bytes,
ParsedMessage*const out)
#include <net/dhcps/dhcp_wire.hpp>
uint32_t prf:: net:: dhcps:: wire:: rebinding_t2_s(const uint32_t lease_time_s)
#include <net/dhcps/dhcp_wire.hpp>
uint32_t prf:: net:: dhcps:: wire:: renewal_t1_s(const uint32_t lease_time_s)
#include <net/dhcps/dhcp_wire.hpp>
void prf:: net:: dhcps:: wire:: sanitize_hostname(const std::span<const uint8_t> raw,
std::array<uint8_t, kMaxHostnameLen>*const out,
bool*const out_present)
#include <net/dhcps/dhcp_wire.hpp>
ReplyDestination prf:: net:: dhcps:: wire:: select_reply_destination(const ParsedMessage& request,
const uint32_t reply_yiaddr,
const uint32_t fallback_broadcast_ip)
#include <net/dhcps/dhcp_wire.hpp>
Variable documentation
uint8_t prf:: net:: dhcps:: wire:: kBootReply constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint8_t prf:: net:: dhcps:: wire:: kBootRequest constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint32_t prf:: net:: dhcps:: wire:: kBroadcastIpv4 constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint16_t prf:: net:: dhcps:: wire:: kClientPort constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint16_t prf:: net:: dhcps:: wire:: kFlagBroadcast constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint8_t prf:: net:: dhcps:: wire:: kHlenEthernet constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint8_t prf:: net:: dhcps:: wire:: kHtypeEthernet constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint32_t prf:: net:: dhcps:: wire:: kMagicCookie constexpr
#include <net/dhcps/dhcp_wire.hpp>
size_t prf:: net:: dhcps:: wire:: kMaxClientIdentifierLen constexpr
#include <net/dhcps/dhcp_wire.hpp>
size_t prf:: net:: dhcps:: wire:: kMaxHostnameLen constexpr
#include <net/dhcps/dhcp_wire.hpp>
size_t prf:: net:: dhcps:: wire:: kMaxReplyBytes constexpr
#include <net/dhcps/dhcp_wire.hpp>
size_t prf:: net:: dhcps:: wire:: kOptionsCapacity constexpr
#include <net/dhcps/dhcp_wire.hpp>
uint16_t prf:: net:: dhcps:: wire:: kServerPort constexpr
#include <net/dhcps/dhcp_wire.hpp>