ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_ping.c
Revision: 1834
Committed: Fri Apr 19 19:50:27 2013 UTC (10 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/modules/m_ping.c
File size: 3959 byte(s)
Log Message:
- Revert to -r1831

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "client.h"
27     #include "ircd.h"
28     #include "numeric.h"
29     #include "send.h"
30     #include "irc_string.h"
31     #include "parse.h"
32     #include "modules.h"
33     #include "hash.h"
34 michael 1309 #include "conf.h"
35 adx 30 #include "s_serv.h"
36    
37    
38     /*
39     ** m_ping
40     ** parv[0] = sender prefix
41     ** parv[1] = origin
42     ** parv[2] = destination
43     */
44     static void
45     m_ping(struct Client *client_p, struct Client *source_p,
46     int parc, char *parv[])
47     {
48     struct Client *target_p;
49     char *origin, *destination;
50    
51 michael 1121 if (parc < 2 || EmptyString(parv[1]))
52 adx 30 {
53 michael 1834 sendto_one(source_p, form_str(ERR_NOORIGIN),
54 michael 1230 me.name, source_p->name);
55 adx 30 return;
56     }
57    
58     origin = parv[1];
59     destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
60    
61 michael 1219 if (ConfigFileEntry.disable_remote && !HasUMode(source_p, UMODE_OPER))
62 adx 30 {
63 michael 1230 sendto_one(source_p, ":%s PONG %s :%s", me.name,
64 adx 30 (destination) ? destination : me.name, origin);
65     return;
66     }
67    
68     if (!EmptyString(destination) && irccmp(destination, me.name) != 0)
69     {
70     /* We're sending it across servers.. origin == client_p->name --fl_ */
71     origin = client_p->name;
72    
73 michael 1169 if ((target_p = hash_find_server(destination)) != NULL)
74 adx 30 {
75 michael 1230 sendto_one(target_p, ":%s PING %s :%s", source_p->name,
76 adx 30 origin, destination);
77     }
78     else
79     {
80 michael 1834 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
81 michael 1230 me.name, source_p->name, destination);
82 adx 30 return;
83     }
84     }
85     else
86 michael 1230 sendto_one(source_p, ":%s PONG %s :%s", me.name,
87 adx 30 (destination) ? destination : me.name, origin);
88     }
89    
90     static void
91     ms_ping(struct Client *client_p, struct Client *source_p,
92     int parc, char *parv[])
93     {
94     struct Client *target_p;
95     const char *origin, *destination;
96    
97 michael 1121 if (parc < 2 || EmptyString(parv[1]))
98 adx 30 {
99 michael 1834 sendto_one(source_p, form_str(ERR_NOORIGIN),
100 michael 1230 me.name, source_p->name);
101 adx 30 return;
102     }
103    
104     origin = source_p->name;
105     destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
106    
107     if (!EmptyString(destination) && irccmp(destination, me.name) != 0 && irccmp(destination, me.id) != 0)
108     {
109 michael 1169 if ((target_p = hash_find_server(destination)))
110 michael 1230 sendto_one(target_p, ":%s PING %s :%s", source_p->name,
111 adx 30 origin, destination);
112     else
113     {
114 michael 1834 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
115 michael 1230 ID_or_name(&me, client_p), source_p->name, destination);
116 adx 30 return;
117     }
118     }
119     else
120 michael 1230 sendto_one(source_p, ":%s PONG %s :%s",
121 adx 30 ID_or_name(&me, client_p), (destination) ? destination : me.name, origin);
122     }
123 michael 1230
124     static struct Message ping_msgtab = {
125     "PING", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
126     {m_unregistered, m_ping, ms_ping, m_ignore, m_ping, m_ping}
127     };
128    
129     static void
130     module_init(void)
131     {
132     mod_add_cmd(&ping_msgtab);
133     }
134    
135     static void
136     module_exit(void)
137     {
138     mod_del_cmd(&ping_msgtab);
139     }
140    
141     struct module module_entry = {
142     .node = { NULL, NULL, NULL },
143     .name = NULL,
144     .version = "$Revision$",
145     .handle = NULL,
146     .modinit = module_init,
147     .modexit = module_exit,
148     .flags = 0
149     };

Properties

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