summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Longeau <chl@cvs.openbsd.org>2009-12-05 18:42:32 +0000
committerCharles Longeau <chl@cvs.openbsd.org>2009-12-05 18:42:32 +0000
commitcfc14f5f1103ac3ce67e347bc8e67db42e4de312 (patch)
tree575b2d07885ef5e6f7ff422fd7367c8ecce15699
parentfba0dda9739506c2fe86cf73de13545e12196b36 (diff)
fix interface tagging listeners in the ipv6 case
while there factor some common code (from jacekm input) ok jacekm@
-rw-r--r--usr.sbin/smtpd/parse.y48
1 files changed, 17 insertions, 31 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index d845c8792e0..afc97f13f43 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.47 2009/11/12 12:35:03 jacekm Exp $ */
+/* $OpenBSD: parse.y,v 1.48 2009/12/05 18:42:31 chl Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -1695,53 +1695,39 @@ interface(const char *s, const char *tag, const char *cert,
if (strcmp(s, p->ifa_name) != 0)
continue;
+ if ((h = calloc(1, sizeof(*h))) == NULL)
+ fatal(NULL);
+
switch (p->ifa_addr->sa_family) {
case AF_INET:
- if ((h = calloc(1, sizeof(*h))) == NULL)
- fatal(NULL);
sain = (struct sockaddr_in *)&h->ss;
*sain = *(struct sockaddr_in *)p->ifa_addr;
sain->sin_len = sizeof(struct sockaddr_in);
sain->sin_port = port;
- h->fd = -1;
- h->port = port;
- h->flags = flags;
- h->ssl = NULL;
- h->ssl_cert_name[0] = '\0';
- if (cert != NULL)
- (void)strlcpy(h->ssl_cert_name, cert, sizeof(h->ssl_cert_name));
- if (tag != NULL)
- (void)strlcpy(h->tag, tag, sizeof(h->tag));
- if (tag != NULL)
- (void)strlcpy(h->tag, tag, sizeof(h->tag));
-
- ret = 1;
- TAILQ_INSERT_HEAD(al, h, entry);
-
break;
case AF_INET6:
- if ((h = calloc(1, sizeof(*h))) == NULL)
- fatal(NULL);
sin6 = (struct sockaddr_in6 *)&h->ss;
*sin6 = *(struct sockaddr_in6 *)p->ifa_addr;
sin6->sin6_len = sizeof(struct sockaddr_in6);
sin6->sin6_port = port;
- h->fd = -1;
- h->port = port;
- h->flags = flags;
- h->ssl = NULL;
- h->ssl_cert_name[0] = '\0';
- if (cert != NULL)
- (void)strlcpy(h->ssl_cert_name, cert, sizeof(h->ssl_cert_name));
-
- ret = 1;
- TAILQ_INSERT_HEAD(al, h, entry);
-
break;
}
+
+ h->fd = -1;
+ h->port = port;
+ h->flags = flags;
+ h->ssl = NULL;
+ h->ssl_cert_name[0] = '\0';
+ if (cert != NULL)
+ (void)strlcpy(h->ssl_cert_name, cert, sizeof(h->ssl_cert_name));
+ if (tag != NULL)
+ (void)strlcpy(h->tag, tag, sizeof(h->tag));
+
+ ret = 1;
+ TAILQ_INSERT_HEAD(al, h, entry);
}
freeifaddrs(ifap);