+struct addrpat {
+ unsigned len;
+ union addr addr;
+};
+
+struct portpat {
+ unsigned lo, hi;
+};
+
+struct sockpat {
+ struct addrpat addr;
+ struct portpat port;
+};
+
+#define ADDRTYPES(_) \
+ _(ipv4, IPV4, INET, "IPv4", 32) \
+ _(ipv6, IPV6, INET6, "IPv6", 128)
+
+struct addrops {
+ int af;
+ const char *name;
+ unsigned len;
+ const union addr *any;
+ const struct addrops_sys *sys;
+ int (*addreq)(const union addr *, const union addr *);
+ int (*match_addrpat)(const struct addrpat *, const union addr *);
+ void (*socket_to_sockaddr)(const struct socket *s, void *, size_t *);
+ void (*sockaddr_to_addr)(const void *, union addr *);
+ int (*init_listen_socket)(int);
+};
+
+enum {
+#define DEFADDR(ty, TY, af, name, len) ADDR_##TY,
+ ADDRTYPES(DEFADDR)
+#undef DEFADDR
+ ADDR_LIMIT
+};
+
+extern const struct addrops addroptab[];
+#define OPS_SYS(ty, TY, af, name, len) \
+ extern const struct addrops_sys addrops_sys_##ty;
+ADDRTYPES(OPS_SYS)
+#undef OPS_SYS
+