Add CIDR ban support.
[ircu2.10.12-pk.git] / include / channel.h
index 0895b7fa0b08f23015fe3abea665be98621ba571..980e2d87b0915e2321f8086bae678acd4c807cdd 100644 (file)
@@ -30,6 +30,9 @@
 #include <sys/types.h>
 #define INCLUDED_sys_types_h
 #endif
+#ifndef INCLUDED_res_h
+#include "res.h"
+#endif
 
 struct SLink;
 struct Client;
@@ -60,12 +63,7 @@ struct Client;
 #define CHFL_DEOPPED            0x0004  /**< Is de-opped by a server */
 #define CHFL_SERVOPOK           0x0008  /**< Server op allowed */
 #define CHFL_ZOMBIE             0x0010  /**< Kicked from channel */
-#define CHFL_BAN                0x0020  /**< ban channel flag */
-#define CHFL_BAN_IPMASK         0x0040  /**< ban mask is an IP-number mask */
-#define CHFL_BAN_OVERLAPPED     0x0080  /**< ban overlapped, need bounce */
 #define CHFL_BURST_JOINED       0x0100  /**< Just joined by net.junction */
-#define CHFL_BURST_BAN          0x0200  /**< Ban part of last BURST */
-#define CHFL_BURST_BAN_WIPEOUT  0x0400  /**< Ban will be wiped at EOB */
 #define CHFL_BANVALID           0x0800  /**< CHFL_BANNED bit is valid */
 #define CHFL_BANNED             0x1000  /**< Channel member is banned */
 #define CHFL_SILENCE_IPMASK     0x2000  /**< silence mask is a CIDR */
@@ -254,6 +252,25 @@ struct Mode {
   char apass[PASSLEN + 1];
 };
 
+#define BAN_IPMASK         0x0001  /**< ban mask is an IP-number mask */
+#define BAN_OVERLAPPED     0x0002  /**< ban overlapped, need bounce */
+#define BAN_BURSTED        0x0004  /**< Ban part of last BURST */
+#define BAN_BURST_WIPEOUT  0x0008  /**< Ban will be wiped at EOB */
+#define BAN_DEL            0x4000  /**< Ban is being removed */
+#define BAN_ADD            0x8000  /**< Ban is being added */
+
+/** A single ban for a channel. */
+struct Ban {
+  struct Ban* next;   /**< next ban in the channel */
+  struct irc_in_addr address; /**< addres for BAN_IPMASK bans */
+  time_t when;        /**< timestamp when ban was added */
+  unsigned short flags; /**< modifier flags for the ban */
+  unsigned char nu_len; /**< length of nick!user part of banstr */
+  unsigned char addrbits; /**< netmask length for BAN_IPMASK bans */
+  char *who;          /**< name of client that set the ban */
+  char *banstr;       /**< hostmask that the ban matches */
+};
+
 /** Information about a channel */
 struct Channel {
   struct Channel*    next;     /**< next channel in the global channel list */
@@ -265,7 +282,7 @@ struct Channel {
   unsigned int       users;       /**< Number of clients on this channel */
   struct Membership* members;     /**< Pointer to the clients on this channel*/
   struct SLink*      invites;     /**< List of invites on this channel */
-  struct SLink*      banlist;     /**< List of bans on this channel */
+  struct Ban*        banlist;      /**< List of bans on this channel */
   struct Mode        mode;        /**< This channels mode */
   char               topic[TOPICLEN + 1]; /**< Channels topic */
   char               topic_nick[NICKLEN + 1]; /**< Nick of the person who set
@@ -374,7 +391,7 @@ extern void add_token_to_sendbuf(char *token, size_t *sblenp, int *firstp,
                                  int *send_itp, char is_a_ban, int mode);
 extern int add_banid(struct Client *cptr, struct Channel *chptr, char *banid,
                      int change, int firsttime);
-extern struct SLink *next_removed_overlapped_ban(void);
+extern struct Ban *next_removed_overlapped_ban(void);
 extern void cancel_mode(struct Client *sptr, struct Channel *chptr, char m,
                         const char *param, int *count);
 extern void make_zombie(struct Membership* member, struct Client* who,
@@ -446,5 +463,7 @@ extern void joinbuf_init(struct JoinBuf *jbuf, struct Client *source,
 extern void joinbuf_join(struct JoinBuf *jbuf, struct Channel *chan,
                         unsigned int flags);
 extern int joinbuf_flush(struct JoinBuf *jbuf);
+extern struct Ban *make_ban(const char *banstr);
+extern void free_ban(struct Ban *ban);
 
 #endif /* INCLUDED_channel_h */