unbound: util/proxy_protocol.c File Reference

unbound 0.1

Functions
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.
struct pp2_header * | pp2_read_header (struct sldns_buffer *buf)
| Read a PROXYv2 header from the current position of the buffer.

## 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

  buf | the buffer to write to.
  src | the source address.
  stream | if the protocol is stream or datagram.

Returns
  1 on success, 0 on failure.

References PP2_HEADER_SIZE, PP2_SIG, PP2_VERSION, sldns_buffer_position(), sldns_buffer_remaining(), sldns_buffer_set_at(), sldns_buffer_skip(), sldns_buffer_write(), sldns_buffer_write_u16(), sldns_buffer_write_u32(), and sldns_buffer_write_u8().

## ◆ 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

  buf | the buffer to read from.

Returns
  the pointer to the buffer position on success, NULL on error.

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

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