- adjust generic proxy-protocol header for IPv6 support with ifdef.

This commit is contained in:
W.C.A. Wijngaards 2023-04-25 08:16:19 +02:00
parent b5cc8b6c59
commit 542f717bf9
2 changed files with 16 additions and 2 deletions

View file

@ -83,7 +83,12 @@ pp_lookup_error(enum pp_parse_errors error) {
}
size_t
pp2_write_to_buf(uint8_t* buf, size_t buflen, struct sockaddr_storage* src,
pp2_write_to_buf(uint8_t* buf, size_t buflen,
#ifdef INET6
struct sockaddr_storage* src,
#else
struct sockaddr_in* src,
#endif
int stream)
{
int af;
@ -123,6 +128,7 @@ pp2_write_to_buf(uint8_t* buf, size_t buflen, struct sockaddr_storage* src,
/* dst port */
(*pp_data.write_uint16)(buf, 12);
} else {
#ifdef INET6
/* family and protocol */
*buf = (PP2_AF_INET6<<4) |
(stream?PP2_PROT_STREAM:PP2_PROT_DGRAM);
@ -142,6 +148,9 @@ pp2_write_to_buf(uint8_t* buf, size_t buflen, struct sockaddr_storage* src,
buf += 2;
/* dst port */
(*pp_data.write_uint16)(buf, 0);
#else
return 0;
#endif /* INET6 */
}
return expected_size;
}

View file

@ -144,7 +144,12 @@ const char* pp_lookup_error(enum pp_parse_errors error);
* @return 1 on success, 0 on failure.
*/
size_t pp2_write_to_buf(uint8_t* buf, size_t buflen,
struct sockaddr_storage* src, int stream);
#ifdef INET6
struct sockaddr_storage* src,
#else
struct sockaddr_in* src,
#endif
int stream);
/**
* Read a PROXYv2 header from the current position of the buffer.