Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Sat, 9 Jun 2001 01:34:17 +0000 (01:34 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Sat, 9 Jun 2001 01:34:17 +0000 (01:34 +0000)
Log message:

Implement a mechanism for servers to indicate to the network that they are
hubs, servers, or both.  We take parv[7], an unspecified unsigned int in
previous versions, and turn it into a mode-like string--it's not actually a
mode in the /mode #channel sense, but it looks similar.  This works in
conjunction with two new flags, FLAGS_HUB and FLAGS_SERVICE.  There is
currently no user-visible impact of this change.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@493 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/client.h
ircd/m_server.c
ircd/s_bsd.c
ircd/s_serv.c

index 3ce72349da533f7bacc68e5e3060a2b38ed6ab2e..0cf881c3bdfe7d53428fb9f40ecb476a542aaa3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2001-06-08  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/s_serv.c (server_estab): send a +h flag in our SERVER
+       command if we're configured as a hub; send individual server flags
+       in SERVER commands
+
+       * ircd/s_bsd.c (completed_connection): send a +h flag in our
+       SERVER command if we're configured as a hub
+
+       * ircd/m_server.c: implement parv[7] as a mode-like string; +h
+       sets the FLAGS_HUB flag for a server; +s sets the FLAGS_SERVICE
+       flag for a server; +hs sets both flags; also modify CMD_SERVER
+       format string to send the flags
+
+       * include/client.h: define two new flags, FLAGS_HUB and
+       FLAGS_SERVICE to mark services and hubs as such; define testing
+       macros, setting macros
+
        * ircd/s_user.c: remove deprecated struct Gline* argument to
        register_user(); remove GLINE rebroadcast; do not send GLINE
        acknowledgement parameter to NICK; do not look for GLINE
index 21b8b353008d59f3d7d09a8422bbb0bfbef77ea5..3af00dd27928ca438b813dd3a6ff4bb7ae2bf1ba 100644 (file)
@@ -356,6 +356,8 @@ struct Client {
 #define FLAGS_CLOSING    0x0400 /* set when closing to suppress errors */
 #define FLAGS_UPING      0x0800 /* has active UDP ping request */
 #define FLAGS_CHKACCESS  0x1000 /* ok to check clients access if set */
+#define FLAGS_HUB        0x2000 /* server is a hub */
+#define FLAGS_SERVICE    0x4000 /* server is a service */
 #define FLAGS_LOCAL     0x00010000      /* set for local clients */
 #define FLAGS_GOTID     0x00020000      /* successful ident lookup achieved */
 #define FLAGS_DOID      0x00040000      /* I-lines say must use ident return */
@@ -400,6 +402,8 @@ struct Client {
 #define SendDebug(x)            (cli_flags(x) & FLAGS_DEBUG)
 #define SendServNotice(x)       (cli_flags(x) & FLAGS_SERVNOTICE)
 #define SendWallops(x)          (cli_flags(x) & FLAGS_WALLOP)
+#define IsHub(x)                (cli_flags(x) & FLAGS_HUB)
+#define IsService(x)            (cli_flags(x) & FLAGS_SERVICE)
 
 #define IsPrivileged(x)         (IsAnOper(x) || IsServer(x))
 
@@ -418,6 +422,8 @@ struct Client {
 #define SetUPing(x)             (cli_flags(x) |= FLAGS_UPING)
 #define SetWallops(x)           (cli_flags(x) |= FLAGS_WALLOP)
 #define SetServNotice(x)        (cli_flags(x) |= FLAGS_SERVNOTICE)
+#define SetHub(x)               (cli_flags(x) |= FLAGS_HUB)
+#define SetService(x)           (cli_flags(x) |= FLAGS_SERVICE)
 
 #define ClearAccess(x)          (cli_flags(x) &= ~FLAGS_CHKACCESS)
 #define ClearBurst(x)           (cli_flags(x) &= ~FLAGS_BURST)
index 6743284fcd32ed80d939a77270f5609f7947be30..0ddd244c5da95b8ea3caf072600d80cd601dec2e 100644 (file)
  *  If cptr is P10:
  *    parv[6] = "YMM", where 'Y' is the server numeric and "MM" is the
  *              numeric nick mask of this server.
- *    parv[7] = 0 (not used yet, mandatory unsigned int after u2.10.06)
+ *    parv[7] = +hs (h == hub, s == service)
  */
 int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
@@ -180,6 +180,18 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (!IsServer(cptr))          /* Don't allow silently connecting a server */
     *parv[5] = 'J';
 
+  if (*parv[7] == '+') {
+    for (ch = parv[7] + 1; *ch; ch++)
+      switch (*ch) {
+      case 'h':
+       SetHub(cptr);
+       break;
+      case 's':
+       SetService(cptr);
+       break;
+      }
+  }
+
   prot = atoi(parv[5] + 1);
   if (prot > atoi(MAJOR_PROTOCOL))
     prot = atoi(MAJOR_PROTOCOL);
@@ -680,9 +692,10 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         continue;
       if (0 == match(cli_name(&me), cli_name(acptr)))
         continue;
-      sendcmdto_one(sptr, CMD_SERVER, bcptr, "%s %d 0 %s %s %s%s 0 :%s",
-                   cli_name(acptr), hop + 1, parv[4], parv[5], NumServCap(acptr),
-                   cli_info(acptr));
+      sendcmdto_one(sptr, CMD_SERVER, bcptr, "%s %d 0 %s %s %s%s +%s%s :%s",
+                   cli_name(acptr), hop + 1, parv[4], parv[5],
+                   NumServCap(acptr), IsHub(acptr) ? "h" : "",
+                   IsService(acptr) ? "s" : "", cli_info(acptr));
     }
     return 0;
   }
@@ -765,7 +778,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
  *  If cptr is P10:
  *    parv[6] = "YMM", where 'Y' is the server numeric and "MM" is the
  *              numeric nick mask of this server.
- *    parv[7] = 0 (not used yet, mandatory unsigned int after u2.10.06)
+ *    parv[7] = +hs (h == hub, s == service)
  */
 int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
@@ -809,6 +822,18 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (!IsServer(cptr))          /* Don't allow silently connecting a server */
     *parv[5] = 'J';
 
+  if (*parv[7] == '+') {
+    for (ch = parv[7] + 1; *ch; ch++)
+      switch (*ch) {
+      case 'h':
+       SetHub(cptr);
+       break;
+      case 's':
+       SetService(cptr);
+       break;
+      }
+  }
+
   prot = atoi(parv[5] + 1);
   if (prot > atoi(MAJOR_PROTOCOL))
     prot = atoi(MAJOR_PROTOCOL);
@@ -1300,9 +1325,10 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         continue;
       if (0 == match(cli_name(&me), cli_name(acptr)))
         continue;
-      sendcmdto_one(sptr, CMD_SERVER, bcptr, "%s %d 0 %s %s %s%s 0 :%s",
-                   cli_name(acptr), hop + 1, parv[4], parv[5], NumServCap(acptr),
-                   cli_info(acptr));
+      sendcmdto_one(sptr, CMD_SERVER, bcptr, "%s %d 0 %s %s %s%s +%s%s :%s",
+                   cli_name(acptr), hop + 1, parv[4], parv[5],
+                   NumServCap(acptr), IsHub(acptr) ? "h" : "",
+                   IsService(acptr) ? "s" : "", cli_info(acptr));
     }
     return 0;
   }
