mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-04 18:03:47 +02:00
MINOR: protocol: support a generic way to call getsockopt() on a connection
It's regularly needed to call getsockopt() on a connection, but each time the calling code has to do all the job by itself. This commit adds a "get_opt()" callback on the protocol struct, that directly calls getsockopt() on the connection's FD. A generic implementation for standard sockets is provided, though QUIC would likely require a different approach, or maybe a mapping. Due to the overlap between IP/TCP/socket option values, it is necessary for the caller to indicate both the level and the option. An abstraction of the level could be done, but the caller would nonetheless have to know the optname, which is generally defined in the same include files. So for now we'll consider that this callback is only for very specific use. The levels and optnames are purposely passed as signed ints so that it is possible to further extend the API by using negative levels for internal namespaces.
This commit is contained in:
@@ -160,6 +160,7 @@ struct protocol {
|
||||
/* default I/O handler */
|
||||
void (*default_iocb)(int fd); /* generic I/O handler (typically accept callback) */
|
||||
int (*get_info)(struct connection *conn, long long int *info, int info_num); /* Callback to get connection level statistical counters */
|
||||
int (*get_opt)(const struct connection *conn, int level, int optname, void *buf, int size); /* getsockopt(level:optname) into buf:size */
|
||||
|
||||
uint flags; /* flags describing protocol support (PROTO_F_*) */
|
||||
uint nb_receivers; /* number of receivers (under proto_lock) */
|
||||
|
||||
@@ -46,6 +46,7 @@ struct connection *sock_accept_conn(struct listener *l, int *status);
|
||||
void sock_accept_iocb(int fd);
|
||||
void sock_conn_ctrl_init(struct connection *conn);
|
||||
void sock_conn_ctrl_close(struct connection *conn);
|
||||
int sock_conn_get_opt(const struct connection *conn, int level, int optname, void *buf, int size);
|
||||
void sock_conn_iocb(int fd);
|
||||
int sock_conn_check(struct connection *conn);
|
||||
int sock_drain(struct connection *conn);
|
||||
|
||||
Reference in New Issue
Block a user