This file contains PROXY protocol structs and functions. More...
#include "config.h"
Data Structures | |
struct | pp2_header |
PROXYv2 header. More... | |
Macros | |
#define | PP2_HEADER_SIZE 16 |
PROXYv2 minimum header size. | |
#define | PP2_SIG "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A" |
PROXYv2 header signature. | |
#define | PP2_SIG_LEN 12 |
#define | PP2_VERSION 0x2 |
PROXYv2 version (protocol value) | |
Enumerations | |
enum | pp2_command { PP2_CMD_LOCAL = 0x0 , PP2_CMD_PROXY = 0x1 } |
PROXYv2 command (protocol value). | |
enum | pp2_af { PP2_AF_UNSPEC = 0x0 , PP2_AF_INET = 0x1 , PP2_AF_INET6 = 0x2 , PP2_AF_UNIX = 0x3 } |
PROXYv2 address family (protocol value). | |
enum | pp2_protocol { PP2_PROT_UNSPEC = 0x0 , PP2_PROT_STREAM = 0x1 , PP2_PROT_DGRAM = 0x2 } |
PROXYv2 protocol (protocol value). | |
enum | pp2_af_protocol_combination { PP2_UNSPEC_UNSPEC = (PP2_AF_UNSPEC<<4)|PP2_PROT_UNSPEC , PP2_INET_STREAM = (PP2_AF_INET<<4)|PP2_PROT_STREAM , PP2_INET_DGRAM = (PP2_AF_INET<<4)|PP2_PROT_DGRAM , PP2_INET6_STREAM = (PP2_AF_INET6<<4)|PP2_PROT_STREAM , PP2_INET6_DGRAM = (PP2_AF_INET6<<4)|PP2_PROT_DGRAM , PP2_UNIX_STREAM = (PP2_AF_UNIX<<4)|PP2_PROT_STREAM , PP2_UNIX_DGRAM = (PP2_AF_UNIX<<4)|PP2_PROT_DGRAM } |
Expected combinations of address family and protocol values used in checks. | |
enum | pp_parse_errors { PP_PARSE_NOERROR = 0 , PP_PARSE_SIZE , PP_PARSE_WRONG_HEADERv2 , PP_PARSE_UNKNOWN_CMD , PP_PARSE_UNKNOWN_FAM_PROT } |
PROXY parse errors. | |
Functions | |
void | pp_init (void(*write_uint16)(void *buf, uint16_t data), void(*write_uint32)(void *buf, uint32_t data)) |
Initialize the internal proxy structure. More... | |
const char * | pp_lookup_error (enum pp_parse_errors error) |
Lookup the parsing error description. More... | |
size_t | pp2_write_to_buf (uint8_t *buf, size_t buflen, struct sockaddr_in *src, int stream) |
Write a PROXYv2 header at the current position of the buffer. More... | |
int | pp2_read_header (uint8_t *buf, size_t buflen) |
Read a PROXYv2 header from the current position of the buffer. More... | |
This file contains PROXY protocol structs and functions.
Only v2 is supported. TLVs are not currently supported.
void pp_init | ( | void(*)(void *buf, uint16_t data) | write_uint16, |
void(*)(void *buf, uint32_t data) | write_uint32 | ||
) |
Initialize the internal proxy structure.
write_uint16 | pointer to a function that can write uint16. |
write_uint32 | pointer to a function that can write uint32. |
Referenced by main().
const char* pp_lookup_error | ( | enum pp_parse_errors | error | ) |
Lookup the parsing error description.
error | parsing error from pp2_read_header. |
References error(), and pp_parse_errors_data.
Referenced by comm_point_tcp_handle_read(), and ssl_handle_read().
size_t pp2_write_to_buf | ( | uint8_t * | buf, |
size_t | buflen, | ||
struct sockaddr_in * | src, | ||
int | stream | ||
) |
Write a PROXYv2 header at the current position of the buffer.
buf | pointer to the buffer to write data to. |
buflen | available size on the buffer. |
src | the source address. |
stream | if the protocol is stream or datagram. |
References PP2_HEADER_SIZE, and PP2_SIG.
int pp2_read_header | ( | uint8_t * | buf, |
size_t | buflen | ||
) |
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.
buf | pointer to the buffer data to read from. |
buflen | available size on the buffer. |
References PP2_HEADER_SIZE.
Referenced by comm_point_tcp_handle_read(), consume_pp2_header(), and ssl_handle_read().