]> jfr.im git - solanum.git/commitdiff
ipv4_from_ipv6: move to librb
authorElizabeth Myers <redacted>
Fri, 8 Apr 2016 08:49:23 +0000 (03:49 -0500)
committerElizabeth Myers <redacted>
Fri, 8 Apr 2016 08:49:23 +0000 (03:49 -0500)
extensions/extb_hostmask.c
include/ipv4_from_ipv6.h [deleted file]
ircd/Makefile.am
ircd/channel.c
ircd/hostmask.c
ircd/ipv4_from_ipv6.c [deleted file]
librb/include/rb_commio.h
librb/src/commio.c
librb/src/export-syms.txt
modules/m_whois.c

index 9bffe26b821500902b74ba45a15820344b144534..9aa964de46bfdec89b92fe262e74e5164a45356e 100644 (file)
@@ -7,7 +7,6 @@
 #include "modules.h"
 #include "client.h"
 #include "ircd.h"
-#include "ipv4_from_ipv6.h"
 
 static const char extb_desc[] = "Hostmask ($m) extban type";
 
@@ -56,7 +55,7 @@ eb_hostmask(const char *banstr, struct Client *client_p, struct Channel *chptr,
 
 #ifdef RB_IPV6
        /* handle Teredo if necessary */
-       if (GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET6 && ipv4_from_ipv6((const struct sockaddr_in6 *) &client_p->localClient->ip, &ip4))
+       if (GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET6 && rb_ipv4_from_ipv6((const struct sockaddr_in6 *) &client_p->localClient->ip, &ip4))
        {
                sprintf(src_ip4host, "%s!%s@", client_p->name, client_p->username);
                s4 = src_ip4host + strlen(src_ip4host);
diff --git a/include/ipv4_from_ipv6.h b/include/ipv4_from_ipv6.h
deleted file mode 100644 (file)
index 1bfbe65..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * charybdis: An advanced ircd.
- * ipv4_from_ipv6.h: Finds IPv4 addresses behind IPv6 transition technologies
- *
- * Copyright (C) 2012 Jilles Tjoelker
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _IPV4_FROM_IPV6_H_
-#define _IPV4_FROM_IPV6_H_
-
-#ifdef RB_IPV6
-int ipv4_from_ipv6(const struct sockaddr_in6 *restrict ip6,
-               struct sockaddr_in *restrict ip4);
-#endif
-
-#endif
index e1bd46d1b769703e66d6b6b0bd33c14ba1454009..d4b1e31b7f24c6980b428f2c283cc88d0160c4b4 100644 (file)
@@ -33,7 +33,6 @@ libircd_la_SOURCES =                  \
   hash.c                        \
   hook.c                        \
   hostmask.c                    \
-  ipv4_from_ipv6.c             \
   ircd.c                        \
   ircd_parser.y                 \
   ircd_lexer.l                  \
index 4609325ab3266a60dd4c905e101608a00b281359..340525eac6dee5ed0faa7365fa71f252f33bc701 100644 (file)
@@ -38,7 +38,6 @@
 #include "s_conf.h"            /* ConfigFileEntry, ConfigChannel */
 #include "s_newconf.h"
 #include "logger.h"
-#include "ipv4_from_ipv6.h"
 #include "s_assert.h"
 
 struct config_channel_entry ConfigChannel;
@@ -581,7 +580,7 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list,
        }
 #ifdef RB_IPV6
        if(GET_SS_FAMILY(&who->localClient->ip) == AF_INET6 &&
-                       ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4))
+                       rb_ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4))
        {
                sprintf(src_ip4host, "%s!%s@", who->name, who->username);
                s4 = src_ip4host + strlen(src_ip4host);
index 49f357cad338b6bce16b55c91c79a5b19dccb5b6..059c07c774f2fc963d9b3d13a8cf31493e564850 100644 (file)
@@ -30,7 +30,6 @@
 #include "numeric.h"
 #include "send.h"
 #include "match.h"
-#include "ipv4_from_ipv6.h"
 
 #ifdef RB_IPV6
 static unsigned long hash_ipv6(struct sockaddr *, int);
@@ -425,7 +424,7 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
 
 #ifdef RB_IPV6
        if(ip != NULL && ip->sa_family == AF_INET6 &&
-                       ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)ip, &ip4))
+                       rb_ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)ip, &ip4))
        {
                kconf = find_conf_by_address(NULL, NULL, NULL, (struct sockaddr *)&ip4, CONF_KILL, AF_INET, vuser, NULL);
                if(kconf)
@@ -457,7 +456,7 @@ find_dline(struct sockaddr *addr, int aftype)
                return aconf;
 #ifdef RB_IPV6
        if(addr->sa_family == AF_INET6 &&
-                       ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)addr, &addr2))
+                       rb_ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)addr, &addr2))
        {
                aconf = find_conf_by_address(NULL, NULL, NULL, (struct sockaddr *)&addr2, CONF_DLINE | 1, AF_INET, NULL, NULL);
                if(aconf)
diff --git a/ircd/ipv4_from_ipv6.c b/ircd/ipv4_from_ipv6.c
deleted file mode 100644 (file)
index b2dee9b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * charybdis: A slightly useful ircd.
- * ipv4_from_ipv6.c: Finds IPv4 addresses behind IPv6 transition technologies
- *
- * Copyright (C) 2012 Jilles Tjoelker
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "stdinc.h"
-#include "ipv4_from_ipv6.h"
-
-#ifdef RB_IPV6
-int
-ipv4_from_ipv6(const struct sockaddr_in6 *restrict ip6,
-               struct sockaddr_in *restrict ip4)
-{
-       int i;
-
-       if (!memcmp(ip6->sin6_addr.s6_addr, "\x20\x02", 2))
-       {
-               /* 6to4 and similar */
-               memcpy(&ip4->sin_addr, ip6->sin6_addr.s6_addr + 2, 4);
-       }
-       else if (!memcmp(ip6->sin6_addr.s6_addr, "\x20\x01\x00\x00", 4))
-       {
-               /* Teredo */
-               for (i = 0; i < 4; i++)
-                       ((uint8_t *)&ip4->sin_addr)[i] = 0xFF ^
-                               ip6->sin6_addr.s6_addr[12 + i];
-       }
-       else
-               return 0;
-       SET_SS_LEN(ip4, sizeof(struct sockaddr_in));
-       ip4->sin_family = AF_INET;
-       ip4->sin_port = 0;
-       return 1;
-}
-#endif /* RB_IPV6 */
index f51e04b1728ec721f304f3b977d84d00df687207..7123a9812ab1abf939977597d2afc8d97937f212 100644 (file)
@@ -181,10 +181,11 @@ int rb_supports_ssl(void);
 unsigned int rb_ssl_handshake_count(rb_fde_t *F);
 void rb_ssl_clear_handshake_count(rb_fde_t *F);
 
-
 int rb_pass_fd_to_process(rb_fde_t *, pid_t, rb_fde_t *);
 rb_fde_t *rb_recv_fd(rb_fde_t *);
 
 const char *rb_ssl_get_cipher(rb_fde_t *F);
 
+int rb_ipv4_from_ipv6(const struct sockaddr_in6 *restrict ip6, struct sockaddr_in *restrict ip4);
+
 #endif /* INCLUDED_commio_h */
index 259b900d90ef523476b12218e79f4bf98b87e353..fde467c83213471869328b26235f8f258419208b 100644 (file)
@@ -2095,7 +2095,6 @@ rb_setup_fd(rb_fde_t *F)
 }
 
 
