chiark
/
gitweb
/
~mdw
/
yaid
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Makefile.am: Include `confsubst' machinery.
[yaid]
/
addr.c
diff --git
a/addr.c
b/addr.c
index 25211dfdfe0a014a3e58232f425e5fb4bc28c32a..bfbbabf4aef7e42b41d7570d3a1a706c068f3b86 100644
(file)
--- a/
addr.c
+++ b/
addr.c
@@
-30,6
+30,10
@@
/*----- IPv4 addresses ----------------------------------------------------*/
/*----- IPv4 addresses ----------------------------------------------------*/
+#define ADDRFAM_IPV4 AF_INET
+#define NAME_IPV4 "IPv4"
+#define ADDRLEN_IPV4 32
+
static int addreq_ipv4(const union addr *a, const union addr *b)
{ return a->ipv4.s_addr == b->ipv4.s_addr; }
static int addreq_ipv4(const union addr *a, const union addr *b)
{ return a->ipv4.s_addr == b->ipv4.s_addr; }
@@
-62,6
+66,10
@@
static const union addr any_ipv4 = { .ipv4.s_addr = INADDR_ANY };
/*----- IPv6 addresses ----------------------------------------------------*/
/*----- IPv6 addresses ----------------------------------------------------*/
+#define ADDRFAM_IPV6 AF_INET6
+#define NAME_IPV6 "IPv6"
+#define ADDRLEN_IPV6 128
+
static int addreq_ipv6(const union addr *a, const union addr *b)
{ return !memcmp(a->ipv6.s6_addr, b->ipv6.s6_addr, 16); }
static int addreq_ipv6(const union addr *a, const union addr *b)
{ return !memcmp(a->ipv6.s6_addr, b->ipv6.s6_addr, 16); }
@@
-106,10
+114,12
@@
static const union addr any_ipv6 = { .ipv6 = IN6ADDR_ANY_INIT };
/*----- General utilities -------------------------------------------------*/
/*----- General utilities -------------------------------------------------*/
+/* Answer whether the sockets SA and SB are equal. */
int sockeq(const struct addrops *ao,
const struct socket *sa, const struct socket *sb)
{ return (ao->addreq(&sa->addr, &sb->addr) && sa->port == sb->port); }
int sockeq(const struct addrops *ao,
const struct socket *sa, const struct socket *sb)
{ return (ao->addreq(&sa->addr, &sb->addr) && sa->port == sb->port); }
+/* Write a textual description of S to the string D. */
void dputsock(dstr *d, const struct addrops *ao, const struct socket *s)
{
char buf[ADDRLEN];
void dputsock(dstr *d, const struct addrops *ao, const struct socket *s)
{
char buf[ADDRLEN];
@@
-123,8
+133,9
@@
void dputsock(dstr *d, const struct addrops *ao, const struct socket *s)
/*----- The operations table ----------------------------------------------*/
const struct addrops addroptab[] = {
/*----- The operations table ----------------------------------------------*/
const struct addrops addroptab[] = {
-#define DEFOPS(ty, TY, af, name, len) \
- { AF_##af, name, len, &any_##ty, &addrops_sys_##ty, \
+#define DEFOPS(ty, TY) \
+ { ADDRFAM_##TY, NAME_##TY, ADDRLEN_##TY, \
+ &any_##ty, &addrops_sys_##ty, \
addreq_##ty, match_addrpat_##ty, \
socket_to_sockaddr_##ty, sockaddr_to_addr_##ty, \
init_listen_socket_##ty },
addreq_##ty, match_addrpat_##ty, \
socket_to_sockaddr_##ty, sockaddr_to_addr_##ty, \
init_listen_socket_##ty },