/[svn]/ircd-hybrid-7.2/modules/m_ping.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/modules/m_ping.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34 - (show annotations)
Sun Oct 2 21:05:51 2005 UTC (14 years ago) by lusky
File MIME type: text/x-chdr
File size: 4204 byte(s)
create 7.2 branch, we can move/rename it as needed.


1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_ping.c: Requests that a PONG message be sent back.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "handlers.h"
27 #include "client.h"
28 #include "ircd.h"
29 #include "numeric.h"
30 #include "send.h"
31 #include "irc_string.h"
32 #include "msg.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "hash.h"
36 #include "s_conf.h"
37 #include "s_serv.h"
38
39 static void m_ping(struct Client*, struct Client*, int, char**);
40 static void ms_ping(struct Client*, struct Client*, int, char**);
41
42 struct Message ping_msgtab = {
43 "PING", 0, 0, 1, 0, MFLG_SLOW, 0,
44 {m_unregistered, m_ping, ms_ping, m_ignore, m_ping, m_ping}
45 };
46
47 #ifndef STATIC_MODULES
48 void
49 _modinit(void)
50 {
51 mod_add_cmd(&ping_msgtab);
52 }
53
54 void
55 _moddeinit(void)
56 {
57 mod_del_cmd(&ping_msgtab);
58 }
59
60 const char *_version = "$Revision$";
61 #endif
62
63 /*
64 ** m_ping
65 ** parv[0] = sender prefix
66 ** parv[1] = origin
67 ** parv[2] = destination
68 */
69 static void
70 m_ping(struct Client *client_p, struct Client *source_p,
71 int parc, char *parv[])
72 {
73 struct Client *target_p;
74 char *origin, *destination;
75
76 if (parc < 2 || *parv[1] == '\0')
77 {
78 sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
79 return;
80 }
81
82 origin = parv[1];
83 destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
84
85 if (ConfigFileEntry.disable_remote && !IsOper(source_p))
86 {
87 sendto_one(source_p,":%s PONG %s :%s", me.name,
88 (destination) ? destination : me.name, origin);
89 return;
90 }
91
92 if (!EmptyString(destination) && irccmp(destination, me.name) != 0)
93 {
94 /* We're sending it across servers.. origin == client_p->name --fl_ */
95 origin = client_p->name;
96
97 /* XXX - sendto_server() ? --fl_ */
98 if ((target_p = find_server(destination)) != NULL)
99 {
100 struct Client *ll_p;
101
102 /* use the direct link for LL checking */
103 ll_p = target_p->from;
104
105 if(ServerInfo.hub && IsCapable(ll_p, CAP_LL))
106 {
107 if((ll_p->lazyLinkClientExists & target_p->localClient->serverMask) == 0)
108 client_burst_if_needed(target_p, ll_p);
109 }
110
111 sendto_one(target_p,":%s PING %s :%s", parv[0],
112 origin, destination);
113 }
114 else
115 {
116 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
117 me.name, parv[0], destination);
118 return;
119 }
120 }
121 else
122 sendto_one(source_p,":%s PONG %s :%s", me.name,
123 (destination) ? destination : me.name, origin);
124 }
125
126 static void
127 ms_ping(struct Client *client_p, struct Client *source_p,
128 int parc, char *parv[])
129 {
130 struct Client *target_p;
131 const char *origin, *destination;
132
133 if (parc < 2 || *parv[1] == '\0')
134 {
135 sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
136 return;
137 }
138
139 origin = source_p->name;
140 destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
141
142 if (!EmptyString(destination) && irccmp(destination, me.name) != 0 && irccmp(destination, me.id) != 0)
143 {
144 if ((target_p = find_server(destination)))
145 sendto_one(target_p,":%s PING %s :%s", parv[0],
146 origin, destination);
147 else
148 {
149 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
150 ID_or_name(&me, client_p), parv[0], destination);
151 return;
152 }
153 }
154 else
155 sendto_one(source_p,":%s PONG %s :%s",
156 ID_or_name(&me, client_p), (destination) ? destination : me.name, origin);
157 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26