index 9d1564830371681a862c2c73625d35f2fead27c8..ed5bc8399de23f8b952bf4670631aeab3aa2ac64 100644 (file)
@@ -460,9 +460,10 @@ static int completed_connection(struct Client* cptr)
   cli_lasttime(cptr) = CurrentTime;
   cli_flags(cptr) |= FLAGS_PINGSENT;
 
-  sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s",
-                cli_name(&me), cli_serv(&me)->timestamp, newts, MAJOR_PROTOCOL, 
-                NumServCap(&me), cli_info(&me));
+  sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s :%s",
+                cli_name(&me), cli_serv(&me)->timestamp, newts,
+               MAJOR_PROTOCOL, NumServCap(&me),
+               feature_bool(FEAT_HUB) ? "h" : "", cli_info(&me));
 
   return (IsDead(cptr)) ? 0 : 1;
 }
index c6eac617c077663ccefa21c3c4534fbc811fe08b..5b8cb84a9cbddb231efabbf12fa3834527881643 100644 (file)
@@ -113,9 +113,11 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf)
     /*
      *  Pass my info to the new server
      */
-    sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s", cli_name(&me),
-                  cli_serv(&me)->timestamp, cli_serv(cptr)->timestamp, MAJOR_PROTOCOL,
-                  NumServCap(&me), *(cli_info(&me)) ? cli_info(&me) : "IRCers United");
+    sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s :%s",
+                 cli_name(&me), cli_serv(&me)->timestamp,
+                 cli_serv(cptr)->timestamp, MAJOR_PROTOCOL, NumServCap(&me),
+                 feature_bool(FEAT_HUB) ? "h" : "",
+                 *(cli_info(&me)) ? cli_info(&me) : "IRCers United");
     /*
      * Don't charge this IP# for connecting
      * XXX - if this comes from a server port, it will not have been added
@@ -176,8 +178,9 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf)
     if (!match(cli_name(&me), cli_name(cptr)))
       continue;
     sendcmdto_one(&me, CMD_SERVER, acptr,
-                 "%s 2 0 %Tu J%02u %s%s 0 :%s", cli_name(cptr),
+                 "%s 2 0 %Tu J%02u %s%s +%s%s :%s", cli_name(cptr),
                  cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr),
+                 IsHub(cptr) ? "h" : "", IsService(cptr) ? "s" : "",
                  cli_info(cptr));
   }
 
@@ -214,9 +217,10 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf)
                0 != ircd_strcmp(cli_name(acptr), cli_sockhost(acptr)) &&
                0 != ircd_strncmp(cli_info(acptr), "JUPE", 4));
       sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr,
-                   "%s %d 0 %Tu %s%u %s%s 0 :%s", cli_name(acptr),
+                   "%s %d 0 %Tu %s%u %s%s +%s%s :%s", cli_name(acptr),
                    cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp,
                    protocol_str, Protocol(acptr), NumServCap(acptr),
+                   IsHub(acptr) ? "h" : "", IsService(acptr) ? "s" : "",
                    cli_info(acptr));
     }
   }