proxy_protocol.c File Reference

This file contains PROXY protocol functions. More...

#include "config.h"
#include "util/log.h"
#include "util/proxy_protocol.h"

Functions

int pp2_write_to_buf (struct sldns_buffer *buf, struct sockaddr_storage *src, int stream)
 Write a PROXYv2 header at the current position of the buffer. More...
 
struct pp2_headerpp2_read_header (struct sldns_buffer *buf)
 Read a PROXYv2 header from the current position of the buffer. More...
 

Detailed Description

This file contains PROXY protocol functions.

Function Documentation

◆ pp2_write_to_buf()

int pp2_write_to_buf ( struct sldns_buffer buf,
struct sockaddr_storage *  src,
int  stream 
)

Write a PROXYv2 header at the current position of the buffer.

Parameters
bufthe buffer to write to.
srcthe source address.
streamif the protocol is stream or datagram.
Returns
1 on success, 0 on failure.

References PP2_HEADER_SIZE, PP2_SIG, sldns_buffer_remaining(), and sldns_buffer_write().

◆ pp2_read_header()

struct pp2_header* pp2_read_header ( struct sldns_buffer buf)

Read a PROXYv2 header from the current position of the buffer.

It does initial validation and returns a pointer to the buffer position on success.

Parameters
bufthe buffer to read from.
Returns
the pointer to the buffer position on success, NULL on error.

References log_err(), PP2_HEADER_SIZE, PP2_SIG, sldns_buffer_begin(), and sldns_buffer_remaining().

Referenced by comm_point_tcp_handle_read(), consume_pp2_header(), and ssl_handle_read().