/************************************************************************ * IRC - Internet Relay Chat, modules/m_pong.c * * Copyright (C) 2000-2003 TR-IRCD Development * * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Co Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free softwmare; 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 2, 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_pong.c,v 1.3 2003/06/14 13:55:51 tr-ircd Exp $ */ #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "channel.h" #include "h.h" #include "s_conf.h" static char *token = TOK1_PONG; static struct Message _msgtab[] = { {MSG_PONG, 0, MAXPARA, M_SLOW, 0L, m_unregistered, m_pong, m_pong, m_pong, m_pong} }; #ifndef STATIC_MODULES char *_version = "$Revision: 1.3 $"; void _modinit(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } void _moddeinit(void) { mod_del_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = NULL; } #else void m_pong_init(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } #endif /* * * m_pong * parv[0] = sender prefix * parv[1] = origin * * parv[2] = destination */ int m_pong(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *acptr; char *origin, *destination; if (parc < 2 || *parv[1] == '\0') { send_me_numeric(sptr, ERR_NOORIGIN); return 0; } origin = parv[1]; destination = parv[2]; cptr->flags &= ~FLAGS_PINGSENT; sptr->flags &= ~FLAGS_PINGSENT; /* * if it's my client and it's a server.. */ if (sptr == cptr && IsServer(cptr)) { if (sptr->flags & FLAGS_USERBURST) { sptr->flags &= ~FLAGS_USERBURST; sendto_gnotice ("from %C: %s has processed user/channel burst, sending topic burst.", &me, sptr->name); send_topic_burst(sptr); sptr->flags |= FLAGS_PINGSENT | FLAGS_SOBSENT; sendto_one(sptr, "%s :%C", MSG_PING, &me); } else if (sptr->flags & FLAGS_TOPICBURST) { sptr->flags &= ~FLAGS_TOPICBURST; sendto_gnotice ("from %C: %s has processed topic burst (synched to network data).", &me, sptr->name); sendto_serv_butone(sptr, &me, TOK1_GNOTICE, ":%C has synched to network data.", sptr); } } /* * Now attempt to route the PONG, comstud pointed out routable PING * is used for SPING. routable PING should also probably be left in * -Dianora That being the case, we will route, but only for * registered clients (a case can be made to allow them only from * servers). -Shadowfax */ if (!BadPtr(destination) && irc_strcmp(destination, me.name) != 0 && IsRegistered(sptr)) { if ((acptr = find_client(destination)) || (acptr = find_server(destination))) sendto_one(acptr, ":%C %s %s %s", sptr, MSG_PONG, origin, destination); else { send_me_numeric(sptr, ERR_NOSUCHSERVER, destination); return 0; } } return 0; }