added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / m_pong.c
index 95a411ee2e74fd63ad5126a2f177bdbd83badb13..df29b9f6714ace850041b1f669e08094c62e2226 100644 (file)
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
+#include "config.h"
+
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
 #include "numeric.h"
 #include "numnicks.h"
+#include "opercmds.h"
+#include "s_auth.h"
 #include "s_user.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 #include <stdlib.h>
 
 /*
- * ms_pong - server message handler template
+ * ms_pong - server message handler
  *
  * parv[0] = sender prefix
  * parv[1] = origin
@@ -118,25 +115,37 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   assert(IsServer(cptr));
 
   if (parc < 2 || EmptyString(parv[1])) {
-#if 0
-    /*
-     * ignore there is nothing the server sending it can do about it
-     */
-    sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); /* XXX DEAD */
-#endif
-    return 0;
+    return protocol_violation(sptr,"No Origin on PONG");
   }
   origin      = parv[1];
   destination = parv[2];
-  cptr->flags &= ~FLAGS_PINGSENT;
-  sptr->flags &= ~FLAGS_PINGSENT;
-  cptr->lasttime = CurrentTime;
+  ClearPingSent(cptr);
+  ClearPingSent(sptr);
+  cli_lasttime(cptr) = CurrentTime;
 
-  if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name)) {
+  if (parc > 5)
+  {
+    /* AsLL pong */
+    cli_serv(cptr)->asll_rtt = atoi(militime_float(parv[3]));
+    cli_serv(cptr)->asll_to = atoi(parv[4]);
+    cli_serv(cptr)->asll_from = atoi(militime_float(parv[5]));
+    cli_serv(cptr)->asll_last = CurrentTime;
+    return 0;
+  }
+  
+  if (EmptyString(destination))
+    return 0;
+  
+  if (*destination == '!')
+  {
+    /* AsLL ping reply from a non-AsLL server */
+    cli_serv(cptr)->asll_rtt = atoi(militime_float(destination + 1));
+  }
+  else if (0 != ircd_strcmp(destination, cli_name(&me)))
+  {
     struct Client* acptr;
-    if ((acptr = FindClient(destination))) {
+    if ((acptr = FindClient(destination)))
       sendcmdto_one(sptr, CMD_PONG, acptr, "%s %s", origin, destination);
-    }
   }
   return 0;
 }
@@ -154,26 +163,8 @@ int mr_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   assert(cptr == sptr);
   assert(!IsRegistered(sptr));
 
-  cptr->flags &= ~FLAGS_PINGSENT;
-  cptr->lasttime = CurrentTime;
-  /*
-   * Check to see if this is a PONG :cookie reply from an
-   * unregistered user.  If so, process it. -record
-   */
-  if (0 != sptr->cookie && COOKIE_VERIFIED != sptr->cookie) {
-    if (parc > 1 && sptr->cookie == atol(parv[parc - 1])) {
-      sptr->cookie = COOKIE_VERIFIED;
-      if (sptr->user && *sptr->user->host && sptr->name[0])
-        /*
-         * NICK and USER OK
-         */
-        return register_user(cptr, sptr, sptr->name, sptr->user->username);
-    }
-    else  
-      send_reply(sptr, SND_EXPLICIT | ERR_BADPING,
-                ":To connect, type /QUOTE PONG %u", sptr->cookie);
-  }
-  return 0;
+  ClearPingSent(cptr);
+  return (parc > 1) ? auth_set_pong(cli_auth(sptr), strtoul(parv[parc - 1], NULL, 10)) : 0;
 }
 
 /*
@@ -187,75 +178,8 @@ int m_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   assert(0 != cptr);
   assert(cptr == sptr);
-  cptr->flags &= ~FLAGS_PINGSENT;
-  cptr->lasttime = CurrentTime;
-  return 0;
-}
-
-
-#if 0
-/*
- * m_pong
- *
- * parv[0] = sender prefix
- * parv[1] = origin
- * parv[2] = destination
- */
-int m_pong(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
-  struct Client *acptr;
-  char *origin, *destination;
-
-  if (MyUser(sptr))
-    return 0;
 
-  /* Check to see if this is a PONG :cookie reply from an
-   * unregistered user.  If so, process it. -record       */
-
-  if ((!IsRegistered(sptr)) && (sptr->cookie != 0) &&
-      (sptr->cookie != COOKIE_VERIFIED) && (parc > 1))
-  {
-    if (atol(parv[parc - 1]) == (long)sptr->cookie)
-    {
-      sptr->cookie = COOKIE_VERIFIED;
-      if (sptr->user && *sptr->user->host && sptr->name[0])        /* NICK and
-                                                                   USER OK */
-        return register_user(cptr, sptr, sptr->name, sptr->user->username);
-    }
-    else
-      sendto_one(sptr, ":%s %d %s :To connect, type /QUOTE PONG %u", /* XXX DEAD */
-          me.name, ERR_BADPING, sptr->name, sptr->cookie);
-
-    return 0;
-  }
-
-  if (parc < 2 || *parv[1] == '\0')
-  {
-    sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); /* XXX DEAD */
-    return 0;
-  }
-
-  origin = parv[1];
-  destination = parv[2];
-  cptr->flags &= ~FLAGS_PINGSENT;
-  sptr->flags &= ~FLAGS_PINGSENT;
-
-  if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name))
-  {
-    if ((acptr = FindClient(destination)))
-      sendto_one(acptr, ":%s PONG %s %s", parv[0], origin, destination); /* XXX DEAD */
-    else
-    {
-      sendto_one(sptr, err_str(ERR_NOSUCHSERVER), /* XXX DEAD */
-          me.name, parv[0], destination);
-      return 0;
-    }
-  }
-#ifdef        DEBUGMODE
-  else
-    Debug((DEBUG_NOTICE, "PONG: %s %s",
-        origin, destination ? destination : "*"));
-#endif
+  ClearPingSent(cptr);
+  cli_lasttime(cptr) = CurrentTime;
   return 0;
 }
-#endif /* 0 */