29#include <freeradius-devel/util/pair.h>
30#include <freeradius-devel/util/proto.h>
31#include <freeradius-devel/util/udpfromto.h>
32#include <freeradius-devel/util/syserror.h>
44 struct sockaddr_storage dst;
46 struct sockaddr_storage src;
59 packet->
socket.inet.ifindex,
60 (
struct sockaddr *)&src, sizeof_src,
61 (
struct sockaddr *)&dst, sizeof_dst);
76 struct sockaddr_storage src;
77 struct sockaddr_storage dst;
94 sizeof_src =
sizeof(src);
95 sizeof_dst =
sizeof(dst);
98 (
struct sockaddr *)&src, &sizeof_src,
99 (
struct sockaddr *)&dst, &sizeof_dst, &when);
111 sizeof_dst =
sizeof(dst);
116 if (getsockname(
sockfd, (
struct sockaddr *) &dst, &sizeof_dst) < 0) {
128 if (!packet)
return NULL;
132 talloc_steal(packet,
data);
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Implementation of the DHCPv4 protocol.
fr_packet_t * fr_dhcpv4_packet_alloc(uint8_t const *data, ssize_t data_len)
int fr_ipaddr_from_sockaddr(fr_ipaddr_t *ipaddr, uint16_t *port, struct sockaddr_storage const *sa, socklen_t salen)
Convert sockaddr to our internal ip address representation.
int fr_ipaddr_to_sockaddr(struct sockaddr_storage *sa, socklen_t *salen, fr_ipaddr_t const *ipaddr, uint16_t port)
Convert our internal ip address representation to a sockaddr.
bool fr_dhcpv4_ok(uint8_t const *data, ssize_t data_len, uint8_t *message_type, uint32_t *xid)
Check received DHCP request is valid and build fr_packet_t structure if it is.
int fr_dhcpv4_udp_packet_send(fr_packet_t *packet)
Send DHCP packet using a connectionless UDP socket.
fr_packet_t * fr_dhcpv4_udp_packet_recv(int sockfd)
Receive DHCP packet using a connectionless UDP socket.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
int sendfromto(int fd, void *buf, size_t len, int flags, int ifindex, struct sockaddr *from, socklen_t from_len, struct sockaddr *to, socklen_t to_len)
Send packet via a file descriptor, setting the src address and outbound interface.
int recvfromto(int fd, void *buf, size_t len, int flags, int *ifindex, struct sockaddr *from, socklen_t *from_len, struct sockaddr *to, socklen_t *to_len, fr_time_t *when)
Read a packet from a file descriptor, retrieving additional header information.
fr_socket_t socket
This packet was received on.
uint8_t * data
Packet data (body).
size_t data_len
Length of packet data.
fr_time_t timestamp
When we received the packet.
int fd
File descriptor if this is a live socket.
static fr_socket_t * fr_socket_addr_init_inet(fr_socket_t *addr, int proto, int ifindex, fr_ipaddr_t const *src_ipaddr, int src_port, fr_ipaddr_t const *dst_ipaddr, int dst_port)
Initialise a fr_socket_t for connecting to a remote host using a specific src interface,...
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)