From: Willy Tarreau Date: Sun, 28 Oct 2007 11:09:45 +0000 (+0100) Subject: [MINOR] add socket address length to the protocols X-Git-Tag: v1.3.14~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=106bf274c4e6dfea3ea1895a19ebf0a0ab16c771;p=thirdparty%2Fhaproxy.git [MINOR] add socket address length to the protocols The protocol struct can be more useful if it also provides address lengths. Add sock_addrlen, as used by bind(), as well as l3_addrlen for hashes. --- diff --git a/include/types/protocols.h b/include/types/protocols.h index a21f9a4a6c..a2b522239d 100644 --- a/include/types/protocols.h +++ b/include/types/protocols.h @@ -78,6 +78,8 @@ struct protocol { int sock_type; /* socket type, as passed to socket() */ int sock_prot; /* socket protocol, as passed to socket() */ sa_family_t sock_family; /* socket family, for sockaddr */ + socklen_t sock_addrlen; /* socket address length, used by bind() */ + int l3_addrlen; /* layer3 address length, used by hashes */ int (*read)(int fd); /* generic read function */ int (*write)(int fd); /* generic write function */ int (*bind_all)(struct protocol *proto); /* bind all unbound listeners */ diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 307d7ef8e7..1a093263c3 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -1407,6 +1407,8 @@ static struct protocol proto_unix = { .sock_type = SOCK_STREAM, .sock_prot = 0, .sock_family = AF_UNIX, + .sock_addrlen = sizeof(struct sockaddr_un), + .l3_addrlen = sizeof(((struct sockaddr_un*)0)->sun_path),/* path len */ .read = &stream_sock_read, .write = &stream_sock_write, .bind_all = uxst_bind_listeners,