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: 4713
Committed: Tue Oct 7 10:56:18 2014 UTC (9 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4693 byte(s)
Log Message:
- m_ping.c, m_pong.c: added proper TS6 support

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_ping.c
23 * \brief Includes required functions for processing the PING command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "send.h"
32 #include "irc_string.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "hash.h"
36 #include "conf.h"
37 #include "server.h"
38
39
40 /*! \brief PING command handler
41 *
42 * \param source_p Pointer to allocated Client struct from which the message
43 * originally comes from. This can be a local or remote client.
44 * \param parc Integer holding the number of supplied arguments.
45 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
46 * pointers.
47 * \note Valid arguments for this command are:
48 * - parv[0] = command
49 * - parv[1] = origin
50 * - parv[2] = destination
51 */
52 static int
53 m_ping(struct Client *source_p, int parc, char *parv[])
54 {
55 struct Client *target_p = NULL;
56 const char *destination = NULL;
57
58 if (parc < 2 || EmptyString(parv[1]))
59 {
60 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
61 return 0;
62 }
63
64 destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
65
66 if (ConfigServerHide.disable_remote_commands && !HasUMode(source_p, UMODE_OPER))
67 {
68 sendto_one(source_p, ":%s PONG %s :%s", me.name,
69 (destination) ? destination : me.name, parv[1]);
70 return 0;
71 }
72
73 if (!EmptyString(destination) && irccmp(destination, me.name))
74 {
75 if ((target_p = hash_find_server(destination)))
76 sendto_one(target_p, ":%s PING %s :%s",
77 ID_or_name(source_p, target_p), source_p->name,
78 ID_or_name(target_p, target_p));
79 else
80 sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
81 }
82 else
83 sendto_one(source_p, ":%s PONG %s :%s", me.name,
84 (destination) ? destination : me.name, parv[1]);
85 return 0;
86 }
87
88 /*! \brief PING command handler
89 *
90 * \param source_p Pointer to allocated Client struct from which the message
91 * originally comes from. This can be a local or remote client.
92 * \param parc Integer holding the number of supplied arguments.
93 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
94 * pointers.
95 * \note Valid arguments for this command are:
96 * - parv[0] = command
97 * - parv[1] = origin
98 * - parv[2] = destination
99 */
100 static int
101 ms_ping(struct Client *source_p, int parc, char *parv[])
102 {
103 struct Client *target_p = NULL;
104 const char *destination = NULL;
105
106 if (parc < 2 || EmptyString(parv[1]))
107 {
108 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
109 return 0;
110 }
111
112 destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
113
114 if (!EmptyString(destination) && irccmp(destination, me.name) && irccmp(destination, me.id))
115 {
116 if ((target_p = hash_find_server(destination)))
117 sendto_one(target_p, ":%s PING %s :%s",
118 ID_or_name(source_p, target_p), source_p->name,
119 ID_or_name(target_p, target_p));
120 else if (!IsDigit(*destination))
121 sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
122 }
123 else
124 sendto_one(source_p, ":%s PONG %s :%s", ID_or_name(&me, source_p),
125 (destination) ? destination : me.name, ID_or_name(source_p, source_p));
126 return 0;
127 }
128
129 static struct Message ping_msgtab =
130 {
131 "PING", NULL, 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
132 { m_unregistered, m_ping, ms_ping, m_ignore, m_ping, m_ping }
133 };
134
135 static void
136 module_init(void)
137 {
138 mod_add_cmd(&ping_msgtab);
139 }
140
141 static void
142 module_exit(void)
143 {
144 mod_del_cmd(&ping_msgtab);
145 }
146
147 struct module module_entry =
148 {
149 .node = { NULL, NULL, NULL },
150 .name = NULL,
151 .version = "$Revision$",
152 .handle = NULL,
153 .modinit = module_init,
154 .modexit = module_exit,
155 .flags = 0
156 };

Properties

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