ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::socket::Ipv4Allow Class Reference

IPv4 peers that may connect. An empty list allows every peer. More...

#include <ipv4_allow.h>

Public Member Functions

void set (const Ipv4AllowEntry *entries, size_t count)
 
bool allows (const struct sockaddr *peer) const
 A v4 mapped IPv6 peer is unwrapped; any other family fails a non empty list.
 
bool allows (uint32_t addr) const
 addr is network byte order, as it sits in a sockaddr_in.
 
bool admit (const struct sockaddr *peer, socklen_t len, const char *tag, uint32_t now)
 allows(peer), logging a refused peer at most once every REJECT_LOG_INTERVAL_MS.
 
void dump_config (const char *tag) const
 One config line per allowed network.
 
size_t size () const
 
Ipv4AllowEntry entry (size_t i) const
 A copy of entry i, read from flash.
 

Protected Attributes

const Ipv4AllowEntry * entries_ {nullptr}
 
size_t count_ {0}
 
uint32_t last_reject_log_ms_ {0}
 

Static Protected Attributes

static constexpr uint32_t REJECT_LOG_INTERVAL_MS = 5000
 

Detailed Description

IPv4 peers that may connect. An empty list allows every peer.

Definition at line 20 of file ipv4_allow.h.

Member Function Documentation

◆ admit()

bool esphome::socket::Ipv4Allow::admit ( const struct sockaddr * peer,
socklen_t len,
const char * tag,
uint32_t now )

allows(peer), logging a refused peer at most once every REJECT_LOG_INTERVAL_MS.

Definition at line 11 of file ipv4_allow.cpp.

◆ allows() [1/2]

bool esphome::socket::Ipv4Allow::allows ( const struct sockaddr * peer) const
inline

A v4 mapped IPv6 peer is unwrapped; any other family fails a non empty list.

Definition at line 28 of file ipv4_allow.h.

◆ allows() [2/2]

bool esphome::socket::Ipv4Allow::allows ( uint32_t addr) const
inline

addr is network byte order, as it sits in a sockaddr_in.

Definition at line 37 of file ipv4_allow.h.

◆ dump_config()

void esphome::socket::Ipv4Allow::dump_config ( const char * tag) const

One config line per allowed network.

Definition at line 24 of file ipv4_allow.cpp.

◆ entry()

Ipv4AllowEntry esphome::socket::Ipv4Allow::entry ( size_t i) const
inline

A copy of entry i, read from flash.

Definition at line 56 of file ipv4_allow.h.

◆ set()

void esphome::socket::Ipv4Allow::set ( const Ipv4AllowEntry * entries,
size_t count )
inline

Definition at line 22 of file ipv4_allow.h.

◆ size()

size_t esphome::socket::Ipv4Allow::size ( ) const
inline

Definition at line 54 of file ipv4_allow.h.

Field Documentation

◆ count_

size_t esphome::socket::Ipv4Allow::count_ {0}
protected

Definition at line 66 of file ipv4_allow.h.

◆ entries_

const Ipv4AllowEntry* esphome::socket::Ipv4Allow::entries_ {nullptr}
protected

Definition at line 65 of file ipv4_allow.h.

◆ last_reject_log_ms_

uint32_t esphome::socket::Ipv4Allow::last_reject_log_ms_ {0}
protected

Definition at line 67 of file ipv4_allow.h.

◆ REJECT_LOG_INTERVAL_MS

uint32_t esphome::socket::Ipv4Allow::REJECT_LOG_INTERVAL_MS = 5000
staticconstexprprotected

Definition at line 63 of file ipv4_allow.h.


The documentation for this class was generated from the following files: