]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/hostmask.c
More TS6 special cases simplified.
[irc/rqf/shadowircd.git] / src / hostmask.c
index d00aeb7c48e7f2a76e54e486a725923e2ae79925..e322e861cc9870fc4b90b86ee18d37027c9456b7 100644 (file)
 #include "hostmask.h"
 #include "numeric.h"
 #include "send.h"
-#include "irc_string.h"
+#include "match.h"
 
-#ifdef IPV6
+#ifdef RB_IPV6
 static unsigned long hash_ipv6(struct sockaddr *, int);
 #endif
 static unsigned long hash_ipv4(struct sockaddr *, int);
 
 
-/* int parse_netmask(const char *, struct irc_sockaddr_storage *, int *);
+/* int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
  * Input: A hostmask, or an IPV4/6 address.
  * Output: An integer describing whether it is an IPV4, IPV6 address or a
  *         hostmask, an address(if it is an IP mask),
@@ -51,7 +51,7 @@ parse_netmask(const char *text, struct sockaddr  *naddr, int *nb)
 {
        char *ip = LOCAL_COPY(text);
        char *ptr;
-       struct irc_sockaddr_storage *addr, xaddr;
+       struct rb_sockaddr_storage *addr, xaddr;
        int *b, xb;
        if(nb == NULL)
                b = &xb;
@@ -59,11 +59,11 @@ parse_netmask(const char *text, struct sockaddr  *naddr, int *nb)
                b = nb;
        
        if(naddr == NULL)
-               addr = (struct irc_sockaddr_storage *)&xaddr;
+               addr = (struct rb_sockaddr_storage *)&xaddr;
        else
-               addr = (struct irc_sockaddr_storage *)naddr;
+               addr = (struct rb_sockaddr_storage *)naddr;
        
-#ifdef IPV6
+#ifdef RB_IPV6
        if(strchr(ip, ':'))
        {       
                if((ptr = strchr(ip, '/')))
@@ -75,7 +75,7 @@ parse_netmask(const char *text, struct sockaddr  *naddr, int *nb)
                                *b = 128;
                } else
                        *b = 128;
-               if(inetpton_sock(ip, (struct sockaddr *)addr) > 0)
+               if(rb_inet_pton_sock(ip, (struct sockaddr *)addr) > 0)
                        return HM_IPV6;
                else
                        return HM_HOST;
@@ -92,7 +92,7 @@ parse_netmask(const char *text, struct sockaddr  *naddr, int *nb)
                                *b = 32;
                } else
                        *b = 32;
-               if(inetpton_sock(ip, (struct sockaddr *)addr) > 0)
+               if(rb_inet_pton_sock(ip, (struct sockaddr *)addr) > 0)
                        return HM_IPV4;
                else
                        return HM_HOST;
@@ -109,7 +109,7 @@ init_host_hash(void)
        memset(&atable, 0, sizeof(atable));
 }
 
-/* unsigned long hash_ipv4(struct irc_sockaddr_storage*)
+/* unsigned long hash_ipv4(struct rb_sockaddr_storage*)
  * Input: An IP address.
  * Output: A hash value of the IP address.
  * Side effects: None
@@ -128,12 +128,12 @@ hash_ipv4(struct sockaddr *saddr, int bits)
        return 0;
 }
 
-/* unsigned long hash_ipv6(struct irc_sockaddr_storage*)
+/* unsigned long hash_ipv6(struct rb_sockaddr_storage*)
  * Input: An IP address.
  * Output: A hash value of the IP address.
  * Side effects: None
  */
-#ifdef IPV6
+#ifdef RB_IPV6
 static unsigned long
 hash_ipv6(struct sockaddr *saddr, int bits)
 {
@@ -196,7 +196,7 @@ get_mask_hash(const char *text)
        return hash_text(text);
 }
 
-/* struct ConfItem* find_conf_by_address(const char*, struct irc_sockaddr_storage*,
+/* struct ConfItem* find_conf_by_address(const char*, struct rb_sockaddr_storage*,
  *         int type, int fam, const char *username)
  * Input: The hostname, the address, the type of mask to find, the address
  *        family, the username.
@@ -221,7 +221,7 @@ find_conf_by_address(const char *name, const char *sockhost,
        if(addr)
        {
                /* Check for IPV6 matches... */
-#ifdef IPV6
+#ifdef RB_IPV6
                if(fam == AF_INET6)
                {
 
@@ -343,7 +343,7 @@ find_conf_by_address(const char *name, const char *sockhost,
 }
 
 /* struct ConfItem* find_address_conf(const char*, const char*,
- *                                    struct irc_sockaddr_storage*, int);
+ *                                    struct rb_sockaddr_storage*, int);
  * Input: The hostname, username, address, address family.
  * Output: The applicable ConfItem.
  * Side-effects: None
@@ -404,19 +404,10 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
                        return kconf;
        }
 
-       /* hunt for a gline */
-       if(ConfigFileEntry.glines)
-       {
-               kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_GLINE, aftype, user);
-
-               if((kconf != NULL) && !IsConfExemptGline(iconf))
-                       return kconf;
-       }
-
        return iconf;
 }
 
-/* struct ConfItem* find_dline(struct irc_sockaddr_storage*, int)
+/* struct ConfItem* find_dline(struct rb_sockaddr_storage*, int)
  * Input: An address, an address family.
  * Output: The best matching D-line or exempt line.
  * Side effects: None.
@@ -442,13 +433,13 @@ find_exact_conf_by_address(const char *address, int type, const char *username)
        int masktype, bits;
        unsigned long hv;
        struct AddressRec *arec;
-       struct irc_sockaddr_storage addr;
+       struct rb_sockaddr_storage addr;
 
        if(address == NULL)
                address = "/NOMATCH!/";
        arec = rb_malloc(sizeof(struct AddressRec));
        masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
-#ifdef IPV6
+#ifdef RB_IPV6
        if(masktype == HM_IPV6)
        {
                /* We have to do this, since we do not re-hash for every bit -A1kmm. */
@@ -507,7 +498,7 @@ add_conf_by_address(const char *address, int type, const char *username, struct
        masktype = parse_netmask(address, (struct sockaddr *)&arec->Mask.ipa.addr, &bits);
        arec->Mask.ipa.bits = bits;
        arec->masktype = masktype;
-#ifdef IPV6
+#ifdef RB_IPV6
        if(masktype == HM_IPV6)
        {
                /* We have to do this, since we do not re-hash for every bit -A1kmm. */
@@ -548,9 +539,9 @@ delete_one_address_conf(const char *address, struct ConfItem *aconf)
        int masktype, bits;
        unsigned long hv;
        struct AddressRec *arec, *arecl = NULL;
-       struct irc_sockaddr_storage addr;
+       struct rb_sockaddr_storage addr;
        masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
-#ifdef IPV6
+#ifdef RB_IPV6
        if(masktype == HM_IPV6)
        {
                /* We have to do this, since we do not re-hash for every bit -A1kmm. */
@@ -683,8 +674,6 @@ show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name)
                *prefix_ptr++ = '=';
        if(IsOper(sptr) && IsConfExemptFlood(aconf))
                *prefix_ptr++ = '|';
-       if(IsOper(sptr) && IsConfExemptGline(aconf) && !IsConfExemptKline(aconf))
-               *prefix_ptr++ = '_';
        if(IsOper(sptr) && IsConfExemptDNSBL(aconf) && !IsConfExemptKline(aconf))
                *prefix_ptr++ = '$';
        if(IsOper(sptr) && IsConfExemptKline(aconf))