mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 06:41:32 +02:00
MINOR: connection: add conn_get_src() and conn_get_dst()
These functions currently are the same as conn_get_from_addr() and conn_get_to_addr() respectively except that they return a status for the operation that the caller can test.
This commit is contained in:
parent
03627245c6
commit
2e34c11458
@ -661,6 +661,46 @@ static inline void conn_get_to_addr(struct connection *conn)
|
|||||||
conn->flags |= CO_FL_ADDR_TO_SET;
|
conn->flags |= CO_FL_ADDR_TO_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieves the connection's original source address. Returns non-zero on
|
||||||
|
* success or zero on failure. The operation is only performed once and the
|
||||||
|
* address is stored in the connection for future use.
|
||||||
|
*/
|
||||||
|
static inline int conn_get_src(struct connection *conn)
|
||||||
|
{
|
||||||
|
if (conn->flags & CO_FL_ADDR_FROM_SET)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!conn_ctrl_ready(conn) || !conn->ctrl->get_src)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (conn->ctrl->get_src(conn->handle.fd, (struct sockaddr *)&conn->addr.from,
|
||||||
|
sizeof(conn->addr.from),
|
||||||
|
obj_type(conn->target) != OBJ_TYPE_LISTENER) == -1)
|
||||||
|
return 0;
|
||||||
|
conn->flags |= CO_FL_ADDR_FROM_SET;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Retrieves the connection's original destination address. Returns non-zero on
|
||||||
|
* success or zero on failure. The operation is only performed once and the
|
||||||
|
* address is stored in the connection for future use.
|
||||||
|
*/
|
||||||
|
static inline int conn_get_dst(struct connection *conn)
|
||||||
|
{
|
||||||
|
if (conn->flags & CO_FL_ADDR_TO_SET)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!conn_ctrl_ready(conn) || !conn->ctrl->get_dst)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (conn->ctrl->get_dst(conn->handle.fd, (struct sockaddr *)&conn->addr.to,
|
||||||
|
sizeof(conn->addr.to),
|
||||||
|
obj_type(conn->target) != OBJ_TYPE_LISTENER) == -1)
|
||||||
|
return 0;
|
||||||
|
conn->flags |= CO_FL_ADDR_TO_SET;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Sets the TOS header in IPv4 and the traffic class header in IPv6 packets
|
/* Sets the TOS header in IPv4 and the traffic class header in IPv6 packets
|
||||||
* (as per RFC3260 #4 and BCP37 #4.2 and #5.2). The connection is tested and if
|
* (as per RFC3260 #4 and BCP37 #4.2 and #5.2). The connection is tested and if
|
||||||
* it is null, nothing is done.
|
* it is null, nothing is done.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user