|
unbound 0.1
|
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). | |
| #define | PP2_HEADER_LEN_INET 12 |
| PROXYv2 minimum header.len value for TCP/UDP over IPv4. | |
| #define | PP2_HEADER_LEN_INET6 36 |
| PROXYv2 minimum header.len value for TCP/UDP over IPv6. | |
| #define | PP2_HEADER_LEN_UNIX 216 |
| PROXYv2 minimum header.len value for TCP/UDP over AF_UNIX. | |
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. | |
| const char * | pp_lookup_error (enum pp_parse_errors error) |
| Lookup the parsing error description. | |
| 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. | |
| int | pp2_read_header (uint8_t *buf, size_t buflen) |
| Read a PROXYv2 header from the current position of the buffer. | |
This file contains PROXY protocol structs and functions.
Only v2 is supported. TLVs are not currently supported.
| #define PP2_HEADER_SIZE 16 |
PROXYv2 minimum header size.
Referenced by comm_point_tcp_handle_read(), consume_pp2_header(), pp2_read_header(), pp2_write_to_buf(), and ssl_handle_read().
| #define PP2_SIG "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A" |
PROXYv2 header signature.
Referenced by pp2_read_header(), and pp2_write_to_buf().
| #define PP2_VERSION 0x2 |
PROXYv2 version (protocol value).
Referenced by pp2_read_header(), and pp2_write_to_buf().
| #define PP2_HEADER_LEN_INET 12 |
PROXYv2 minimum header.len value for TCP/UDP over IPv4.
Referenced by consume_pp2_header(), and pp2_read_header().
| #define PP2_HEADER_LEN_INET6 36 |
PROXYv2 minimum header.len value for TCP/UDP over IPv6.
Referenced by consume_pp2_header(), and pp2_read_header().
| void pp_init | ( | void(* | write_uint16 )(void *buf, uint16_t data), |
| void(* | write_uint32 )(void *buf, uint32_t data) ) |
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. |
References pp_init().
Referenced by libworker_setup(), main(), pp_init(), and worker_init().
| const char * pp_lookup_error | ( | enum pp_parse_errors | error | ) |
Lookup the parsing error description.
| error | parsing error from pp2_read_header. |
References pp_lookup_error(), and pp_parse_errors_data.
Referenced by comm_point_tcp_handle_read(), pp_lookup_error(), 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, PP2_SIG, PP2_VERSION, and pp2_write_to_buf().
Referenced by pp2_write_to_buf().
| 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_LEN_INET, PP2_HEADER_LEN_INET6, PP2_HEADER_SIZE, pp2_read_header(), PP2_SIG, and PP2_VERSION.
Referenced by comm_point_tcp_handle_read(), consume_pp2_header(), pp2_read_header(), and ssl_handle_read().