diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-12-22 17:45:48 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-12-22 17:45:48 +0000 |
commit | 18e48f50a5aa3148be5ecd5b307a6940eb8b1caa (patch) | |
tree | f661a7f4e3a057f3c6a976ae48136f3fd832fd89 /usr.sbin | |
parent | 0a2afbf3f435f13ee6abcd97b223594a26361f1b (diff) |
Implement log_in6addr_scope() yet another function doing the same thing
again but different because of link local addressing.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospf6d/log.c | 21 | ||||
-rw-r--r-- | usr.sbin/ospf6d/log.h | 3 |
2 files changed, 22 insertions, 2 deletions
diff --git a/usr.sbin/ospf6d/log.c b/usr.sbin/ospf6d/log.c index 15f19b8606a..1eab0730003 100644 --- a/usr.sbin/ospf6d/log.c +++ b/usr.sbin/ospf6d/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.5 2009/11/02 20:24:58 claudio Exp $ */ +/* $OpenBSD: log.c,v 1.6 2009/12/22 17:45:47 claudio Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -200,6 +200,25 @@ log_in6addr(const struct in6_addr *addr) return (log_sockaddr(&sa_in6)); } +const char * +log_in6addr_scope(const struct in6_addr *addr, unsigned int ifindex) +{ + struct sockaddr_in6 sa_in6; + + bzero(&sa_in6, 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, IPv6 & KAME, for this ugliness... */ + if (IN6_IS_ADDR_LINKLOCAL(&sa_in6.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&sa_in6.sin6_addr)) { + sa_in6.sin6_scope_id = ifindex; + } + + return (log_sockaddr(&sa_in6)); +} + #define NUM_LOGS 4 const char * log_rtr_id(u_int32_t id) diff --git a/usr.sbin/ospf6d/log.h b/usr.sbin/ospf6d/log.h index 456b0aec324..92c2d67e719 100644 --- a/usr.sbin/ospf6d/log.h +++ b/usr.sbin/ospf6d/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.4 2009/11/02 20:24:58 claudio Exp $ */ +/* $OpenBSD: log.h,v 1.5 2009/12/22 17:45:47 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -32,6 +32,7 @@ void fatal(const char *) __dead; void fatalx(const char *) __dead; const char *log_in6addr(const struct in6_addr *); +const char *log_in6addr_scope(const struct in6_addr *, unsigned int); const char *log_rtr_id(u_int32_t); const char *log_sockaddr(void *); |