ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_pong.c
Revision: 2820
Committed: Wed Jan 15 23:10:26 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3608 byte(s)
Log Message:
- Clean up all files in modules/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years
- Made module handlers int type for later use

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 *client_p, struct Client *source_p,
42 int parc, char *parv[])
43 {
44 struct Client *target_p;
45 const char *origin, *destination;
46
47 if (parc < 2 || EmptyString(parv[1]))
48 {
49 sendto_one(source_p, form_str(ERR_NOORIGIN),
50 me.name, source_p->name);
51 return 0;
52 }
53
54 origin = parv[1];
55 destination = parv[2];
56
57 /* Now attempt to route the PONG, comstud pointed out routable PING
58 * is used for SPING. routable PING should also probably be left in
59 * -Dianora
60 * That being the case, we will route, but only for registered clients (a
61 * case can be made to allow them only from servers). -Shadowfax
62 */
63 if (!EmptyString(destination) && match(destination, me.name) &&
64 irccmp(destination, me.id))
65 {
66 if ((target_p = hash_find_client(destination)) ||
67 (target_p = hash_find_server(destination)))
68 sendto_one(target_p, ":%s PONG %s %s",
69 source_p->name, origin, destination);
70 else
71 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
72 me.name, source_p->name, destination);
73 }
74
75 return 0;
76 }
77
78 static int
79 mr_pong(struct Client *client_p, struct Client *source_p,
80 int parc, char *parv[])
81 {
82 assert(source_p == client_p);
83
84 if (parc == 2 && *parv[1] != '\0')
85 {
86 if (ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
87 {
88 unsigned int incoming_ping = strtoul(parv[1], NULL, 10);
89
90 if (incoming_ping)
91 {
92 if (source_p->localClient->random_ping == incoming_ping)
93 {
94 SetPingCookie(source_p);
95 register_local_user(source_p);
96 }
97 else
98 sendto_one(source_p, form_str(ERR_WRONGPONG), me.name,
99 source_p->name, source_p->localClient->random_ping);
100 }
101 }
102 }
103 else
104 sendto_one(source_p, form_str(ERR_NOORIGIN),
105 me.name, source_p->name);
106 return 0;
107 }
108
109 static struct Message pong_msgtab =
110 {
111 "PONG", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
112 { mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore }
113 };
114
115 static void
116 module_init(void)
117 {
118 mod_add_cmd(&pong_msgtab);
119 }
120
121 static void
122 module_exit(void)
123 {
124 mod_del_cmd(&pong_msgtab);
125 }
126
127 struct module module_entry =
128 {
129 .node = { NULL, NULL, NULL },
130 .name = NULL,
131 .version = "$Revision$",
132 .handle = NULL,
133 .modinit = module_init,
134 .modexit = module_exit,
135 .flags = 0
136 };

Properties

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