ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_pong.c
Revision: 3156
Committed: Fri Mar 14 19:57:38 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 3415 byte(s)
Log Message:
- Removed client_p pointers from everywhere

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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_pong.c
23 * \brief Includes required functions for processing the PONG command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "ircd.h"
29 #include "s_user.h"
30 #include "client.h"
31 #include "hash.h"
32 #include "numeric.h"
33 #include "conf.h"
34 #include "send.h"
35 #include "irc_string.h"
36 #include "parse.h"
37 #include "modules.h"
38
39
40 static int
41 ms_pong(struct Client *source_p, int parc, char *parv[])
42 {
43 struct Client *target_p;
44 const char *origin, *destination;
45
46 if (parc < 2 || EmptyString(parv[1]))
47 {
48 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
49 return 0;
50 }
51
52 origin = parv[1];
53 destination = parv[2];
54
55 /* Now attempt to route the PONG, comstud pointed out routable PING
56 * is used for SPING. routable PING should also probably be left in
57 * -Dianora
58 * That being the case, we will route, but only for registered clients (a
59 * case can be made to allow them only from servers). -Shadowfax
60 */
61 if (!EmptyString(destination) && match(destination, me.name) &&
62 irccmp(destination, me.id))
63 {
64 if ((target_p = hash_find_client(destination)) ||
65 (target_p = hash_find_server(destination)))
66 sendto_one(target_p, ":%s PONG %s %s",
67 source_p->name, origin, destination);
68 else
69 sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
70 }
71
72 return 0;
73 }
74
75 static int
76 mr_pong(struct Client *source_p, int parc, char *parv[])
77 {
78 assert(MyConnect(source_p));
79
80 if (parc == 2 && *parv[1] != '\0')
81 {
82 if (ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
83 {
84 unsigned int incoming_ping = strtoul(parv[1], NULL, 10);
85
86 if (incoming_ping)
87 {
88 if (source_p->localClient->random_ping == incoming_ping)
89 {
90 SetPingCookie(source_p);
91 register_local_user(source_p);
92 }
93 else
94 sendto_one_numeric(source_p, &me, ERR_WRONGPONG,
95 source_p->localClient->random_ping);
96 }
97 }
98 }
99 else
100 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
101
102 return 0;
103 }
104
105 static struct Message pong_msgtab =
106 {
107 "PONG", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
108 { mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore }
109 };
110
111 static void
112 module_init(void)
113 {
114 mod_add_cmd(&pong_msgtab);
115 }
116
117 static void
118 module_exit(void)
119 {
120 mod_del_cmd(&pong_msgtab);
121 }
122
123 struct module module_entry =
124 {
125 .node = { NULL, NULL, NULL },
126 .name = NULL,
127 .version = "$Revision$",
128 .handle = NULL,
129 .modinit = module_init,
130 .modexit = module_exit,
131 .flags = 0
132 };

Properties

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