-/* $OpenBSD: config.c,v 1.52 2020/12/31 08:27:15 martijn Exp $ */
+/* $OpenBSD: config.c,v 1.53 2021/01/19 09:16:20 claudio Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
sin6 = (struct sockaddr_in6 *)&ss;
*sin6 = *(struct sockaddr_in6 *)p->ifa_addr;
sin6->sin6_len = sizeof(struct sockaddr_in6);
+#ifdef __KAME__
+ if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr)) &&
+ sin6->sin6_scope_id == 0) {
+ sin6->sin6_scope_id = ntohs(
+ *(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
+ sin6->sin6_addr.s6_addr[2] = 0;
+ sin6->sin6_addr.s6_addr[3] = 0;
+ }
+#endif
table_add(t, ss_to_text(&ss), NULL);
table_add(localnames, ss_to_text(&ss), NULL);
(void)snprintf(buf, sizeof buf, "[%s]", ss_to_text(&ss));
-/* $OpenBSD: parse.y,v 1.282 2020/12/31 08:27:15 martijn Exp $ */
+/* $OpenBSD: parse.y,v 1.283 2021/01/19 09:16:20 claudio Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
*sin6 = *(struct sockaddr_in6 *)p->ifa_addr;
sin6->sin6_len = sizeof(struct sockaddr_in6);
sin6->sin6_port = lo->port;
+#ifdef __KAME__
+ if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr)) &&
+ sin6->sin6_scope_id == 0) {
+ sin6->sin6_scope_id = ntohs(
+ *(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
+ sin6->sin6_addr.s6_addr[2] = 0;
+ sin6->sin6_addr.s6_addr[3] = 0;
+ }
+#endif
if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
h->local = 1;
break;
-/* $OpenBSD: smtpd.h,v 1.660 2020/12/31 08:27:15 martijn Exp $ */
+/* $OpenBSD: smtpd.h,v 1.661 2021/01/19 09:16:20 claudio Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
const char *time_to_text(time_t);
const char *duration_to_text(time_t);
const char *rule_to_text(struct rule *);
-const char *sockaddr_to_text(struct sockaddr *);
+const char *sockaddr_to_text(const struct sockaddr *);
const char *mailaddr_to_text(const struct mailaddr *);
const char *expandnode_to_text(struct expandnode *);
-/* $OpenBSD: to.c,v 1.44 2019/11/12 20:21:46 gilles Exp $ */
+/* $OpenBSD: to.c,v 1.45 2021/01/19 09:16:20 claudio Exp $ */
/*
* Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
#include "smtpd.h"
#include "log.h"
-static const char *in6addr_to_text(const struct in6_addr *);
static int alias_is_filter(struct expandnode *, const char *, size_t);
static int alias_is_username(struct expandnode *, const char *, size_t);
static int alias_is_address(struct expandnode *, const char *, size_t);
static int alias_is_error(struct expandnode *, const char *, size_t);
const char *
-sockaddr_to_text(struct sockaddr *sa)
+sockaddr_to_text(const struct sockaddr *sa)
{
static char buf[NI_MAXHOST];
return (buf);
}
-static const char *
-in6addr_to_text(const struct in6_addr *addr)
-{
- struct sockaddr_in6 sa_in6;
- uint16_t tmp16;
-
- memset(&sa_in6, 0, sizeof(sa_in6));
- sa_in6.sin6_len = sizeof(sa_in6);
- sa_in6.sin6_family = AF_INET6;
- memcpy(&sa_in6.sin6_addr, addr, sizeof(sa_in6.sin6_addr));
-
- /* XXX thanks, KAME, for this ugliness... adopted from route/show.c */
- if (IN6_IS_ADDR_LINKLOCAL(&sa_in6.sin6_addr) ||
- IN6_IS_ADDR_MC_LINKLOCAL(&sa_in6.sin6_addr)) {
- memcpy(&tmp16, &sa_in6.sin6_addr.s6_addr[2], sizeof(tmp16));
- sa_in6.sin6_scope_id = ntohs(tmp16);
- sa_in6.sin6_addr.s6_addr[2] = 0;
- sa_in6.sin6_addr.s6_addr[3] = 0;
- }
-
- return (sockaddr_to_text((struct sockaddr *)&sa_in6));
-}
-
int
text_to_mailaddr(struct mailaddr *maddr, const char *email)
{
(addr >> 8) & 0xff, addr & 0xff);
}
else if (sa->sa_family == AF_INET6) {
- const struct sockaddr_in6 *in6;
- const struct in6_addr *in6_addr;
-
- in6 = (const struct sockaddr_in6 *)sa;
- p = buf;
- in6_addr = &in6->sin6_addr;
- (void)bsnprintf(p, NI_MAXHOST, "[%s]", in6addr_to_text(in6_addr));
+ (void)bsnprintf(p, NI_MAXHOST, "[%s]", sockaddr_to_text(sa));
}
return (buf);