-
 int
 rb_ignore_errno(int error)
 {
@@ -2242,7 +2241,7 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
        }
        return sendmsg(rb_get_fd(xF), &msg, MSG_NOSIGNAL);
 }
-#else
+#else /* defined(HAVE_SENDMSG) && !defined(WIN32) */
 #ifndef _WIN32
 int
 rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
@@ -2257,5 +2256,38 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
        errno = ENOSYS;
        return -1;
 }
-#endif
-#endif
+#endif /* _WIN32 */
+#endif /* defined(HAVE_SENDMSG) && !defined(WIN32) */
+
+#ifdef RB_IPV6
+int
+rb_ipv4_from_ipv6(const struct sockaddr_in6 *restrict ip6, struct sockaddr_in *restrict ip4)
+{
+       int i;
+
+       if (!memcmp(ip6->sin6_addr.s6_addr, "\x20\x02", 2))
+       {
+               /* 6to4 and similar */
+               memcpy(&ip4->sin_addr, ip6->sin6_addr.s6_addr + 2, 4);
+       }
+       else if (!memcmp(ip6->sin6_addr.s6_addr, "\x20\x01\x00\x00", 4))
+       {
+               /* Teredo */
+               for (i = 0; i < 4; i++)
+                       ((uint8_t *)&ip4->sin_addr)[i] = 0xFF ^
+                               ip6->sin6_addr.s6_addr[12 + i];
+       }
+       else
+               return 0;
+       SET_SS_LEN(ip4, sizeof(struct sockaddr_in));
+       ip4->sin_family = AF_INET;
+       ip4->sin_port = 0;
+       return 1;
+}
+#else
+int
+rb_ipv4_from_ipv6(const struct sockaddr_in6 *restrict ip6, struct sockaddr_in *restrict ip4)
+{
+       return 0;
+}
+#endif /* RB_IPV6 */
index 21c6b035d1bd9e8908acf22410b1668940078354..bd804eb1092982269ad14090b3a1823e98f17dbc 100644 (file)
@@ -84,6 +84,7 @@ rb_init_patricia
 rb_init_prng
 rb_init_rawbuffers
 rb_init_rb_dlink_nodes
+rb_ipv4_from_ipv6
 rb_kill
 rb_lib_die
 rb_lib_init
index 5f7b42d134fee751196c9e46eceb8feb023226b7..a43b9109dc8022c81f5591edefa34a3feef0ba44 100644 (file)
@@ -40,7 +40,6 @@
 #include "modules.h"
 #include "hook.h"
 #include "s_newconf.h"
-#include "ipv4_from_ipv6.h"
 #include "ratelimit.h"
 #include "s_assert.h"
 
@@ -369,7 +368,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                if (GET_SS_FAMILY(&target_p->localClient->ip) == AF_INET6 &&
                                (show_ip(source_p, target_p) ||
                                 (source_p == target_p && !IsIPSpoof(target_p))) &&
-                               ipv4_from_ipv6((struct sockaddr_in6 *)&target_p->localClient->ip, &ip4))
+                               rb_ipv4_from_ipv6((struct sockaddr_in6 *)&target_p->localClient->ip, &ip4))
                {
                        rb_inet_ntop_sock((struct sockaddr *)&ip4,
                                        buf, sizeof buf);