#
# ChangeLog for ircu2.10.10
#
-# $Id: ChangeLog.10,v 1.4 2000-03-24 10:14:20 bleep Exp $
+# $Id: ChangeLog.10,v 1.5 2000-03-27 03:33:25 bleep Exp $
#
# Insert new changes at beginning of the change list.
#
+* Hookup UPING code again, cleanups --Bleep
+* Convert numerics back to mask and shift extended numerics
+ follow same mechanism --Bleep
* Fixed bogus errno return on Solaris --Bleep
* Fixed core on RPING bug, tokenized RPING --Bleep
* Remove add_local_domain entirely, unused --Bleep
extern int mo_squit(struct Client*, struct Client*, int, char*[]);
extern int mo_stats(struct Client*, struct Client*, int, char*[]);
extern int mo_trace(struct Client*, struct Client*, int, char*[]);
+extern int mo_uping(struct Client*, struct Client*, int, char*[]);
extern int mo_wallops(struct Client*, struct Client*, int, char*[]);
extern int mr_error(struct Client*, struct Client*, int, char*[]);
extern int mr_pong(struct Client*, struct Client*, int, char*[]);
extern int ms_stats(struct Client*, struct Client*, int, char*[]);
extern int ms_topic(struct Client*, struct Client*, int, char*[]);
extern int ms_trace(struct Client*, struct Client*, int, char*[]);
+extern int ms_uping(struct Client*, struct Client*, int, char*[]);
extern int ms_version(struct Client*, struct Client*, int, char*[]);
extern int ms_wallchops(struct Client*, struct Client*, int, char*[]);
extern int ms_wallops(struct Client*, struct Client*, int, char*[]);
#define MSG_BURST "BURST" /* BURS */
#define TOK_BURST "B"
+#define MSG_UPING "UPING" /* UPIN */
+#define TOK_UPING "UP"
+
#define MSG_CREATE "CREATE" /* CREA */
#define TOK_CREATE "C"
#define RELEASE ".11.alpha."
-
/* Do NOT edit those: */
#ifndef BASE_VERSION
extern struct Client* LocalClientArray[MAXCONNECTIONS];
extern int OpenFileDescriptorCount;
-#ifdef VIRTUAL_HOST
-extern struct sockaddr_in vserv;
-#endif
+extern struct sockaddr_in VirtualHost;
enum PollType {
PT_NONE,
#endif
struct Client;
+struct ConfItem;
struct UPing
{
char buf[BUFSIZE]; /* buffer to hold ping times */
};
+extern int UPingFileDescriptor;
-/*=============================================================================
- * Proto types
- */
-
-extern int setup_ping(void);
-extern void polludp(int fd);
-extern void send_ping(struct UPing* pptr);
-extern void read_ping(struct UPing* pptr);
-extern int m_uping(struct Client *cptr, struct Client *sptr, int parc, char* parv[]);
-extern void end_ping(struct UPing* pptr);
-extern void cancel_ping(struct Client *sptr, struct Client *acptr);
-extern struct UPing* pings_begin(void);
+extern int uping_init(void);
+extern void uping_send(struct UPing* pptr);
+extern void uping_read(struct UPing* pptr);
+extern void uping_end(struct UPing* pptr);
+extern void uping_cancel(struct Client *sptr, struct Client *acptr);
+extern void uping_echo(void);
+extern struct UPing* uping_begin(void);
+extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count);
-#ifdef DEBUG
-extern void uping_mark_blocks(void);
-#endif
#endif /* INCLUDED_uping_h */
m_time.c \
m_topic.c \
m_trace.c \
+ m_uping.c \
m_user.c \
m_userhost.c \
m_userip.c \
../include/client.h ../include/dbuf.h ../include/ircd_handler.h \
../include/crule.h ../include/hash.h ../include/ircd_alloc.h \
../include/fda.h ../include/ircd_log.h ../include/ircd_signal.h \
- ../include/ircd_string.h ../include/ircd_chattr.h ../include/list.h \
- ../include/listener.h ../include/match.h ../include/numeric.h \
- ../include/numnicks.h ../include/parse.h ../include/res.h \
- ../include/s_auth.h ../include/s_bsd.h ../include/s_conf.h \
- ../include/s_debug.h ../include/s_misc.h ../include/send.h \
- ../include/sys.h ../include/userload.h ../include/version.h \
- ../include/whowas.h ../include/msg.h
+ ../include/ircd_string.h ../include/ircd_chattr.h ../include/jupe.h \
+ ../include/list.h ../include/listener.h ../include/match.h \
+ ../include/numeric.h ../include/numnicks.h ../include/parse.h \
+ ../include/res.h ../include/s_auth.h ../include/s_bsd.h \
+ ../include/s_conf.h ../include/s_debug.h ../include/s_misc.h \
+ ../include/send.h ../include/sys.h ../include/uping.h \
+ ../include/userload.h ../include/version.h ../include/whowas.h \
+ ../include/msg.h
ircd_alloc.o: ircd_alloc.c ../include/ircd_alloc.h ../include/fda.h \
../include/ircd_string.h ../config/config.h ../config/setup.h \
../include/ircd_chattr.h ../include/s_debug.h ../include/ircd_defs.h
../include/ircd_defs.h ../include/ircd_handler.h ../include/hash.h \
../include/ircd.h ../config/config.h ../config/setup.h \
../include/struct.h ../include/ircd_reply.h ../include/ircd_string.h \
- ../include/ircd_chattr.h ../include/numeric.h ../include/numnicks.h \
- ../include/opercmds.h ../include/send.h
+ ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \
+ ../include/numnicks.h ../include/opercmds.h ../include/send.h
m_server.o: m_server.c ../include/client.h ../include/dbuf.h \
../include/ircd_defs.h ../include/ircd_handler.h ../include/crule.h \
../include/hash.h ../include/ircd.h ../config/config.h \
../include/msg.h ../include/numeric.h ../include/numnicks.h \
../include/s_bsd.h ../include/s_conf.h ../include/s_user.h \
../include/send.h ../include/version.h
+m_uping.o: m_uping.c ../include/client.h ../include/dbuf.h \
+ ../include/ircd_defs.h ../include/ircd_handler.h ../include/hash.h \
+ ../include/ircd.h ../config/config.h ../config/setup.h \
+ ../include/struct.h ../include/ircd_reply.h ../include/ircd_string.h \
+ ../include/ircd_chattr.h ../include/match.h ../include/msg.h \
+ ../include/numeric.h ../include/numnicks.h ../include/s_conf.h \
+ ../include/s_user.h ../include/send.h ../include/uping.h
m_user.o: m_user.c ../include/client.h ../include/dbuf.h \
../include/ircd_defs.h ../include/ircd_handler.h ../include/ircd.h \
../config/config.h ../config/setup.h ../include/struct.h \
../include/s_auth.h ../include/s_conf.h ../include/s_debug.h \
../include/s_misc.h ../include/s_user.h ../include/send.h \
../include/sprintf_irc.h ../include/support.h ../include/sys.h \
- ../include/version.h
+ ../include/uping.h ../include/version.h
s_conf.o: s_conf.c ../include/s_conf.h ../include/IPcheck.h \
../include/class.h ../include/client.h ../include/dbuf.h \
../include/ircd_defs.h ../include/ircd_handler.h ../include/crule.h \
../include/parse.h ../include/querycmds.h ../include/res.h \
../include/s_bsd.h ../include/s_conf.h ../include/s_debug.h \
../include/s_user.h ../include/send.h ../include/sprintf_irc.h \
- ../include/support.h ../include/sys.h ../include/userload.h
+ ../include/support.h ../include/sys.h ../include/uping.h \
+ ../include/userload.h
s_numeric.o: s_numeric.c ../include/s_numeric.h ../include/channel.h \
../config/config.h ../config/setup.h ../include/ircd_defs.h \
../include/client.h ../include/dbuf.h ../include/ircd_handler.h \
../include/struct.h ../include/ircd_alloc.h ../include/fda.h \
../include/ircd_log.h ../include/ircd_osdep.h \
../include/ircd_string.h ../include/ircd_chattr.h ../include/match.h \
- ../include/numeric.h ../include/numnicks.h ../include/res.h \
+ ../include/msg.h ../include/numeric.h ../include/numnicks.h \
../include/s_bsd.h ../include/s_conf.h ../include/s_debug.h \
../include/s_misc.h ../include/s_user.h ../include/send.h \
../include/sys.h
#include "send.h"
#include "struct.h"
#include "sys.h"
+#include "uping.h"
#include "userload.h"
#include "version.h"
#include "whowas.h"
Debug((DEBUG_FATAL, "Failed to initialize server identity"));
exit(2);
}
+ uping_init();
read_tlines();
rmotd = read_motd(RPATH);
motd = read_motd(MPATH);
--- /dev/null
+/*
+ * IRC - Internet Relay Chat, ircd/m_uping.c
+ * Copyright (C) 1990 Jarkko Oikarinen and
+ * University of Oulu, Computing Center
+ *
+ * See file AUTHORS in IRC package for additional names of
+ * the programmers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ */
+
+/*
+ * m_functions execute protocol messages on this server:
+ *
+ * cptr is always NON-NULL, pointing to a *LOCAL* client
+ * structure (with an open socket connected!). This
+ * identifies the physical socket where the message
+ * originated (or which caused the m_function to be
+ * executed--some m_functions may call others...).
+ *
+ * sptr is the source of the message, defined by the
+ * prefix part of the message if present. If not
+ * or prefix not found, then sptr==cptr.
+ *
+ * (!IsServer(cptr)) => (cptr == sptr), because
+ * prefixes are taken *only* from servers...
+ *
+ * (IsServer(cptr))
+ * (sptr == cptr) => the message didn't
+ * have the prefix.
+ *
+ * (sptr != cptr && IsServer(sptr) means
+ * the prefix specified servername. (?)
+ *
+ * (sptr != cptr && !IsServer(sptr) means
+ * that message originated from a remote
+ * user (not local).
+ *
+ * combining
+ *
+ * (!IsServer(sptr)) means that, sptr can safely
+ * taken as defining the target structure of the
+ * message in this server.
+ *
+ * *Always* true (if 'parse' and others are working correct):
+ *
+ * 1) sptr->from == cptr (note: cptr->from == cptr)
+ *
+ * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
+ * *cannot* be a local connection, unless it's
+ * actually cptr!). [MyConnect(x) should probably
+ * be defined as (x == x->from) --msa ]
+ *
+ * parc number of variable parameter strings (if zero,
+ * parv is allowed to be NULL)
+ *
+ * parv a NULL terminated list of parameter pointers,
+ *
+ * parv[0], sender (prefix string), if not present
+ * this points to an empty string.
+ * parv[1]...parv[parc-1]
+ * pointers to additional parameters
+ * parv[parc] == NULL, *always*
+ *
+ * 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 "client.h"
+#include "hash.h"
+#include "ircd.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "match.h"
+#include "msg.h"
+#include "numeric.h"
+#include "numnicks.h"
+#include "s_conf.h"
+#include "s_user.h"
+#include "send.h"
+#include "uping.h"
+
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * ms_uping - server message handler
+ *
+ * m_uping -- by Run
+ *
+ * parv[0] = sender prefix
+ * parv[1] = pinged server
+ * parv[2] = port
+ * parv[3] = hunted server
+ * parv[4] = number of requested pings
+ */
+int ms_uping(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+ struct ConfItem *aconf;
+ int port;
+ int count;
+
+ assert(0 != cptr);
+ assert(0 != sptr);
+
+ if (!IsAnOper(sptr)) {
+ sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
+ return 0;
+ }
+
+ if (parc < 5) {
+ sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "UPING");
+ return 0;
+ }
+
+ if (hunt_server(1, cptr, sptr, "%s%s " TOK_UPING " %s %s %s %s", 3, parc, parv) != HUNTED_ISME)
+ return 0;
+ /*
+ * Determine port: First user supplied, then default : 7007
+ */
+ if (EmptyString(parv[2]) || (port = atoi(parv[2])) <= 0)
+ port = atoi(UDP_PORT);
+
+ if (EmptyString(parv[4]) || (count = atoi(parv[4])) <= 0)
+ {
+ if (MyUser(sptr))
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Illegal number of packets: %s",
+ me.name, parv[0], parv[4]);
+ else
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Illegal number of packets: %s",
+ NumServ(&me), NumNick(sptr), parv[4]);
+ return 0;
+ }
+ /*
+ * Check if a CONNECT would be possible at all (adapted from m_connect)
+ */
+ if ((aconf = conf_find_server(parv[1])))
+ uping_server(sptr, aconf, port, count);
+ else {
+ if (MyUser(sptr))
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Host %s not listed in ircd.conf",
+ me.name, parv[0], parv[1]);
+ else
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Host %s not listed in ircd.conf",
+ NumServ(&me), NumNick(sptr), parv[1]);
+ }
+ return 0;
+}
+
+/*
+ * mo_uping - oper message handler
+ *
+ * m_uping -- by Run
+ *
+ * parv[0] = sender prefix
+ * parv[1] = pinged server
+ * parv[2] = port
+ * parv[3] = hunted server
+ * parv[4] = number of requested pings
+ */
+int mo_uping(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+ struct ConfItem *aconf;
+ int port;
+ int count;
+
+ assert(0 != cptr);
+ assert(0 != sptr);
+ assert(cptr == sptr);
+
+ assert(IsAnOper(sptr));
+
+ if (parc < 2) {
+ sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "UPING");
+ return 0;
+ }
+
+ if (parc == 2) {
+ parv[parc++] = UDP_PORT;
+ parv[parc++] = me.name;
+ parv[parc++] = "5";
+ }
+ else if (parc == 3) {
+ if (IsDigit(*parv[2]))
+ parv[parc++] = me.name;
+ else {
+ parv[parc++] = parv[2];
+ parv[2] = UDP_PORT;
+ }
+ parv[parc++] = "5";
+ }
+ else if (parc == 4) {
+ if (IsDigit(*parv[2])) {
+ if (IsDigit(*parv[3])) {
+ parv[parc++] = parv[3];
+ parv[3] = me.name;
+ }
+ else
+ parv[parc++] = "5";
+ }
+ else {
+ parv[parc++] = parv[3];
+ parv[3] = parv[2];
+ parv[2] = UDP_PORT;
+ }
+ }
+ if (hunt_server(1, cptr, sptr, "%s%s " TOK_UPING " %s %s %s %s", 3, parc, parv) != HUNTED_ISME)
+ return 0;
+ /*
+ * Determine port: First user supplied, then default : 7007
+ */
+ if (EmptyString(parv[2]) || (port = atoi(parv[2])) <= 0)
+ port = atoi(UDP_PORT);
+
+ if (EmptyString(parv[4]) || (count = atoi(parv[4])) <= 0)
+ {
+ if (MyUser(sptr))
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Illegal number of packets: %s",
+ me.name, parv[0], parv[4]);
+ else
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Illegal number of packets: %s",
+ NumServ(&me), NumNick(sptr), parv[4]);
+ return 0;
+ }
+ /*
+ * Check if a CONNECT would be possible at all (adapted from m_connect)
+ */
+ if ((aconf = conf_find_server(parv[1])))
+ uping_server(sptr, aconf, port, count);
+ else {
+ if (MyUser(sptr))
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Host %s not listed in ircd.conf",
+ me.name, parv[0], parv[1]);
+ else
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Host %s not listed in ircd.conf",
+ NumServ(&me), NumNick(sptr), parv[1]);
+ }
+ return 0;
+}
+
+
+#if 0
+/*
+ * m_uping -- by Run
+ *
+ * parv[0] = sender prefix
+ * parv[1] = pinged server
+ * parv[2] = port
+ * parv[3] = hunted server
+ * parv[4] = number of requested pings
+ */
+int m_uping(struct Client* cptr, struct Client *sptr, int parc, char *parv[])
+{
+ struct ConfItem *aconf;
+ int port;
+ int fd;
+ struct UPing* pptr = 0;
+
+ if (!IsPrivileged(sptr))
+ {
+ sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
+ return -1;
+ }
+
+ if (parc < 2)
+ {
+ sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "UPING");
+ return 0;
+ }
+
+ if (MyUser(sptr))
+ {
+ if (parc == 2)
+ {
+ parv[parc++] = UDP_PORT;
+ parv[parc++] = me.name;
+ parv[parc++] = "5";
+ }
+ else if (parc == 3)
+ {
+ if (IsDigit(*parv[2]))
+ parv[parc++] = me.name;
+ else
+ {
+ parv[parc++] = parv[2];
+ parv[2] = UDP_PORT;
+ }
+ parv[parc++] = "5";
+ }
+ else if (parc == 4)
+ {
+ if (IsDigit(*parv[2]))
+ {
+ if (IsDigit(*parv[3]))
+ {
+ parv[parc++] = parv[3];
+ parv[3] = me.name;
+ }
+ else
+ parv[parc++] = "5";
+ }
+ else
+ {
+ parv[parc++] = parv[3];
+ parv[3] = parv[2];
+ parv[2] = UDP_PORT;
+ }
+ }
+ }
+ if (hunt_server(1, cptr, sptr, ":%s UPING %s %s %s %s", 3, parc, parv) != HUNTED_ISME)
+ return 0;
+
+ if (BadPtr(parv[4]) || atoi(parv[4]) <= 0)
+ {
+ if (MyUser(sptr) || Protocol(cptr) < 10)
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Illegal number of packets: %s",
+ me.name, parv[0], parv[4]);
+ else
+ sendto_one(sptr, "%s NOTICE %s%s :UPING: Illegal number of packets: %s",
+ NumServ(&me), NumNick(sptr), parv[4]);
+ return 0;
+ }
+
+ /* Check if a CONNECT would be possible at all (adapted from m_connect) */
+ for (aconf = GlobalConfList; aconf; aconf = aconf->next)
+ {
+ if (aconf->status == CONF_SERVER &&
+ match(parv[1], aconf->name) == 0)
+ break;
+ }
+ if (!aconf)
+ {
+ for (aconf = GlobalConfList; aconf; aconf = aconf->next)
+ {
+ if (aconf->status == CONF_SERVER &&
+ (match(parv[1], aconf->host) == 0 ||
+ match(parv[1], strchr(aconf->host, '@') + 1) == 0))
+ break;
+ }
+ }
+ if (!aconf)
+ {
+ if (MyUser(sptr) || Protocol(cptr) < 10)
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Host %s not listed in ircd.conf",
+ me.name, parv[0], parv[1]);
+ else
+ sendto_one(sptr,
+ "%s NOTICE %s%s :UPING: Host %s not listed in ircd.conf",
+ NumServ(&me), NumNick(sptr), parv[1]);
+ return 0;
+ }
+
+ if (IsUPing(sptr))
+ cancel_ping(sptr, sptr); /* Cancel previous ping request */
+
+ /*
+ * Determine port: First user supplied, then default : 7007
+ */
+ if (BadPtr(parv[2]) || (port = atoi(parv[2])) <= 0)
+ port = atoi(UDP_PORT);
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
+ int err = errno;
+ sendto_ops("m_uping: socket: %s", (err != EMFILE)
+ ? ((strerror(err)) ? strerror(err) : "Unknown error") : "No more sockets");
+ if (MyUser(sptr) || Protocol(cptr) < 10)
+ sendto_one(sptr,
+ ":%s NOTICE %s :UPING: Unable to create udp ping socket",
+ me.name, parv[0]);
+ else
+ sendto_one(sptr,
+ "%s NOTICE %s%s :UPING: Unable to create udp ping socket",
+ NumServ(&me), NumNick(sptr));
+ ircd_log(L_ERROR, "UPING: Unable to create UDP socket");
+ return 0;
+ }
+
+ if (!os_set_nonblocking(fd)) {
+ if (MyUser(sptr) || Protocol(cptr) < 10)
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Can't set fd non-blocking",
+ me.name, parv[0]);
+ else
+ sendto_one(sptr, "%s NOTICE %s%s :UPING: Can't set fd non-blocking",
+ NumServ(&me), NumNick(sptr));
+ close(fd);
+ return 0;
+ }
+ pptr = (struct UPing*) MyMalloc(sizeof(struct UPing));
+ assert(0 != pptr);
+ memset(pptr, 0, sizeof(struct UPing));
+
+ pptr->fd = fd;
+ pptr->sin.sin_port = htons(port);
+ pptr->sin.sin_addr.s_addr = aconf->ipnum.s_addr;
+ pptr->sin.sin_family = AF_INET;
+ pptr->count = IRCD_MIN(20, atoi(parv[4]));
+ strcpy(pptr->name, aconf->host);
+ pptr->client = sptr;
+ pptr->index = -1;
+
+ pptr->next = pingList;
+ pingList = pptr;
+
+ SetUPing(sptr);
+ ping_server(pptr);
+ return 0;
+}
+#endif /* 0 */
+
/* UNREG, CLIENT, SERVER, OPER, SERVICE */
{ m_unregistered, m_jupe, ms_jupe, mo_jupe, m_ignore }
},
+ {
+ MSG_UPING,
+ TOK_UPING,
+ 0, MAXPARA, MFLG_SLOW, 0,
+ /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+ { m_unregistered, m_not_oper, ms_uping, mo_uping, m_ignore }
+ },
{
MSG_END_OF_BURST,
TOK_END_OF_BURST,
#include "struct.h"
#include "support.h"
#include "sys.h"
+#include "uping.h"
#include "version.h"
#include <arpa/inet.h>
#include <sys/poll.h>
#endif /* USE_POLL */
-#ifndef IN_LOOPBACKNET
-#define IN_LOOPBACKNET 0x7f
-#endif
-
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
struct Client* LocalClientArray[MAXCONNECTIONS];
int HighestFd = -1;
-static struct sockaddr_in virtualHost;
+struct sockaddr_in VirtualHost;
static char readbuf[SERVER_TCP_WINDOW];
static int running_in_background;
const char* const SETBUFS_ERROR_MSG = "error setting buffer size for %s: %s";
const char* const SOCKET_ERROR_MSG = "error creating socket for %s: %s";
-#ifdef VIRTUAL_HOST
-struct sockaddr_in vserv;
-#endif
#ifdef GODMODE
#ifndef NODNS
* explicitly bind it, it will default to IN_ADDR_ANY and we lose
* due to the other server not allowing our base IP --smg
*/
- if (bind(cptr->fd, (struct sockaddr*) &virtualHost, sizeof(virtualHost))) {
+ if (bind(cptr->fd, (struct sockaddr*) &VirtualHost, sizeof(VirtualHost))) {
report_error(BIND_ERROR_MSG, cptr->name, errno);
return 0;
}
int read_message(time_t delay)
{
struct pollfd poll_fds[MAXCONNECTIONS + 1];
- struct Client* cptr;
- struct Listener* listener = 0;
- struct AuthRequest* auth = 0;
- struct AuthRequest* auth_next = 0;
- int nfds;
+ struct Client* cptr;
+ struct Listener* listener = 0;
+ struct AuthRequest* auth = 0;
+ struct AuthRequest* auth_next = 0;
+ struct UPing* uping = 0;
+ struct UPing* uping_next = 0;
time_t delay2 = delay;
+ int nfds;
int length;
int i;
int res = 0;
- int pfd_count = 0;
- struct pollfd* pfd = 0;
- struct pollfd* res_pfd = 0;
+ int pfd_count;
+ struct pollfd* pfd;
+ struct pollfd* res_pfd;
+ struct pollfd* uping_pfd;
int read_ready;
int write_ready;
pfd_count = 0;
pfd = poll_fds;
res_pfd = 0;
+ uping_pfd = 0;
pfd->fd = -1;
if (-1 < ResolverFileDescriptor) {
PFD_SETR(ResolverFileDescriptor);
res_pfd = pfd;
}
+ if (-1 < UPingFileDescriptor) {
+ PFD_SETR(UPingFileDescriptor);
+ uping_pfd = pfd;
+ }
+ /*
+ * add uping descriptors
+ */
+ for (uping = uping_begin(); uping; uping = uping_next) {
+ uping_next = uping->next;
+ if (uping->active) {
+ delay2 = 1;
+ if (uping->lastsent && CurrentTime > uping->timeout) {
+ uping_end(uping);
+ continue;
+ }
+ uping->index = pfd_count;
+ PFD_SETR(uping->fd);
+ }
+ }
/*
* add auth file descriptors
*/
CurrentTime = time(0);
}
+ if (uping_pfd && (uping_pfd->revents & (POLLREADFLAGS | POLLERRORS))) {
+ uping_echo();
+ --nfds;
+ }
+ /*
+ * check uping replies
+ */
+ for (uping = uping_begin(); uping; uping = uping_next) {
+ uping_next = uping->next;
+ if (uping->active) {
+ assert(-1 < uping->index);
+ if (poll_fds[uping->index].revents) {
+ uping_read(uping);
+ if (0 == --nfds)
+ break;
+ }
+ else if (CurrentTime > uping->lastsent) {
+ uping->lastsent = CurrentTime;
+ uping_send(uping);
+ }
+ }
+ }
+
if (res_pfd && (res_pfd->revents & (POLLREADFLAGS | POLLERRORS))) {
resolver_read();
--nfds;
{
struct Client* cptr;
struct Listener* listener;
+ struct AuthRequest* auth = 0;
+ struct AuthRequest* auth_next = 0;
+ struct UPing* uping;
+ struct UPing* uping_next;
int nfds;
struct timeval wait;
time_t delay2 = delay;
int res = 0;
int length;
int i;
- struct AuthRequest* auth = 0;
- struct AuthRequest* auth_next = 0;
int read_ready;
fd_set read_set;
fd_set write_set;
if (-1 < ResolverFileDescriptor)
FD_SET(ResolverFileDescriptor, &read_set);
+ if (-1 < UPingFileDescriptor)
+ FD_SET(UPingFileDescriptor, &read_set);
+ /*
+ * set up uping file descriptors
+ */
+ for (uping = uping_begin(); uping; uping = uping_next) {
+ uping_next = uping->next;
+ if (uping->active) {
+ delay2 = 1;
+ if (uping->lastsent && CurrentTime > ping->timeout) {
+ uping_end(uping);
+ continue;
+ }
+ assert(-1 < uping->fd);
+ FD_SET(uping->fd, &read_set);
+ }
+ }
/*
* set auth file descriptors
*/
CurrentTime = time(0);
}
- if (-1 < ResolverFileDescriptor &&
- FD_ISSET(ResolverFileDescriptor, &read_set)) {
+ if (-1 < UPingFileDescriptor && FD_ISSET(UPingFileDescriptor, &read_set)) {
+ uping_echo();
+ --nfds;
+ }
+ for (uping = uping_begin(); uping; uping = uping_next) {
+ uping_next = uping->next;
+ if (uping->active) {
+ assert(-1 < uping->fd);
+ if (FD_ISSET(uping->fd, &read_set)) {
+ uping_read(uping);
+ if (0 == --nfds)
+ break;
+ }
+ else if (CurrentTime > uping->lastsent) {
+ uping->lastsent = CurrentTime;
+ uping_send(uping);
+ }
+ }
+ }
+ if (-1 < ResolverFileDescriptor && FD_ISSET(ResolverFileDescriptor, &read_set)) {
resolver_read();
--nfds;
}
{
assert(0 != conf);
- memset(&virtualHost, 0, sizeof(virtualHost));
- virtualHost.sin_family = AF_INET;
- virtualHost.sin_addr.s_addr = INADDR_ANY;
+ memset(&VirtualHost, 0, sizeof(VirtualHost));
+ VirtualHost.sin_family = AF_INET;
+ VirtualHost.sin_addr.s_addr = INADDR_ANY;
if (EmptyString(conf->passwd) || 0 == strcmp(conf->passwd, "*"))
return;
- virtualHost.sin_addr.s_addr = inet_addr(conf->passwd);
+ VirtualHost.sin_addr.s_addr = inet_addr(conf->passwd);
- if (INADDR_NONE == virtualHost.sin_addr.s_addr)
- virtualHost.sin_addr.s_addr = INADDR_ANY;
+ if (INADDR_NONE == VirtualHost.sin_addr.s_addr)
+ VirtualHost.sin_addr.s_addr = INADDR_ANY;
}
/*
if (IsDigit(*aconf->host)) {
/*
* rfc 1035 sez host names may not start with a digit
+ * XXX - this has changed code needs to be updated
*/
aconf->ipnum.s_addr = inet_addr(aconf->host);
if (INADDR_NONE == aconf->ipnum.s_addr) {
#include "struct.h"
#include "support.h"
#include "sys.h"
+#include "uping.h"
#include "userload.h"
#include <assert.h>
if (bcptr->serv && bcptr->serv->client_list) /* Was SetServerYXX called ? */
ClearServerYXX(bcptr); /* Removes server from server_list[] */
if (IsUser(bcptr)) {
+ /*
+ * clear out uping requests
+ */
+ if (IsUPing(bcptr))
+ uping_cancel(bcptr, 0);
/*
* Stop a running /LIST clean
*/
#include "ircd_osdep.h"
#include "ircd_string.h"
#include "match.h"
+#include "msg.h"
#include "numeric.h"
#include "numnicks.h"
-#include "res.h"
#include "s_bsd.h" /* vserv */
#include "s_conf.h"
#include "s_debug.h"
#define INADDR_NONE 0xffffffff
#endif
-static void ping_server(struct UPing*);
-
static struct UPing* pingList = 0;
-int UPingListener = -1; /* UDP listener socket for upings */
+int UPingFileDescriptor = -1; /* UDP listener socket for upings */
/*
* pings_begin - iterator function for ping list
assert(0 != p);
- for (it = pingList; it; last = it = it->next) {
+ for (it = pingList; it; last = it, it = it->next) {
if (p == it) {
if (last)
last->next = p->next;
}
}
-/*
- * uping_dns_callback - this gets called when the resolver either
- * succeeds or fails to locate the servers address.
- * If the dns query failed hp will be 0, otherwise it
- * will contain the stuff a hostent normally contains.
- */
-static void uping_dns_callback(void* v, struct DNSReply* r)
-{
- struct UPing* ping = (struct UPing*) v;
- assert(valid_ptr((void*)ping, sizeof(struct UPing)));
-
- if (r) {
- memcpy(&ping->sin.sin_addr, r->hp->h_addr, sizeof(struct in_addr));
- ping_server(ping);
- }
- else
- {
- sendto_ops("UDP ping to %s failed: host lookup", ping->name);
- end_ping(ping);
- }
-}
-
-
/*
* Setup a UDP socket and listen for incoming packets
*/
int uping_init(void)
{
- struct sockaddr_in from;
+ struct sockaddr_in from = { 0 };
int fd;
memset(&from, 0, sizeof(from));
-#ifdef VIRTUAL_HOST
- from.sin_addr = vserv.sin_addr;
-#else
- from.sin_addr.s_addr = htonl(INADDR_ANY);
-#endif
+ from.sin_addr = VirtualHost.sin_addr;
from.sin_port = htons(atoi(UDP_PORT));
from.sin_family = AF_INET;
close(fd);
return -1;
}
+ UPingFileDescriptor = fd;
return fd;
}
/*
* max # of pings set to 15/sec.
*/
-void polludp(int udpfd)
+void uping_echo()
{
- struct sockaddr_in from;
+ struct sockaddr_in from = { 0 };
unsigned int len = 0;
static time_t last = 0;
static int counter = 0;
char buf[BUFSIZE + 1];
- Debug((DEBUG_DEBUG, "UPING: poll"));
+ Debug((DEBUG_DEBUG, "UPING: uping_echo"));
- if (IO_SUCCESS != os_recvfrom_nonb(udpfd, buf, BUFSIZE, &len, &from))
+ if (IO_SUCCESS != os_recvfrom_nonb(UPingFileDescriptor, buf, BUFSIZE, &len, &from))
return;
/*
* count em even if we're getting flooded so we can tell we're getting
}
if (len < 19)
return;
- sendto(udpfd, buf, len, 0, (struct sockaddr *)&from, sizeof(from));
+ sendto(UPingFileDescriptor, buf, len, 0, (struct sockaddr*) &from, sizeof(from));
}
/*
* start_ping
*/
-static void start_ping(struct UPing* pptr)
+static void uping_start(struct UPing* pptr)
{
- assert(valid_ptr((void*) pptr, sizeof(struct UPing)));
+ assert(0 != pptr);
- if (MyUser(pptr->client) || Protocol(pptr->client->from) < 10) {
+ if (MyUser(pptr->client)) {
sendto_one(pptr->client,
- ":%s NOTICE %s :Sending %d ping%s to %s[%s] port %d",
- me.name, pptr->client->name, pptr->count,
- (pptr->count == 1) ? "" : "s", pptr->name,
- ircd_ntoa((const char*) &pptr->sin.sin_addr), ntohs(pptr->sin.sin_port));
+ ":%s NOTICE %s :Sending %d ping%s to %s",
+ me.name, pptr->client->name, pptr->count,
+ (pptr->count == 1) ? "" : "s", pptr->name);
}
- else
- {
+ else {
sendto_one(pptr->client,
- "%s NOTICE %s%s :Sending %d ping%s to %s[%s] port %d",
- NumServ(&me), NumNick(pptr->client), pptr->count,
- (pptr->count == 1) ? "" : "s", pptr->name,
- ircd_ntoa((const char*) &pptr->sin.sin_addr), ntohs(pptr->sin.sin_port));
+ "%s NOTICE %s%s :Sending %d ping%s to %s",
+ NumServ(&me), NumNick(pptr->client), pptr->count,
+ (pptr->count == 1) ? "" : "s", pptr->name);
}
pptr->timeout = CurrentTime + UPINGTIMEOUT;
pptr->active = 1;
}
/*
- * ping_server - get the server host address if not valid
- * then call start_ping
- */
-static void ping_server(struct UPing* pptr)
-{
- if (INADDR_NONE == pptr->sin.sin_addr.s_addr) {
- char *s;
-
- if ((s = strchr(pptr->name, '@')))
- ++s;
- else
- s = pptr->name;
-
- if (INADDR_NONE == (pptr->sin.sin_addr.s_addr = inet_addr(s))) {
- struct DNSQuery query;
- struct DNSReply* rpl;
-
- query.vptr = (void*) pptr;
- query.callback = uping_dns_callback;
- if (0 == (rpl = gethost_byname(s, &query)))
- return;
- memcpy(&pptr->sin.sin_addr, rpl->hp->h_addr, sizeof(struct in_addr));
- }
- }
- start_ping(pptr);
-}
-
-
-/*
- * send_ping
+ * uping_send
*
*/
-void send_ping(struct UPing* pptr)
+void uping_send(struct UPing* pptr)
{
struct timeval tv;
char buf[BUFSIZE + 1];
Debug((DEBUG_SEND, "send_ping: sending [%s %s] to %s.%d on %d",
buf, &buf[12],
- ircd_ntoa((const char*) &pptr->sin.sin_addr), ntohs(pptr->sin.sin_port),
+ ircd_ntoa((const char*) &pptr->sin.sin_addr), ntohs(pptr->sin.sin_port),
pptr->fd));
if (sendto(pptr->fd, buf, BUFSIZE, 0, (struct sockaddr*) &pptr->sin,
sizeof(struct sockaddr_in)) != BUFSIZE)
{
- int err = errno;
- if (pptr->client)
- {
- if (MyUser(pptr->client)
-#ifndef NO_PROTOCOL9
- || (IsServer(pptr->client->from) && Protocol(pptr->client->from) < 10)
-#endif
- )
- sendto_one(pptr->client, ":%s NOTICE %s :UPING: sendto() failed: %s",
- me.name, pptr->client->name,
- (strerror(err)) ? strerror(err) : "Unknown error");
+ const char* msg = strerror(errno);
+ if (!msg)
+ msg = "Unknown error";
+ if (pptr->client) {
+ if (MyUser(pptr->client))
+ sendto_one(pptr->client, ":%s NOTICE %s :UPING: send failed: %s",
+ me.name, pptr->client->name, msg);
else
sendto_one(pptr->client, "%s NOTICE %s%s :UPING: sendto() failed: %s",
- NumServ(&me), NumNick(pptr->client),
- (strerror(err)) ? strerror(err) : "Unknown error");
+ NumServ(&me), NumNick(pptr->client), msg);
}
- Debug((DEBUG_DEBUG, "UPING: send_ping: sendto failed on %d: %s", pptr->fd,
- (strerror(err)) ? strerror(err) : "Unknown error"));
- end_ping(pptr);
+ Debug((DEBUG_DEBUG, "UPING: send_ping: sendto failed on %d: %s", pptr->fd, msg));
+ uping_end(pptr);
return;
}
++pptr->sent;
/*
* read_ping
*/
-void read_ping(struct UPing* pptr)
+void uping_read(struct UPing* pptr)
{
struct sockaddr_in sin;
struct timeval tv;
if (IO_BLOCKED == ior)
return;
else if (IO_FAILURE == ior) {
- int err = errno;
- if (MyUser(pptr->client)
-#ifndef NO_PROTOCOL9
- || (IsServer(pptr->client->from) && Protocol(pptr->client->from) < 10)
-#endif
- )
- sendto_one(pptr->client, ":%s NOTICE %s :UPING: recvfrom: %s",
- me.name, pptr->client->name,
- (strerror(err)) ? strerror(err) : "Unknown error");
+ const char* msg = strerror(errno);
+ if (!msg)
+ msg = "Unknown error";
+ if (MyUser(pptr->client))
+ sendto_one(pptr->client, ":%s NOTICE %s :UPING: receive error: %s",
+ me.name, pptr->client->name, msg);
else
- sendto_one(pptr->client, "%s NOTICE %s%s :UPING: recvfrom: %s",
- NumServ(&me), NumNick(pptr->client),
- (strerror(err)) ? strerror(err) : "Unknown error");
- Debug((DEBUG_SEND, "UPING: read_ping: recvfrom: %d", err));
- end_ping(pptr);
+ sendto_one(pptr->client, "%s NOTICE %s%s :UPING: receive error: %s",
+ NumServ(&me), NumNick(pptr->client), msg);
+ uping_end(pptr);
return;
}
if (len < 19)
return; /* Broken packet */
-
+
++pptr->received;
+
+ buf[len] = 0;
pingtime = (tv.tv_sec - atol(&buf[1])) * 1000
+ (tv.tv_usec - atol(buf + strlen(buf) + 1)) / 1000;
pptr->ms_ave += pingtime;
- if (!(pptr->ms_min) || (pptr->ms_min > pingtime))
+ if (!pptr->ms_min || pptr->ms_min > pingtime)
pptr->ms_min = pingtime;
if (pingtime > pptr->ms_max)
pptr->ms_max = pingtime;
pptr->timeout = CurrentTime + UPINGTIMEOUT;
Debug((DEBUG_SEND, "read_ping: %d bytes, ti %lu: [%s %s] %lu ms",
- len, pptr->timeout, buf, (buf + strlen(buf) + 1), pingtime));
+ len, pptr->timeout, buf, (buf + strlen(buf) + 1), pingtime));
s = pptr->buf + strlen(pptr->buf);
sprintf(s, " %u", pingtime);
if (pptr->received == pptr->count)
- end_ping(pptr);
+ uping_end(pptr);
return;
}
-
-/*
- * m_uping -- by Run
- *
- * parv[0] = sender prefix
- * parv[1] = pinged server
- * parv[2] = port
- * parv[3] = hunted server
- * parv[4] = number of requested pings
- */
-int m_uping(struct Client* cptr, struct Client *sptr, int parc, char *parv[])
+int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count)
{
- struct ConfItem *aconf;
- int port;
int fd;
- struct UPing* pptr = 0;
+ struct UPing* pptr;
- if (!IsPrivileged(sptr))
- {
- sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
- return -1;
- }
+ assert(0 != sptr);
+ assert(0 != aconf);
- if (parc < 2)
- {
- sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "UPING");
- return 0;
- }
-
- if (MyUser(sptr))
- {
- if (parc == 2)
- {
- parv[parc++] = UDP_PORT;
- parv[parc++] = me.name;
- parv[parc++] = "5";
- }
- else if (parc == 3)
- {
- if (IsDigit(*parv[2]))
- parv[parc++] = me.name;
- else
- {
- parv[parc++] = parv[2];
- parv[2] = UDP_PORT;
- }
- parv[parc++] = "5";
- }
- else if (parc == 4)
- {
- if (IsDigit(*parv[2]))
- {
- if (IsDigit(*parv[3]))
- {
- parv[parc++] = parv[3];
- parv[3] = me.name;
- }
- else
- parv[parc++] = "5";
- }
- else
- {
- parv[parc++] = parv[3];
- parv[3] = parv[2];
- parv[2] = UDP_PORT;
- }
- }
- }
- if (hunt_server(1, cptr, sptr,
- ":%s UPING %s %s %s %s", 3, parc, parv) != HUNTED_ISME)
- return 0;
-
- if (BadPtr(parv[4]) || atoi(parv[4]) <= 0)
- {
- if (MyUser(sptr) || Protocol(cptr) < 10)
- sendto_one(sptr, ":%s NOTICE %s :UPING: Illegal number of packets: %s",
- me.name, parv[0], parv[4]);
+ if (INADDR_NONE == aconf->ipnum.s_addr) {
+ if (MyUser(sptr))
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Host lookup failed for %s",
+ me.name, sptr->name, aconf->name);
else
- sendto_one(sptr, "%s NOTICE %s%s :UPING: Illegal number of packets: %s",
- NumServ(&me), NumNick(sptr), parv[4]);
- return 0;
- }
-
- /* Check if a CONNECT would be possible at all (adapted from m_connect) */
- for (aconf = GlobalConfList; aconf; aconf = aconf->next)
- {
- if (aconf->status == CONF_SERVER &&
- match(parv[1], aconf->name) == 0)
- break;
- }
- if (!aconf)
- {
- for (aconf = GlobalConfList; aconf; aconf = aconf->next)
- {
- if (aconf->status == CONF_SERVER &&
- (match(parv[1], aconf->host) == 0 ||
- match(parv[1], strchr(aconf->host, '@') + 1) == 0))
- break;
- }
- }
- if (!aconf)
- {
- if (MyUser(sptr) || Protocol(cptr) < 10)
- sendto_one(sptr, ":%s NOTICE %s :UPING: Host %s not listed in ircd.conf",
- me.name, parv[0], parv[1]);
- else
- sendto_one(sptr,
- "%s NOTICE %s%s :UPING: Host %s not listed in ircd.conf",
- NumServ(&me), NumNick(sptr), parv[1]);
- return 0;
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Host lookup failed for %s",
+ NumServ(&me), NumNick(sptr), aconf->name);
}
if (IsUPing(sptr))
- cancel_ping(sptr, sptr); /* Cancel previous ping request */
-
- /*
- * Determine port: First user supplied, then default : 7007
- */
- if (BadPtr(parv[2]) || (port = atoi(parv[2])) <= 0)
- port = atoi(UDP_PORT);
+ uping_cancel(sptr, sptr); /* Cancel previous ping request */
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- int err = errno;
- sendto_ops("m_uping: socket: %s", (err != EMFILE)
- ? ((strerror(err)) ? strerror(err) : "Unknown error") : "No more sockets");
- if (MyUser(sptr) || Protocol(cptr) < 10)
- sendto_one(sptr,
- ":%s NOTICE %s :UPING: Unable to create udp ping socket",
- me.name, parv[0]);
+ if (MyUser(sptr))
+ sendto_one(sptr, ":%s NOTICE %s :UPING: Unable to create udp ping socket",
+ me.name, sptr->name);
else
- sendto_one(sptr,
- "%s NOTICE %s%s :UPING: Unable to create udp ping socket",
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Unable to create udp ping socket",
NumServ(&me), NumNick(sptr));
- ircd_log(L_ERROR, "UPING: Unable to create UDP socket");
return 0;
}
if (!os_set_nonblocking(fd)) {
- if (MyUser(sptr) || Protocol(cptr) < 10)
+ if (MyUser(sptr))
sendto_one(sptr, ":%s NOTICE %s :UPING: Can't set fd non-blocking",
- me.name, parv[0]);
+ me.name, sptr->name);
else
- sendto_one(sptr, "%s NOTICE %s%s :UPING: Can't set fd non-blocking",
- NumServ(&me), NumNick(sptr));
+ sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Can't set fd non-blocking",
+ NumServ(&me), NumNick(sptr));
close(fd);
return 0;
}
assert(0 != pptr);
memset(pptr, 0, sizeof(struct UPing));
- pptr->fd = fd;
- pptr->sin.sin_port = htons(port);
+ pptr->fd = fd;
+ pptr->sin.sin_port = htons(port);
pptr->sin.sin_addr.s_addr = aconf->ipnum.s_addr;
- pptr->sin.sin_family = AF_INET;
- pptr->count = IRCD_MIN(20, atoi(parv[4]));
- strcpy(pptr->name, aconf->host);
- pptr->client = sptr;
- pptr->index = -1;
+ pptr->sin.sin_family = AF_INET;
+ pptr->count = IRCD_MIN(20, count);
+ pptr->client = sptr;
+ pptr->index = -1;
+ strcpy(pptr->name, aconf->name);
pptr->next = pingList;
- pingList = pptr;
+ pingList = pptr;
SetUPing(sptr);
- ping_server(pptr);
+ uping_start(pptr);
return 0;
}
-void end_ping(struct UPing* pptr)
+
+void uping_end(struct UPing* pptr)
{
- Debug((DEBUG_DEBUG, "end_ping: %p", pptr));
- delete_resolver_queries((void*) pptr);
- if (pptr->client)
- {
- if (MyUser(pptr->client)
- || (IsServer(pptr->client->from) && Protocol(pptr->client->from) < 10))
- {
- if (pptr->lastsent) /* Started at all ? */
- {
- if (0 < pptr->received) /* Received any pings at all? */
- {
+ Debug((DEBUG_DEBUG, "uping_end: %p", pptr));
+
+ if (pptr->client) {
+ if (MyUser(pptr->client)) {
+ if (pptr->lastsent) {
+ if (0 < pptr->received) {
sendto_one(pptr->client, ":%s NOTICE %s :UPING %s%s",
- me.name, pptr->client->name, pptr->name, pptr->buf);
- /* XXX - warning long unsigned int format, unsigned int arg (7, 8, 9) */
+ me.name, pptr->client->name, pptr->name, pptr->buf);
+ /*
+ * XXX - warning long unsigned int format, unsigned int arg (7, 8, 9)
+ */
sendto_one(pptr->client,
- ":%s NOTICE %s :UPING Stats: sent %d recvd %d ; "
- "min/avg/max = %1lu/%1lu/%1lu ms",
- me.name, pptr->client->name, pptr->sent,
- pptr->received, pptr->ms_min,
- (2 * pptr->ms_ave) / (2 * pptr->received),
- pptr->ms_max);
+ ":%s NOTICE %s :UPING Stats: sent %d recvd %d ; "
+ "min/avg/max = %1lu/%1lu/%1lu ms",
+ me.name, pptr->client->name, pptr->sent,
+ pptr->received, pptr->ms_min,
+ (2 * pptr->ms_ave) / (2 * pptr->received),
+ pptr->ms_max);
}
else
sendto_one(pptr->client,
- ":%s NOTICE %s :UPING: no response from %s within %d seconds",
- me.name, pptr->client->name, pptr->name,
- UPINGTIMEOUT);
+ ":%s NOTICE %s :UPING: no response from %s within %d seconds",
+ me.name, pptr->client->name, pptr->name,
+ UPINGTIMEOUT);
}
else
sendto_one(pptr->client,
- ":%s NOTICE %s :UPING: Could not start ping to %s %d",
- me.name, pptr->client->name, pptr->name, ntohs(pptr->sin.sin_port));
+ ":%s NOTICE %s :UPING: Could not start ping to %s",
+ me.name, pptr->client->name, pptr->name);
}
- else
- {
- if (pptr->lastsent) /* Started at all ? */
- {
- if (0 < pptr->received) /* Received any pings at all? */
- {
+ else {
+ if (pptr->lastsent) {
+ if (0 < pptr->received) {
sendto_one(pptr->client, "%s NOTICE %s%s :UPING %s%s",
- NumServ(&me), NumNick(pptr->client), pptr->name, pptr->buf);
+ NumServ(&me), NumNick(pptr->client), pptr->name, pptr->buf);
/* XXX - warning: long unsigned int format, unsigned int arg(9, 10, 11) */
sendto_one(pptr->client,
- "%s NOTICE %s%s :UPING Stats: sent %d recvd %d ; "
- "min/avg/max = %1lu/%1lu/%1lu ms",
- NumServ(&me), NumNick(pptr->client), pptr->sent,
- pptr->received, pptr->ms_min,
- (2 * pptr->ms_ave) / (2 * pptr->received),
- pptr->ms_max);
+ "%s " TOK_NOTICE " %s%s :UPING Stats: sent %d recvd %d ; "
+ "min/avg/max = %1lu/%1lu/%1lu ms",
+ NumServ(&me), NumNick(pptr->client), pptr->sent,
+ pptr->received, pptr->ms_min,
+ (2 * pptr->ms_ave) / (2 * pptr->received),
+ pptr->ms_max);
}
else
sendto_one(pptr->client,
- "%s NOTICE %s%s :UPING: no response from %s within %d seconds",
- NumServ(&me), NumNick(pptr->client), pptr->name,
- UPINGTIMEOUT);
+ "%s " TOK_NOTICE " %s%s :UPING: no response from %s within %d seconds",
+ NumServ(&me), NumNick(pptr->client), pptr->name, UPINGTIMEOUT);
}
else
sendto_one(pptr->client,
- "%s NOTICE %s%s :UPING: Could not start ping to %s %d",
- NumServ(&me), NumNick(pptr->client), pptr->name,
- ntohs(pptr->sin.sin_port));
+ "%s " TOK_NOTICE " %s%s :UPING: Could not start ping to %s",
+ NumServ(&me), NumNick(pptr->client), pptr->name);
}
}
close(pptr->fd);
MyFree(pptr);
}
-void cancel_ping(struct Client *sptr, struct Client* acptr)
+void uping_cancel(struct Client *sptr, struct Client* acptr)
{
struct UPing* ping;
struct UPing* ping_next;
ping_next = ping->next;
if (sptr == ping->client) {
ping->client = acptr;
- end_ping(ping);
+ uping_end(ping);
}
}
ClearUPing(sptr);
}
+