[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.
This commit is contained in:
Willy Tarreau 2007-10-28 12:09:45 +01:00
parent bd578bbe1a
commit 106bf274c4
2 changed files with 4 additions and 0 deletions

View File

@ -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 */

View File

@ -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,