X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_ping.c;h=95d747953e3a37d8ede7a9abfac110e0127099f6;hb=refs%2Fheads%2Fupstream;hp=751c174ec60b3746695e63643ffb85de4c514193;hpb=ae91ef6320f611af74e70a0db2620c338fbaa7d5;p=ircu2.10.12-pk.git diff --git a/ircd/m_ping.c b/ircd/m_ping.c index 751c174..95d7479 100644 --- a/ircd/m_ping.c +++ b/ircd/m_ping.c @@ -130,26 +130,24 @@ * 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_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "ircd.h" #include "msg.h" #include "numeric.h" #include "numnicks.h" +#include "opercmds.h" #include "s_debug.h" #include "send.h" -#include +/* #include -- Now using assert in ircd_log.h */ +#include +#include /* * m_ping - generic message handler @@ -159,28 +157,41 @@ * parv[2] = destination */ int m_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + assert(0 != cptr); + assert(cptr == sptr); + + if (parc < 2 || EmptyString(parv[1])) + return send_reply(sptr, ERR_NOORIGIN); + + sendcmdto_one(&me, CMD_PONG, sptr, "%C :%s", &me, parv[1]); + return 0; +} + +/* + * mo_ping - oper message handler + * + * parv[0] = sender prefix + * parv[1] = origin + * parv[2] = destination + */ +int mo_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Client* acptr; - char* destination; + char *destination; assert(0 != cptr); assert(cptr == sptr); if (parc < 2 || EmptyString(parv[1])) - return send_error_to_client(sptr, ERR_NOORIGIN); + return send_reply(sptr, ERR_NOORIGIN); destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ - if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name)) { + if (!EmptyString(destination) && 0 != ircd_strcmp(destination, cli_name(&me))) { if ((acptr = FindServer(destination))) - /* - * NOTE: can't send the origin string to servers, since this is a client, - * we could get garbage, and the link between us and the pingee wouldn't - * know who to send it to. - * sendto_one(acptr, "%s%s PING %s :%s", NumNick(sptr), parv[1], destination); - */ - sendto_one(acptr, "%s%s " TOK_PING " %s :%s", NumNick(sptr), sptr->name, destination); + sendcmdto_one(sptr, CMD_PING, acptr, "%C :%s", sptr, destination); else - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, sptr->name, destination); + send_reply(sptr, ERR_NOSUCHSERVER, destination); } else { /* @@ -192,11 +203,11 @@ int m_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) /* Is this supposed to be here? */ acptr = FindClient(origin); if (acptr && acptr != sptr) - origin = cptr->name; + origin = cli_name(cptr); if (strlen(origin) > 64) origin[64] = '\0'; - sendto_one(sptr, ":%s PONG %s :%s", me.name, me.name, origin); + sendcmdto_one(&me, CMD_PONG, sptr, "%C :%s", &me, origin); } return 0; } @@ -211,7 +222,7 @@ int m_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ /* - * ms_ping - server message handler template + * ms_ping - server message handler */ int ms_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { @@ -227,32 +238,31 @@ int ms_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) /* * don't bother sending the error back */ -#if 0 - sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); -#endif return 0; } origin = parv[1]; destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ - if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name)) { + if (parc > 3) + { + /* AsLL ping, send reply back */ + int diff = atoi(militime_float(parv[3])); + sendcmdto_one(&me, CMD_PONG, sptr, "%C %s %s %i %s", &me, origin, + parv[3], diff, militime_float(NULL)); + return 0; + } + if (!EmptyString(destination) && 0 != ircd_strcmp(destination, cli_name(&me))) { if ((acptr = FindServer(destination))) { /* * Servers can just forward the origin */ - if (IsServer(sptr)) - /* - * servers don't normally send pings to remote servers - */ - sendto_one(acptr, "%s " TOK_PING " %s :%s", NumServ(sptr), origin, destination); - else - sendto_one(acptr, "%s%s " TOK_PING " %s :%s", NumNick(sptr), origin, destination); + sendcmdto_one(sptr, CMD_PING, acptr, "%s :%s", origin, destination); } else { /* * this can happen if server split before the ping got here */ - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, sptr->name, destination); + send_reply(sptr, ERR_NOSUCHSERVER, destination); } } else { @@ -261,51 +271,7 @@ int ms_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * NOTE: sptr is never local so if pong handles numerics everywhere we * could send a numeric here. */ - sendto_one(sptr, "%s " TOK_PONG " %s :%s", NumServ(&me), me.name, origin); + sendcmdto_one(&me, CMD_PONG, sptr, "%C :%s", &me, origin); } return 0; } - - -#if 0 -/* - * m_ping - * - * parv[0] = sender prefix - * parv[1] = origin - * parv[2] = destination - */ -int m_ping(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client *acptr; - char *origin, *destination; - - if (parc < 2 || *parv[1] == '\0') - { - sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); - return 0; - } - origin = parv[1]; - destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ - - acptr = FindClient(origin); - if (acptr && acptr != sptr) - origin = cptr->name; - - if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name) != 0) - { - if ((acptr = FindServer(destination))) - sendto_one(acptr, ":%s PING %s :%s", parv[0], origin, destination); - else - { - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), - me.name, parv[0], destination); - return 0; - } - } - else - sendto_one(sptr, ":%s PONG %s :%s", me.name, me.name, origin); - return 0; -} -#endif -