ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_stats.c
Revision: 3516
Committed: Mon May 12 17:34:43 2014 UTC (11 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 52946 byte(s)
Log Message:
- m_stats.c:stats_operedup(): don't show idle time if operator is +q

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 2820 /*! \file m_stats.c
23     * \brief Includes required functions for processing the STATS command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 2820 #include "list.h"
29     #include "client.h"
30     #include "irc_string.h"
31     #include "ircd.h"
32     #include "listener.h"
33 michael 3321 #include "gline.h"
34 michael 1632 #include "conf.h"
35 michael 1644 #include "conf_class.h"
36 adx 30 #include "hostmask.h"
37 michael 2820 #include "numeric.h"
38     #include "send.h"
39     #include "fdlist.h"
40     #include "s_bsd.h"
41 michael 3347 #include "misc.h"
42     #include "server.h"
43     #include "user.h"
44 michael 2820 #include "event.h"
45 adx 30 #include "dbuf.h"
46 michael 1144 #include "hook.h"
47 adx 30 #include "parse.h"
48     #include "modules.h"
49 michael 2820 #include "resv.h"
50 adx 30 #include "whowas.h"
51 michael 884 #include "watch.h"
52 michael 3322 #include "res.h"
53 michael 2150 #include "motd.h"
54 adx 30
55    
56 michael 1922 static const struct shared_flags
57     {
58     const unsigned int type;
59     const unsigned char letter;
60     } flag_table[] = {
61     { SHARED_KLINE, 'K' },
62     { SHARED_UNKLINE, 'U' },
63     { SHARED_XLINE, 'X' },
64     { SHARED_UNXLINE, 'Y' },
65     { SHARED_RESV, 'Q' },
66     { SHARED_UNRESV, 'R' },
67     { SHARED_LOCOPS, 'L' },
68     { SHARED_DLINE, 'D' },
69     { SHARED_UNDLINE, 'E' },
70     { 0, '\0' }
71     };
72    
73 adx 30 /*
74 michael 1922 * inputs - pointer to client requesting confitem report
75     * - ConfType to report
76     * output - none
77     * side effects -
78     */
79     static void
80     report_confitem_types(struct Client *source_p, enum maskitem_type type)
81     {
82 michael 2160 dlink_node *ptr = NULL;
83 michael 1922 struct MaskItem *conf = NULL;
84     const struct shared_flags *shared = NULL;
85 michael 2691 char buf[IRCD_BUFSIZE];
86 michael 1922 char *p = NULL;
87    
88     switch (type)
89     {
90     case CONF_XLINE:
91     DLINK_FOREACH(ptr, xconf_items.head)
92     {
93     conf = ptr->data;
94    
95 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSXLINE,
96 michael 2820 conf->until ? 'x': 'X', conf->count,
97     conf->name, conf->reason);
98 michael 1922 }
99     break;
100    
101     case CONF_ULINE:
102     DLINK_FOREACH(ptr, uconf_items.head)
103     {
104     conf = ptr->data;
105    
106     p = buf;
107    
108     *p++ = 'c';
109 michael 3285 for (shared = flag_table; shared->type; ++shared)
110 michael 1922 if (shared->type & conf->flags)
111     *p++ = shared->letter;
112     else
113     *p++ = ToLower(shared->letter);
114    
115 michael 3285 *p = '\0';
116    
117 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSULINE, conf->name,
118 michael 1922 conf->user?conf->user: "*",
119 michael 2820 conf->host?conf->host: "*", buf);
120 michael 1922 }
121    
122     DLINK_FOREACH(ptr, cluster_items.head)
123     {
124     conf = ptr->data;
125    
126     p = buf;
127    
128     *p++ = 'C';
129 michael 3285 for (shared = flag_table; shared->type; ++shared)
130 michael 1922 if (shared->type & conf->flags)
131     *p++ = shared->letter;
132     else
133     *p++ = ToLower(shared->letter);
134    
135 michael 3285 *p = '\0';
136    
137 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSULINE, conf->name,
138 michael 1922 "*", "*", buf);
139     }
140    
141     break;
142    
143     case CONF_OPER:
144     DLINK_FOREACH(ptr, oconf_items.head)
145     {
146     conf = ptr->data;
147    
148     /* Don't allow non opers to see oper privs */
149     if (HasUMode(source_p, UMODE_OPER))
150 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSOLINE, 'O', conf->user, conf->host,
151 michael 2820 conf->name, oper_privs_as_string(conf->port),
152     conf->class ? conf->class->name : "<default>");
153 michael 1922 else
154 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSOLINE, 'O', conf->user, conf->host,
155 michael 1922 conf->name, "0",
156 michael 2820 conf->class ? conf->class->name : "<default>");
157 michael 1922 }
158     break;
159    
160     case CONF_SERVICE:
161     DLINK_FOREACH(ptr, service_items.head)
162     {
163     conf = ptr->data;
164 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSSERVICE, 'S', "*", conf->name, 0, 0);
165 michael 1922 }
166     break;
167    
168     case CONF_SERVER:
169     DLINK_FOREACH(ptr, server_items.head)
170     {
171     p = buf;
172     conf = ptr->data;
173    
174     buf[0] = '\0';
175    
176     if (IsConfAllowAutoConn(conf))
177 michael 2820 *p++ = 'A';
178 michael 1922 if (IsConfSSL(conf))
179     *p++ = 'S';
180     if (buf[0] == '\0')
181 michael 2820 *p++ = '*';
182 michael 1922
183     *p = '\0';
184    
185     /*
186     * Allow admins to see actual ips unless hide_server_ips is enabled
187     */
188     if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
189 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSCLINE, 'C', conf->host,
190 michael 2820 buf, conf->name, conf->port,
191     conf->class ? conf->class->name : "<default>");
192 michael 1922 else
193 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSCLINE, 'C',
194 michael 2820 "*@127.0.0.1", buf, conf->name, conf->port,
195     conf->class ? conf->class->name : "<default>");
196 michael 1922 }
197     break;
198    
199     default:
200     break;
201     }
202     }
203    
204 michael 1927 /* report_resv()
205     *
206     * inputs - pointer to client pointer to report to.
207     * output - NONE
208     * side effects - report all resvs to client.
209     */
210     static void
211     report_resv(struct Client *source_p)
212     {
213     dlink_node *ptr = NULL;
214    
215 michael 2174 DLINK_FOREACH(ptr, cresv_items.head)
216 michael 1927 {
217 michael 3109 struct MaskItem *conf = ptr->data;
218    
219     sendto_one_numeric(source_p, &me, RPL_STATSQLINE,
220     conf->until ? 'q' : 'Q', conf->count,
221     conf->name, conf->reason);
222 michael 1927 }
223    
224     DLINK_FOREACH(ptr, nresv_items.head)
225     {
226 michael 3109 struct MaskItem *conf = ptr->data;
227    
228     sendto_one_numeric(source_p, &me, RPL_STATSQLINE,
229     conf->until ? 'q' : 'Q', conf->count,
230     conf->name, conf->reason);
231 michael 1927 }
232     }
233    
234 michael 1922 /*
235 adx 30 * This is part of the STATS replies. There is no offical numeric for this
236     * since this isnt an official command, in much the same way as HASH isnt.
237     * It is also possible that some systems wont support this call or have
238     * different field names for "struct rusage".
239     * -avalon
240     */
241     static void
242 michael 1457 stats_usage(struct Client *source_p, int parc, char *parv[])
243 adx 30 {
244     struct rusage rus;
245     time_t secs;
246     time_t rup;
247     #ifdef hz
248     # define hzz hz
249     #else
250     # ifdef HZ
251     # define hzz HZ
252     # else
253     int hzz = 1;
254     # endif
255     #endif
256    
257     if (getrusage(RUSAGE_SELF, &rus) == -1)
258     {
259 michael 3110 sendto_one_notice(source_p, &me, ":Getruseage error: %s",
260     strerror(errno));
261 adx 30 return;
262     }
263    
264     secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec;
265    
266     if (secs == 0)
267     secs = 1;
268    
269 michael 1241 rup = (CurrentTime - me.localClient->since) * hzz;
270 adx 30
271     if (rup == 0)
272     rup = 1;
273    
274     sendto_one(source_p,
275 michael 1968 ":%s %d %s R :CPU Secs %d:%02d User %d:%02d System %d:%02d",
276 adx 30 me.name, RPL_STATSDEBUG, source_p->name, (int)(secs/60), (int)(secs%60),
277     (int)(rus.ru_utime.tv_sec/60), (int)(rus.ru_utime.tv_sec%60),
278     (int)(rus.ru_stime.tv_sec/60), (int)(rus.ru_stime.tv_sec%60));
279     sendto_one(source_p, ":%s %d %s R :RSS %ld ShMem %ld Data %ld Stack %ld",
280     me.name, RPL_STATSDEBUG, source_p->name, rus.ru_maxrss,
281     (rus.ru_ixrss / rup), (rus.ru_idrss / rup),
282     (rus.ru_isrss / rup));
283     sendto_one(source_p, ":%s %d %s R :Swaps %d Reclaims %d Faults %d",
284     me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nswap,
285     (int)rus.ru_minflt, (int)rus.ru_majflt);
286     sendto_one(source_p, ":%s %d %s R :Block in %d out %d",
287     me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_inblock,
288     (int)rus.ru_oublock);
289     sendto_one(source_p, ":%s %d %s R :Msg Rcv %d Send %d",
290     me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_msgrcv,
291     (int)rus.ru_msgsnd);
292     sendto_one(source_p, ":%s %d %s R :Signals %d Context Vol. %d Invol %d",
293     me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nsignals,
294     (int)rus.ru_nvcsw, (int)rus.ru_nivcsw);
295     }
296    
297     static void
298 michael 1457 stats_memory(struct Client *source_p, int parc, char *parv[])
299 adx 30 {
300     const dlink_node *gptr = NULL;
301     const dlink_node *dlink = NULL;
302    
303 michael 948 unsigned int local_client_conf_count = 0; /* local client conf links */
304     unsigned int users_counted = 0; /* user structs */
305 adx 30
306 michael 1017 unsigned int channel_members = 0;
307 michael 948 unsigned int channel_invites = 0;
308     unsigned int channel_bans = 0;
309     unsigned int channel_except = 0;
310     unsigned int channel_invex = 0;
311 adx 30
312 michael 948 unsigned int wwu = 0; /* whowas users */
313     unsigned int class_count = 0; /* classes */
314     unsigned int aways_counted = 0;
315     unsigned int number_ips_stored; /* number of ip addresses hashed */
316 adx 30
317 michael 948 uint64_t channel_memory = 0;
318     uint64_t channel_ban_memory = 0;
319     uint64_t channel_except_memory = 0;
320     uint64_t channel_invex_memory = 0;
321 adx 30
322     unsigned int safelist_count = 0;
323 michael 948 uint64_t safelist_memory = 0;
324 adx 30
325 michael 948 uint64_t wwm = 0; /* whowas array memory used */
326     uint64_t conf_memory = 0; /* memory used by conf lines */
327     uint64_t mem_ips_stored; /* memory used by ip address hash */
328 adx 30
329 michael 948 uint64_t total_channel_memory = 0;
330     uint64_t totww = 0;
331 adx 30
332     unsigned int local_client_count = 0;
333     unsigned int remote_client_count = 0;
334    
335 michael 948 uint64_t local_client_memory_used = 0;
336     uint64_t remote_client_memory_used = 0;
337 adx 30
338 michael 948 uint64_t total_memory = 0;
339 adx 30 unsigned int topic_count = 0;
340    
341 michael 1017 unsigned int watch_list_headers = 0; /* watchlist headers */
342     unsigned int watch_list_entries = 0; /* watchlist entries */
343     uint64_t watch_list_memory = 0; /* watchlist memory used */
344 michael 884
345 adx 30
346     DLINK_FOREACH(gptr, global_client_list.head)
347     {
348     struct Client *target_p = gptr->data;
349    
350     if (MyConnect(target_p))
351     {
352     ++local_client_count;
353     local_client_conf_count += dlink_list_length(&target_p->localClient->confs);
354 michael 1017 watch_list_entries += dlink_list_length(&target_p->localClient->watches);
355 adx 30 }
356     else
357     ++remote_client_count;
358    
359     if (IsClient(target_p))
360     {
361     ++users_counted;
362    
363 michael 1483 if (target_p->away[0])
364 adx 30 ++aways_counted;
365     }
366     }
367    
368     /* Count up all channels, ban lists, except lists, Invex lists */
369     channel_memory = dlink_list_length(&global_channel_list) *
370     sizeof(struct Channel);
371     DLINK_FOREACH(gptr, global_channel_list.head)
372     {
373 michael 948 const struct Ban *actualBan;
374     const struct Channel *chptr = gptr->data;
375 adx 30
376 michael 1017 channel_members += dlink_list_length(&chptr->members);
377 adx 30 channel_invites += dlink_list_length(&chptr->invites);
378    
379 michael 1203 if (chptr->topic[0])
380 adx 30 ++topic_count;
381    
382 michael 1017 channel_bans += dlink_list_length(&chptr->banlist);
383     channel_ban_memory += dlink_list_length(&chptr->banlist) * sizeof(struct Ban);
384    
385     DLINK_FOREACH(dlink, chptr->banlist.head)
386 adx 30 {
387 michael 1017 actualBan = dlink->data;
388     assert(actualBan->who);
389 adx 30
390 michael 1017 channel_ban_memory += actualBan->len + 1;
391     channel_ban_memory += strlen(actualBan->who) + 1;
392 adx 30 }
393    
394 michael 1017 channel_except += dlink_list_length(&chptr->exceptlist);
395     channel_except_memory += dlink_list_length(&chptr->exceptlist) * sizeof(struct Ban);
396    
397     DLINK_FOREACH(dlink, chptr->exceptlist.head)
398 adx 30 {
399 michael 1017 actualBan = dlink->data;
400     assert(actualBan->who);
401 adx 30
402 michael 1017 channel_except_memory += actualBan->len + 1;
403     channel_except_memory += strlen(actualBan->who) + 1;
404 adx 30 }
405    
406 michael 1017 channel_invex += dlink_list_length(&chptr->invexlist);
407     channel_invex_memory += dlink_list_length(&chptr->invexlist) * sizeof(struct Ban);
408    
409     DLINK_FOREACH(dlink, chptr->invexlist.head)
410 adx 30 {
411 michael 1017 actualBan = dlink->data;
412     assert(actualBan->who);
413 adx 30
414 michael 1017 channel_invex_memory += actualBan->len + 1;
415     channel_invex_memory += strlen(actualBan->who) + 1;
416 adx 30 }
417     }
418    
419     if ((safelist_count = dlink_list_length(&listing_client_list)))
420     {
421     safelist_memory = safelist_count * sizeof(struct ListTask);
422     DLINK_FOREACH(gptr, listing_client_list.head)
423     {
424 michael 948 const struct Client *acptr = gptr->data;
425 adx 30
426     DLINK_FOREACH(dlink, acptr->localClient->list_task->show_mask.head)
427     safelist_memory += strlen(dlink->data);
428    
429     DLINK_FOREACH(dlink, acptr->localClient->list_task->hide_mask.head)
430     safelist_memory += strlen(dlink->data);
431     }
432     }
433    
434     #if 0
435     /* XXX THIS has to be fixed !!!! -db */
436     /* count up all config items */
437     DLINK_FOREACH(dlink, ConfigItemList.head)
438     {
439     aconf = dlink->data;
440     conf_memory += aconf->host ? strlen(aconf->host)+1 : 0;
441     conf_memory += aconf->passwd ? strlen(aconf->passwd)+1 : 0;
442     conf_memory += aconf->name ? strlen(aconf->name)+1 : 0;
443     conf_memory += sizeof(struct AccessItem);
444     }
445     #endif
446     /* count up all classes */
447 michael 1644 class_count = dlink_list_length(class_get_list());
448 adx 30
449 michael 2297 whowas_count_memory(&wwu, &wwm);
450 michael 1017 watch_count_memory(&watch_list_headers, &watch_list_memory);
451 michael 884
452 michael 1761 sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%llu) entries %d(%u)",
453 michael 1017 me.name, RPL_STATSDEBUG, source_p->name, watch_list_headers,
454     watch_list_memory, watch_list_entries,
455     watch_list_entries * sizeof(dlink_node) * 2);
456 michael 884
457     sendto_one(source_p, ":%s %d %s z :Clients %u(%u)",
458 adx 30 me.name, RPL_STATSDEBUG, source_p->name, users_counted,
459 michael 884 (users_counted * sizeof(struct Client)));
460 adx 30
461 michael 1483 sendto_one(source_p, ":%s %d %s z :User aways %u",
462 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
463 michael 1483 aways_counted);
464 adx 30
465 michael 948 sendto_one(source_p, ":%s %d %s z :Attached confs %u(%llu)",
466 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
467     local_client_conf_count,
468 michael 948 (unsigned long long)(local_client_conf_count * sizeof(dlink_node)));
469 adx 30
470 michael 1127 sendto_one(source_p, ":%s %d %s z :Resv channels %u(%lu) nicks %u(%lu)",
471 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
472 michael 2174 dlink_list_length(&cresv_items),
473     dlink_list_length(&cresv_items) * sizeof(struct MaskItem),
474 adx 30 dlink_list_length(&nresv_items),
475 michael 1632 dlink_list_length(&nresv_items) * sizeof(struct MaskItem));
476 adx 30
477 michael 948 sendto_one(source_p, ":%s %d %s z :Classes %u(%llu)",
478 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
479 michael 948 class_count, (unsigned long long)(class_count * sizeof(struct ClassItem)));
480 adx 30
481 michael 1761 sendto_one(source_p, ":%s %d %s z :Channels %u(%llu) Topics %u(%u)",
482 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
483     dlink_list_length(&global_channel_list),
484     channel_memory, topic_count, topic_count *
485     (TOPICLEN + 1 + USERHOST_REPLYLEN));
486    
487 michael 948 sendto_one(source_p, ":%s %d %s z :Bans %u(%llu)",
488 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
489     channel_bans, channel_ban_memory);
490    
491 michael 948 sendto_one(source_p, ":%s %d %s z :Exceptions %u(%llu)",
492 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
493     channel_except, channel_except_memory);
494    
495 michael 948 sendto_one(source_p, ":%s %d %s z :Invex %u(%llu)",
496 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
497     channel_invex, channel_invex_memory);
498    
499 michael 948 sendto_one(source_p, ":%s %d %s z :Channel members %u(%llu) invites %u(%llu)",
500 michael 1017 me.name, RPL_STATSDEBUG, source_p->name, channel_members,
501     (unsigned long long)(channel_members * sizeof(struct Membership)),
502 michael 948 channel_invites, (unsigned long long)channel_invites *
503 michael 884 sizeof(dlink_node) * 2);
504 adx 30
505     total_channel_memory = channel_memory + channel_ban_memory +
506 michael 1017 channel_members * sizeof(struct Membership) +
507 michael 884 (channel_invites * sizeof(dlink_node)*2);
508 adx 30
509 michael 948 sendto_one(source_p, ":%s %d %s z :Safelist %u(%llu)",
510 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
511     safelist_count, safelist_memory);
512    
513 michael 948 sendto_one(source_p, ":%s %d %s z :Whowas users %u(%llu)",
514 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
515 michael 948 wwu, (unsigned long long)(wwu * sizeof(struct Client)));
516 adx 30
517 michael 948 sendto_one(source_p, ":%s %d %s z :Whowas array %u(%llu)",
518 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
519 michael 948 NICKNAMEHISTORYLENGTH, wwm);
520 adx 30
521     totww = wwu * sizeof(struct Client) + wwm;
522    
523 michael 2150 motd_memory_count(source_p);
524 adx 30 count_ip_hash(&number_ips_stored,&mem_ips_stored);
525 michael 948 sendto_one(source_p, ":%s %d %s z :iphash %u(%llu)",
526 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
527 michael 948 number_ips_stored, mem_ips_stored);
528 adx 30
529     total_memory = totww + total_channel_memory + conf_memory + class_count *
530     sizeof(struct ClassItem);
531 michael 948 sendto_one(source_p, ":%s %d %s z :Total: whowas %llu channel %llu conf %llu",
532     me.name, RPL_STATSDEBUG, source_p->name, totww,
533     total_channel_memory, conf_memory);
534 adx 30
535     local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct LocalUser));
536     total_memory += local_client_memory_used;
537 michael 1127 sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %u(%llu)",
538 adx 30 me.name, RPL_STATSDEBUG, source_p->name, local_client_count,
539     local_client_memory_used);
540    
541     remote_client_memory_used = remote_client_count * sizeof(struct Client);
542     total_memory += remote_client_memory_used;
543 michael 1127 sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %u(%llu)",
544 adx 30 me.name, RPL_STATSDEBUG, source_p->name, remote_client_count,
545     remote_client_memory_used);
546    
547     sendto_one(source_p,
548 michael 948 ":%s %d %s z :TOTAL: %llu",
549 adx 30 me.name, RPL_STATSDEBUG, source_p->name,
550 michael 948 total_memory);
551 adx 30 }
552    
553     static void
554     stats_dns_servers(struct Client *source_p)
555     {
556     report_dns_servers(source_p);
557     }
558    
559     static void
560 michael 1457 stats_connect(struct Client *source_p, int parc, char *parv[])
561 adx 30 {
562 michael 1632 report_confitem_types(source_p, CONF_SERVER);
563 adx 30 }
564    
565     /* stats_deny()
566     *
567     * input - client to report to
568     * output - none
569     * side effects - client is given dline list.
570     */
571     static void
572 michael 1457 stats_deny(struct Client *source_p, int parc, char *parv[])
573 adx 30 {
574 michael 3246 struct MaskItem *conf = NULL;
575 michael 1367 dlink_node *ptr = NULL;
576 adx 30
577 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
578 adx 30 {
579 michael 1367 DLINK_FOREACH(ptr, atable[i].head)
580 adx 30 {
581 michael 1367 struct AddressRec *arec = ptr->data;
582    
583 michael 1632 if (arec->type != CONF_DLINE)
584     continue;
585 adx 30
586 michael 1632 conf = arec->conf;
587 adx 30
588 michael 1632 /* dont report a tdline as a dline */
589 michael 1649 if (conf->until)
590 michael 1632 continue;
591 adx 30
592 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSDLINE, 'D', conf->host, conf->reason);
593 adx 30 }
594     }
595     }
596    
597     /* stats_tdeny()
598     *
599     * input - client to report to
600     * output - none
601     * side effects - client is given dline list.
602     */
603     static void
604 michael 1457 stats_tdeny(struct Client *source_p, int parc, char *parv[])
605 adx 30 {
606 michael 1632 struct MaskItem *conf = NULL;
607 michael 1367 dlink_node *ptr = NULL;
608 adx 30
609 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
610 adx 30 {
611 michael 1367 DLINK_FOREACH(ptr, atable[i].head)
612 adx 30 {
613 michael 1367 struct AddressRec *arec = ptr->data;
614    
615 michael 1632 if (arec->type != CONF_DLINE)
616     continue;
617 adx 30
618 michael 1632 conf = arec->conf;
619 adx 30
620 michael 1632 /* dont report a permanent dline as a tdline */
621 michael 1649 if (!conf->until)
622 michael 1632 continue;
623 adx 30
624 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSDLINE, 'd', conf->host, conf->reason);
625 adx 30 }
626     }
627     }
628    
629     /* stats_exempt()
630     *
631     * input - client to report to
632     * output - none
633     * side effects - client is given list of exempt blocks
634     */
635     static void
636 michael 1457 stats_exempt(struct Client *source_p, int parc, char *parv[])
637 adx 30 {
638 michael 1632 struct MaskItem *conf;
639 michael 1367 dlink_node *ptr = NULL;
640 adx 30
641 michael 584 if (ConfigFileEntry.stats_e_disabled)
642     {
643 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
644 michael 584 return;
645     }
646    
647 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
648 adx 30 {
649 michael 1367 DLINK_FOREACH(ptr, atable[i].head)
650 adx 30 {
651 michael 1367 struct AddressRec *arec = ptr->data;
652    
653 michael 1632 if (arec->type != CONF_EXEMPT)
654     continue;
655 adx 30
656 michael 1632 conf = arec->conf;
657 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSDLINE, 'e', conf->host, "");
658 adx 30 }
659     }
660     }
661    
662     static void
663 michael 1457 stats_events(struct Client *source_p, int parc, char *parv[])
664 adx 30 {
665     show_events(source_p);
666     }
667    
668     /* stats_pending_glines()
669     *
670     * input - client pointer
671     * output - none
672     * side effects - client is shown list of pending glines
673     */
674     static void
675 michael 1457 stats_pending_glines(struct Client *source_p, int parc, char *parv[])
676 adx 30 {
677 michael 958 const dlink_node *dn_ptr = NULL;
678 michael 988 const struct gline_pending *glp_ptr = NULL;
679 michael 3246 char timebuffer[MAX_DATE_STRING] = "";
680 michael 958 struct tm *tmptr = NULL;
681 adx 30
682     if (!ConfigFileEntry.glines)
683     {
684 michael 3110 sendto_one_notice(source_p, &me, ":This server does not support G-Lines");
685 adx 30 return;
686     }
687    
688 michael 3246 if (dlink_list_length(&pending_glines[GLINE_PENDING_ADD_TYPE]))
689 michael 3110 sendto_one_notice(source_p, &me, ":Pending G-lines");
690 adx 30
691 michael 958 DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_ADD_TYPE].head)
692 adx 30 {
693 michael 958 glp_ptr = dn_ptr->data;
694     tmptr = localtime(&glp_ptr->vote_1.time_request);
695 adx 30 strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
696    
697 michael 3110 sendto_one_notice(source_p, &me, ":1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
698     glp_ptr->vote_1.oper_nick,
699     glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
700     glp_ptr->vote_1.oper_server, timebuffer,
701     glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
702 adx 30
703 michael 3246 if (glp_ptr->vote_2.oper_nick[0])
704 adx 30 {
705 michael 958 tmptr = localtime(&glp_ptr->vote_2.time_request);
706 adx 30 strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
707 michael 3110
708     sendto_one_notice(source_p, &me, ":2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
709     glp_ptr->vote_2.oper_nick,
710     glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
711     glp_ptr->vote_2.oper_server, timebuffer,
712     glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
713 adx 30 }
714     }
715    
716 michael 3110 sendto_one_notice(source_p, &me, ":End of Pending G-lines");
717 michael 958
718 michael 3246 if (dlink_list_length(&pending_glines[GLINE_PENDING_DEL_TYPE]))
719 michael 3110 sendto_one_notice(source_p, &me, ":Pending UNG-lines");
720 michael 958
721     DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_DEL_TYPE].head)
722     {
723     glp_ptr = dn_ptr->data;
724     tmptr = localtime(&glp_ptr->vote_1.time_request);
725     strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
726    
727 michael 3110 sendto_one_notice(source_p, &me, ":1) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
728     glp_ptr->vote_1.oper_nick,
729     glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
730     glp_ptr->vote_1.oper_server, timebuffer,
731     glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
732 michael 958
733 michael 3246 if (glp_ptr->vote_2.oper_nick[0])
734 michael 958 {
735     tmptr = localtime(&glp_ptr->vote_2.time_request);
736     strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
737    
738 michael 3110 sendto_one_notice(source_p, &me, ":2) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
739     glp_ptr->vote_2.oper_nick,
740     glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
741     glp_ptr->vote_2.oper_server, timebuffer,
742     glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
743    
744 michael 958 }
745     }
746    
747 michael 3110 sendto_one_notice(source_p, &me, ":End of Pending UNG-lines");
748 adx 30 }
749    
750     /* stats_glines()
751     *
752     * input - client pointer
753     * output - none
754     * side effects - client is shown list of glines
755     */
756     static void
757 michael 1457 stats_glines(struct Client *source_p, int parc, char *parv[])
758 adx 30 {
759 michael 1367 dlink_node *ptr = NULL;
760 adx 30
761     if (!ConfigFileEntry.glines)
762     {
763 michael 3110 sendto_one_notice(source_p, &me, ":This server does not support G-Lines");
764 adx 30 return;
765     }
766    
767 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
768 adx 30 {
769 michael 1367 DLINK_FOREACH(ptr, atable[i].head)
770 adx 30 {
771 michael 1376 const struct AddressRec *arec = ptr->data;
772 michael 1367
773 adx 30 if (arec->type == CONF_GLINE)
774     {
775 michael 1632 const struct MaskItem *conf = arec->conf;
776 adx 30
777 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, 'G',
778     conf->host ? conf->host : "*",
779     conf->user ? conf->user : "*",
780     conf->reason ? conf->reason : CONF_NOREASON);
781    
782 adx 30 }
783     }
784     }
785     }
786    
787     static void
788 michael 1457 stats_hubleaf(struct Client *source_p, int parc, char *parv[])
789 adx 30 {
790 michael 2118 const dlink_node *ptr = NULL, *dptr = NULL;
791    
792     DLINK_FOREACH(ptr, server_items.head)
793     {
794     const struct MaskItem *conf = ptr->data;
795    
796     DLINK_FOREACH(dptr, conf->hub_list.head)
797 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSHLINE, 'H', dptr->data, conf->name, 0, "*");
798 michael 2118 }
799    
800     DLINK_FOREACH(ptr, server_items.head)
801     {
802     const struct MaskItem *conf = ptr->data;
803    
804     DLINK_FOREACH(dptr, conf->leaf_list.head)
805 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLLINE, 'L', dptr->data, conf->name, 0, "*");
806 michael 2118 }
807 adx 30 }
808    
809 michael 1372 /*
810     * show_iline_prefix()
811     *
812     * inputs - pointer to struct Client requesting output
813 michael 2820 * - pointer to struct MaskItem
814 michael 1372 * - name to which iline prefix will be prefixed to
815     * output - pointer to static string with prefixes listed in ascii form
816     * side effects - NONE
817     */
818     static const char *
819 michael 1632 show_iline_prefix(const struct Client *sptr, const struct MaskItem *conf)
820 michael 1372 {
821 michael 1715 static char prefix_of_host[USERLEN + 15];
822 michael 1372 char *prefix_ptr = prefix_of_host;
823    
824 michael 1715 if (IsConfWebIRC(conf))
825     *prefix_ptr++ = '<';
826 michael 1632 if (IsNoTilde(conf))
827 michael 1372 *prefix_ptr++ = '-';
828 michael 1632 if (IsNeedIdentd(conf))
829 michael 1372 *prefix_ptr++ = '+';
830 michael 1632 if (!IsNeedPassword(conf))
831 michael 1372 *prefix_ptr++ = '&';
832 michael 1632 if (IsConfExemptResv(conf))
833 michael 1372 *prefix_ptr++ = '$';
834 michael 1632 if (IsConfDoSpoofIp(conf))
835 michael 1372 *prefix_ptr++ = '=';
836 michael 1632 if (MyOper(sptr) && IsConfExemptKline(conf))
837 michael 1372 *prefix_ptr++ = '^';
838 michael 1632 if (MyOper(sptr) && IsConfExemptGline(conf))
839 michael 1372 *prefix_ptr++ = '_';
840 michael 1632 if (MyOper(sptr) && IsConfExemptLimits(conf))
841 michael 1372 *prefix_ptr++ = '>';
842 michael 1632 if (IsConfCanFlood(conf))
843 michael 1372 *prefix_ptr++ = '|';
844    
845 michael 1632 strlcpy(prefix_ptr, conf->user, USERLEN+1);
846 michael 1372
847     return prefix_of_host;
848     }
849    
850 adx 30 static void
851 michael 3156 report_auth(struct Client *source_p, int parc, char *parv[])
852 michael 1372 {
853 michael 1632 struct MaskItem *conf = NULL;
854 michael 1372 dlink_node *ptr = NULL;
855    
856 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
857 michael 1372 {
858     DLINK_FOREACH(ptr, atable[i].head)
859     {
860     struct AddressRec *arec = ptr->data;
861    
862 michael 1632 if (arec->type != CONF_CLIENT)
863     continue;
864 michael 1372
865 michael 1632 conf = arec->conf;
866 michael 1372
867 michael 3156 if (!MyOper(source_p) && IsConfDoSpoofIp(conf))
868 michael 1632 continue;
869 michael 1372
870 michael 1632 /* We are doing a partial list, based on what matches the u@h of the
871     * sender, so prepare the strings for comparing --fl_
872     */
873     if (ConfigFileEntry.hide_spoof_ips)
874 michael 3156 sendto_one_numeric(source_p, &me, RPL_STATSILINE, 'I',
875 michael 3109 conf->name == NULL ? "*" : conf->name,
876 michael 3156 show_iline_prefix(source_p, conf),
877 michael 3109 IsConfDoSpoofIp(conf) ? "255.255.255.255" :
878     conf->host, conf->port,
879     conf->class ? conf->class->name : "<default>");
880 michael 1372
881 michael 1632 else
882 michael 3156 sendto_one_numeric(source_p, &me, RPL_STATSILINE, 'I',
883 michael 3109 conf->name == NULL ? "*" : conf->name,
884 michael 3156 show_iline_prefix(source_p, conf),
885 michael 3109 conf->host, conf->port,
886     conf->class ? conf->class->name : "<default>");
887 michael 1372 }
888     }
889     }
890    
891     static void
892 michael 1457 stats_auth(struct Client *source_p, int parc, char *parv[])
893 adx 30 {
894     /* Oper only, if unopered, return ERR_NOPRIVILEGES */
895 michael 1219 if ((ConfigFileEntry.stats_i_oper_only == 2) && !HasUMode(source_p, UMODE_OPER))
896 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
897 adx 30
898     /* If unopered, Only return matching auth blocks */
899 michael 1219 else if ((ConfigFileEntry.stats_i_oper_only == 1) && !HasUMode(source_p, UMODE_OPER))
900 adx 30 {
901 michael 1632 struct MaskItem *conf;
902 adx 30
903     if (MyConnect(source_p))
904 michael 1632 conf = find_conf_by_address(source_p->host,
905 michael 2820 &source_p->localClient->ip, CONF_CLIENT,
906     source_p->localClient->aftype,
907     source_p->username,
908     source_p->localClient->passwd, 1);
909 adx 30 else
910 michael 1632 conf = find_conf_by_address(source_p->host, NULL, CONF_CLIENT,
911 michael 1371 0, source_p->username, NULL, 1);
912 adx 30
913 michael 1632 if (conf == NULL)
914 adx 30 return;
915    
916 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSILINE,
917     'I', "*", show_iline_prefix(source_p, conf),
918     conf->host, conf->port,
919     conf->class ? conf->class->name : "<default>");
920 adx 30 }
921     /* They are opered, or allowed to see all auth blocks */
922     else
923 michael 1457 report_auth(source_p, 0, NULL);
924 adx 30 }
925    
926 michael 1372 /* report_Klines()
927     * Inputs: Client to report to,
928     * type(==0 for perm, !=0 for temporary)
929 michael 2820 * mask
930 michael 1372 * Output: None
931 michael 3156 * Side effects: Reports configured K(or k)-lines to source_p.
932 michael 1372 */
933 adx 30 static void
934 michael 3156 report_Klines(struct Client *source_p, int tkline)
935 michael 1372 {
936 michael 1632 struct MaskItem *conf = NULL;
937 michael 3246 dlink_node *ptr = NULL;
938 michael 1921 char c = '\0';
939 michael 1372
940     if (tkline)
941 michael 1921 c = 'k';
942 michael 1372 else
943 michael 1921 c = 'K';
944 michael 1372
945 michael 3246 for (unsigned int i = 0; i < ATABLE_SIZE; ++i)
946 michael 1372 {
947     DLINK_FOREACH(ptr, atable[i].head)
948     {
949     struct AddressRec *arec = ptr->data;
950    
951 michael 1632 if (arec->type != CONF_KLINE)
952     continue;
953 michael 1628
954 michael 1632 conf = arec->conf;
955 michael 1372
956 michael 1650 if ((!tkline && conf->until) ||
957     (tkline && !conf->until))
958 michael 1632 continue;
959    
960 michael 3156 if (HasUMode(source_p, UMODE_OPER))
961     sendto_one_numeric(source_p, &me, RPL_STATSKLINE, c, conf->host, conf->user,
962 michael 3109 conf->reason);
963 michael 1632 else
964 michael 3156 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, c, conf->host, conf->user,
965 michael 3109 conf->reason);
966 michael 1372 }
967     }
968     }
969    
970     static void
971 michael 1457 stats_tklines(struct Client *source_p, int parc, char *parv[])
972 adx 30 {
973     /* Oper only, if unopered, return ERR_NOPRIVILEGES */
974 michael 1219 if ((ConfigFileEntry.stats_k_oper_only == 2) && !HasUMode(source_p, UMODE_OPER))
975 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
976 adx 30
977     /* If unopered, Only return matching klines */
978 michael 1219 else if ((ConfigFileEntry.stats_k_oper_only == 1) && !HasUMode(source_p, UMODE_OPER))
979 adx 30 {
980 michael 1632 struct MaskItem *conf = NULL;
981 adx 30
982     if (MyConnect(source_p))
983 michael 1632 conf = find_conf_by_address(source_p->host,
984 michael 2820 &source_p->localClient->ip, CONF_KLINE,
985     source_p->localClient->aftype,
986     source_p->username, NULL, 1);
987 adx 30 else
988 michael 1632 conf = find_conf_by_address(source_p->host, NULL, CONF_KLINE,
989 michael 1371 0, source_p->username, NULL, 1);
990 adx 30
991 michael 1632 if (!conf)
992 adx 30 return;
993    
994     /* dont report a permanent kline as a tkline */
995 michael 1649 if (!conf->until)
996 adx 30 return;
997    
998 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, 'k',
999     conf->host, conf->user, conf->reason);
1000 adx 30 }
1001     /* Theyre opered, or allowed to see all klines */
1002     else {
1003     report_Klines(source_p, 1);
1004     }
1005     }
1006    
1007     static void
1008 michael 1457 stats_klines(struct Client *source_p, int parc, char *parv[])
1009 adx 30 {
1010     /* Oper only, if unopered, return ERR_NOPRIVILEGES */
1011 michael 1219 if ((ConfigFileEntry.stats_k_oper_only == 2) && !HasUMode(source_p, UMODE_OPER))
1012 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1013 adx 30
1014     /* If unopered, Only return matching klines */
1015 michael 1219 else if ((ConfigFileEntry.stats_k_oper_only == 1) && !HasUMode(source_p, UMODE_OPER))
1016 adx 30 {
1017 michael 1632 struct MaskItem *conf = NULL;
1018 adx 30
1019     /* search for a kline */
1020 michael 560 if (MyConnect(source_p))
1021 michael 1632 conf = find_conf_by_address(source_p->host,
1022 michael 2820 &source_p->localClient->ip, CONF_KLINE,
1023     source_p->localClient->aftype,
1024     source_p->username, NULL, 0);
1025 adx 30 else
1026 michael 1632 conf = find_conf_by_address(source_p->host, NULL, CONF_KLINE,
1027 michael 1371 0, source_p->username, NULL, 0);
1028 adx 30
1029 michael 1632 if (!conf)
1030 adx 30 return;
1031    
1032     /* dont report a tkline as a kline */
1033 michael 1649 if (conf->until)
1034 adx 30 return;
1035 michael 2820
1036 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSKLINE, 'K',
1037     conf->host, conf->user, conf->reason);
1038 adx 30 }
1039     /* Theyre opered, or allowed to see all klines */
1040 michael 1921 else
1041 adx 30 report_Klines(source_p, 0);
1042     }
1043    
1044     static void
1045 michael 1457 stats_messages(struct Client *source_p, int parc, char *parv[])
1046 adx 30 {
1047     report_messages(source_p);
1048     }
1049    
1050     static void
1051 michael 1457 stats_oper(struct Client *source_p, int parc, char *parv[])
1052 adx 30 {
1053 michael 1219 if (!HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.stats_o_oper_only)
1054 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1055 adx 30 else
1056 michael 1632 report_confitem_types(source_p, CONF_OPER);
1057 adx 30 }
1058    
1059     /* stats_operedup()
1060     *
1061     * input - client pointer
1062     * output - none
1063     * side effects - client is shown a list of active opers
1064     */
1065     static void
1066 michael 1457 stats_operedup(struct Client *source_p, int parc, char *parv[])
1067 adx 30 {
1068 michael 3114 dlink_node *ptr = NULL;
1069 michael 3511 unsigned int opercount = 0;
1070 michael 3516 char buf[IRCD_BUFSIZE] = "";
1071 adx 30
1072     DLINK_FOREACH(ptr, oper_list.head)
1073     {
1074     const struct Client *target_p = ptr->data;
1075    
1076 michael 1294 if (HasUMode(target_p, UMODE_HIDDEN) && !HasUMode(source_p, UMODE_OPER))
1077 adx 30 continue;
1078    
1079 michael 3516 if (HasUMode(source_p, UMODE_OPER) || !HasUMode(target_p, UMODE_HIDEIDLE))
1080     snprintf(buf, sizeof(buf), "%u", idle_time_get(source_p, target_p));
1081     else
1082     strlcpy(buf, "n/a", sizeof(buf));
1083    
1084 michael 1219 if (MyClient(source_p) && HasUMode(source_p, UMODE_OPER))
1085 michael 3516 sendto_one(source_p, ":%s %d %s p :[%c][%s] %s (%s@%s) Idle: %s",
1086 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1087 michael 1294 HasUMode(target_p, UMODE_ADMIN) ? 'A' : 'O',
1088 michael 2820 oper_privs_as_string(target_p->localClient->operflags),
1089 michael 3516 target_p->name, target_p->username, target_p->host, buf);
1090 adx 30 else
1091 michael 3516 sendto_one(source_p, ":%s %d %s p :[%c] %s (%s@%s) Idle: %s",
1092 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1093 michael 1294 HasUMode(target_p, UMODE_ADMIN) ? 'A' : 'O',
1094 michael 3516 target_p->name, target_p->username, target_p->host, buf);
1095 michael 3511 ++opercount;
1096 adx 30 }
1097    
1098 michael 1759 sendto_one(source_p, ":%s %d %s p :%u OPER(s)",
1099 michael 3511 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p), opercount);
1100 adx 30 }
1101    
1102     static void
1103 michael 1457 stats_ports(struct Client *source_p, int parc, char *parv[])
1104 adx 30 {
1105 michael 1219 if (!HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.stats_P_oper_only)
1106 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1107 adx 30 else
1108     show_ports(source_p);
1109     }
1110    
1111     static void
1112 michael 1457 stats_resv(struct Client *source_p, int parc, char *parv[])
1113 adx 30 {
1114     report_resv(source_p);
1115     }
1116    
1117     static void
1118 michael 1457 stats_service(struct Client *source_p, int parc, char *parv[])
1119 adx 30 {
1120 michael 1632 report_confitem_types(source_p, CONF_SERVICE);
1121 michael 1175 }
1122    
1123     static void
1124 michael 1457 stats_tstats(struct Client *source_p, int parc, char *parv[])
1125 adx 30 {
1126 michael 896 const struct Client *target_p = NULL;
1127     const dlink_node *ptr = NULL;
1128     struct ServerStatistics tmp;
1129 michael 1842 struct ServerStatistics *sp = &tmp;
1130 michael 896
1131     memcpy(sp, &ServerStats, sizeof(struct ServerStatistics));
1132    
1133     /*
1134     * must use the += operator. is_sv is not the number of currently
1135     * active server connections. Note the incrementation in
1136     * s_bsd.c:close_connection.
1137     */
1138     sp->is_sv += dlink_list_length(&serv_list);
1139    
1140     DLINK_FOREACH(ptr, serv_list.head)
1141     {
1142     target_p = ptr->data;
1143    
1144     sp->is_sbs += target_p->localClient->send.bytes;
1145     sp->is_sbr += target_p->localClient->recv.bytes;
1146 michael 1241 sp->is_sti += CurrentTime - target_p->localClient->firsttime;
1147 michael 896 }
1148    
1149     sp->is_cl += dlink_list_length(&local_client_list);
1150    
1151     DLINK_FOREACH(ptr, local_client_list.head)
1152     {
1153     target_p = ptr->data;
1154    
1155     sp->is_cbs += target_p->localClient->send.bytes;
1156     sp->is_cbr += target_p->localClient->recv.bytes;
1157 michael 1241 sp->is_cti += CurrentTime - target_p->localClient->firsttime;
1158 michael 896 }
1159    
1160     sp->is_ni += dlink_list_length(&unknown_list);
1161    
1162     sendto_one(source_p, ":%s %d %s T :accepts %u refused %u",
1163     me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
1164     sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u",
1165     me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
1166     sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u",
1167     me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
1168     sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u",
1169     me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
1170     sendto_one(source_p, ":%s %d %s T :numerics seen %u",
1171     me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
1172     sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u",
1173     me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
1174     sendto_one(source_p, ":%s %d %s T :Client Server",
1175     me.name, RPL_STATSDEBUG, source_p->name);
1176    
1177     sendto_one(source_p, ":%s %d %s T :connected %u %u",
1178     me.name, RPL_STATSDEBUG, source_p->name,
1179     (unsigned int)sp->is_cl,
1180     (unsigned int)sp->is_sv);
1181     sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu",
1182     me.name, RPL_STATSDEBUG, source_p->name,
1183     sp->is_cbs, sp->is_sbs);
1184     sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu",
1185     me.name, RPL_STATSDEBUG, source_p->name,
1186     sp->is_cbr, sp->is_sbr);
1187     sendto_one(source_p, ":%s %d %s T :time connected %u %u",
1188     me.name, RPL_STATSDEBUG, source_p->name,
1189     (unsigned int)sp->is_cti,
1190     (unsigned int)sp->is_sti);
1191 adx 30 }
1192    
1193     static void
1194 michael 1457 stats_uptime(struct Client *source_p, int parc, char *parv[])
1195 adx 30 {
1196 michael 2270 if (!HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.stats_u_oper_only)
1197 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1198 michael 2269 else
1199     {
1200     time_t now = CurrentTime - me.localClient->since;
1201 michael 1148
1202 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSUPTIME, now / 86400,
1203     (now / 3600) % 24, (now / 60) % 60, now % 60);
1204 michael 1148
1205 michael 2269 if (!ConfigServerHide.disable_remote_commands || HasUMode(source_p, UMODE_OPER))
1206 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con,
1207     Count.max_loc_cli, Count.totalrestartcount);
1208 michael 2269 }
1209 adx 30 }
1210    
1211     static void
1212 michael 1457 stats_shared(struct Client *source_p, int parc, char *parv[])
1213 adx 30 {
1214 michael 1632 report_confitem_types(source_p, CONF_ULINE);
1215 adx 30 }
1216    
1217     /* stats_servers()
1218     *
1219     * input - client pointer
1220     * output - none
1221     * side effects - client is shown lists of who connected servers
1222     */
1223     static void
1224 michael 1457 stats_servers(struct Client *source_p, int parc, char *parv[])
1225 adx 30 {
1226 michael 1127 dlink_node *ptr = NULL;
1227 adx 30
1228     DLINK_FOREACH(ptr, serv_list.head)
1229     {
1230 michael 1127 const struct Client *target_p = ptr->data;
1231 adx 30
1232     sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d",
1233 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG,
1234     ID_or_name(source_p, source_p), target_p->name,
1235 michael 1127 (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1236 michael 1241 "*", "*", (int)(CurrentTime - target_p->localClient->lasttime));
1237 adx 30 }
1238    
1239 michael 3114 sendto_one(source_p, ":%s %d %s v :%u Server(s)", ID_or_name(&me, source_p),
1240     RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1241     dlink_list_length(&serv_list));
1242 adx 30 }
1243    
1244     static void
1245 michael 1457 stats_gecos(struct Client *source_p, int parc, char *parv[])
1246 adx 30 {
1247 michael 1632 report_confitem_types(source_p, CONF_XLINE);
1248 adx 30 }
1249    
1250     static void
1251 michael 1457 stats_class(struct Client *source_p, int parc, char *parv[])
1252 adx 30 {
1253 michael 2116 const dlink_node *ptr = NULL;
1254    
1255     DLINK_FOREACH(ptr, class_get_list()->head)
1256     {
1257     const struct ClassItem *class = ptr->data;
1258    
1259 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSYLINE, 'Y',
1260     class->name, class->ping_freq,
1261     class->con_freq,
1262     class->max_total, class->max_sendq,
1263     class->max_recvq,
1264     class->ref_count,
1265     class->number_per_cidr, class->cidr_bitlen_ipv4,
1266     class->number_per_cidr, class->cidr_bitlen_ipv6,
1267     class->active ? "active" : "disabled");
1268 michael 2116 }
1269 adx 30 }
1270    
1271     static void
1272 michael 1457 stats_servlinks(struct Client *source_p, int parc, char *parv[])
1273 adx 30 {
1274     uint64_t sendB = 0, recvB = 0;
1275     time_t uptime = 0;
1276 michael 560 dlink_node *ptr = NULL;
1277 adx 30
1278 michael 1219 if (ConfigServerHide.flatten_links && !HasUMode(source_p, UMODE_OPER))
1279 adx 30 {
1280 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1281 adx 30 return;
1282     }
1283    
1284     DLINK_FOREACH(ptr, serv_list.head)
1285     {
1286 michael 560 struct Client *target_p = ptr->data;
1287 adx 30
1288 michael 1851 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
1289     if (!HasUMode(source_p, UMODE_OPER))
1290     continue;
1291    
1292 adx 30 sendB += target_p->localClient->send.bytes;
1293     recvB += target_p->localClient->recv.bytes;
1294    
1295     /* ":%s 211 %s %s %u %u %llu %u %llu :%u %u %s" */
1296 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1297 michael 1219 get_client_name(target_p, HasUMode(source_p, UMODE_ADMIN) ? SHOW_IP : MASK_IP),
1298 adx 30 dbuf_length(&target_p->localClient->buf_sendq),
1299     target_p->localClient->send.messages,
1300     target_p->localClient->send.bytes >> 10,
1301     target_p->localClient->recv.messages,
1302     target_p->localClient->recv.bytes >> 10,
1303 michael 1241 (unsigned)(CurrentTime - target_p->localClient->firsttime),
1304     (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since): 0,
1305 michael 1219 HasUMode(source_p, UMODE_OPER) ? show_capabilities(target_p) : "TS");
1306 adx 30 }
1307    
1308     sendB >>= 10;
1309     recvB >>= 10;
1310    
1311     sendto_one(source_p, ":%s %d %s ? :%u total server(s)",
1312 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p), dlink_list_length(&serv_list));
1313 michael 3227 sendto_one(source_p, ":%s %d %s ? :Sent total: %7.2f %s",
1314 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1315 michael 560 _GMKv(sendB), _GMKs(sendB));
1316 michael 3227 sendto_one(source_p, ":%s %d %s ? :Recv total: %7.2f %s",
1317 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1318 michael 560 _GMKv(recvB), _GMKs(recvB));
1319 adx 30
1320 michael 1241 uptime = (CurrentTime - me.localClient->since);
1321 adx 30
1322     sendto_one(source_p, ":%s %d %s ? :Server send: %7.2f %s (%4.1f K/s)",
1323 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1324 michael 560 _GMKv((me.localClient->send.bytes>>10)),
1325     _GMKs((me.localClient->send.bytes>>10)),
1326     (float)((float)((me.localClient->send.bytes) >> 10) /
1327     (float)uptime));
1328 adx 30 sendto_one(source_p, ":%s %d %s ? :Server recv: %7.2f %s (%4.1f K/s)",
1329 michael 3114 ID_or_name(&me, source_p), RPL_STATSDEBUG, ID_or_name(source_p, source_p),
1330 michael 560 _GMKv((me.localClient->recv.bytes>>10)),
1331     _GMKs((me.localClient->recv.bytes>>10)),
1332     (float)((float)((me.localClient->recv.bytes) >> 10) /
1333     (float)uptime));
1334 adx 30 }
1335    
1336 michael 1457 /* parse_stats_args()
1337     *
1338     * inputs - arg count
1339     * - args
1340     * - doall flag
1341     * - wild card or not
1342     * output - pointer to name to use
1343     * side effects -
1344     * common parse routine for m_stats args
1345 michael 2820 *
1346 michael 1457 */
1347     static char *
1348 michael 3114 parse_stats_args(struct Client *source_p, int parc, char *parv[], int *doall, int *wilds)
1349 adx 30 {
1350 michael 1457 char *name;
1351 adx 30
1352 michael 1457 if (parc > 2)
1353 adx 30 {
1354 michael 1457 name = parv[2];
1355 adx 30
1356 michael 3114 if (!irccmp(name, ID_or_name(&me, source_p)))
1357 michael 1457 *doall = 2;
1358 michael 3114 else if (!match(name, ID_or_name(&me, source_p)))
1359 michael 1457 *doall = 1;
1360    
1361     *wilds = has_wildcards(name);
1362    
1363     return name;
1364 adx 30 }
1365    
1366 michael 1457 return NULL;
1367 adx 30 }
1368    
1369     static void
1370 michael 3079 stats_L_list(struct Client *source_p, char *name, int doall, int wilds,
1371     dlink_list *list, char statchar)
1372 adx 30 {
1373     dlink_node *ptr;
1374     struct Client *target_p;
1375    
1376     /*
1377     * send info about connections which match, or all if the
1378     * mask matches from. Only restrictions are on those who
1379     * are invisible not being visible to 'foreigners' who use
1380     * a wild card based search to list it.
1381     */
1382     DLINK_FOREACH(ptr, list->head)
1383     {
1384     target_p = ptr->data;
1385    
1386 michael 1219 if (HasUMode(target_p, UMODE_INVISIBLE) && (doall || wilds) &&
1387 michael 1457 !(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) &&
1388     !HasUMode(target_p, UMODE_OPER) && (target_p != source_p))
1389 adx 30 continue;
1390 michael 1652 if (!doall && wilds && match(name, target_p->name))
1391 adx 30 continue;
1392     if (!(doall || wilds) && irccmp(name, target_p->name))
1393     continue;
1394    
1395     /* This basically shows ips for our opers if its not a server/admin, or
1396     * its one of our admins. */
1397 michael 1457 if(MyClient(source_p) && HasUMode(source_p, UMODE_OPER) &&
1398 michael 1219 (HasUMode(source_p, UMODE_ADMIN) ||
1399 michael 1457 (!IsServer(target_p) && !HasUMode(target_p, UMODE_ADMIN) &&
1400 adx 30 !IsHandshake(target_p) && !IsConnecting(target_p))))
1401     {
1402 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1403 adx 30 (IsUpper(statchar)) ?
1404     get_client_name(target_p, SHOW_IP) :
1405     get_client_name(target_p, HIDE_IP),
1406     dbuf_length(&target_p->localClient->buf_sendq),
1407     target_p->localClient->send.messages,
1408     target_p->localClient->send.bytes>>10,
1409     target_p->localClient->recv.messages,
1410     target_p->localClient->recv.bytes>>10,
1411 michael 1241 (unsigned)(CurrentTime - target_p->localClient->firsttime),
1412     (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since):0,
1413 adx 30 IsServer(target_p) ? show_capabilities(target_p) : "-");
1414     }
1415     else
1416     {
1417     /* If its a hidden ip, an admin, or a server, mask the real IP */
1418 michael 1219 if(IsIPSpoof(target_p) || IsServer(target_p) || HasUMode(target_p, UMODE_ADMIN)
1419 adx 30 || IsHandshake(target_p) || IsConnecting(target_p))
1420 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1421 michael 1457 get_client_name(target_p, MASK_IP),
1422     dbuf_length(&target_p->localClient->buf_sendq),
1423     target_p->localClient->send.messages,
1424     target_p->localClient->send.bytes>>10,
1425     target_p->localClient->recv.messages,
1426     target_p->localClient->recv.bytes>>10,
1427     (unsigned)(CurrentTime - target_p->localClient->firsttime),
1428     (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since):0,
1429     IsServer(target_p) ? show_capabilities(target_p) : "-");
1430 adx 30 else /* show the real IP */
1431 michael 3109 sendto_one_numeric(source_p, &me, RPL_STATSLINKINFO,
1432 michael 1457 (IsUpper(statchar)) ?
1433     get_client_name(target_p, SHOW_IP) :
1434     get_client_name(target_p, HIDE_IP),
1435     dbuf_length(&target_p->localClient->buf_sendq),
1436     target_p->localClient->send.messages,
1437     target_p->localClient->send.bytes>>10,
1438     target_p->localClient->recv.messages,
1439     target_p->localClient->recv.bytes>>10,
1440     (unsigned)(CurrentTime - target_p->localClient->firsttime),
1441     (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since):0,
1442     IsServer(target_p) ? show_capabilities(target_p) : "-");
1443 adx 30 }
1444     }
1445     }
1446    
1447 michael 1457 /*
1448     * stats_L
1449 adx 30 *
1450 michael 1457 * inputs - pointer to client to report to
1451     * - doall flag
1452     * - wild card or not
1453     * output - NONE
1454     * side effects -
1455     */
1456     static void
1457 michael 3079 stats_L(struct Client *source_p, char *name,int doall,
1458     int wilds, char statchar)
1459 michael 1457 {
1460     stats_L_list(source_p, name, doall, wilds, &unknown_list, statchar);
1461     stats_L_list(source_p, name, doall, wilds, &local_client_list, statchar);
1462     stats_L_list(source_p, name, doall, wilds, &serv_list, statchar);
1463     }
1464    
1465     static void
1466     stats_ltrace(struct Client *source_p, int parc, char *parv[])
1467     {
1468     int doall = 0;
1469     int wilds = 0;
1470     char *name = NULL;
1471     char statchar;
1472    
1473 michael 3246 if ((name = parse_stats_args(source_p, parc, parv, &doall, &wilds)))
1474 michael 1457 {
1475 michael 3246 statchar = *parv[1];
1476 michael 1457 stats_L(source_p, name, doall, wilds, statchar);
1477     }
1478     else
1479 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "STATS");
1480 michael 1457 }
1481    
1482     static const struct StatsStruct
1483     {
1484     const unsigned char letter;
1485     void (*handler)();
1486     const unsigned int need_oper;
1487     const unsigned int need_admin;
1488     } stats_cmd_table[] = {
1489     /* letter function need_oper need_admin */
1490     { 'a', stats_dns_servers, 1, 1 },
1491     { 'A', stats_dns_servers, 1, 1 },
1492     { 'c', stats_connect, 1, 0 },
1493     { 'C', stats_connect, 1, 0 },
1494     { 'd', stats_tdeny, 1, 0 },
1495     { 'D', stats_deny, 1, 0 },
1496     { 'e', stats_exempt, 1, 0 },
1497     { 'E', stats_events, 1, 1 },
1498     { 'f', fd_dump, 1, 1 },
1499     { 'F', fd_dump, 1, 1 },
1500     { 'g', stats_pending_glines, 1, 0 },
1501     { 'G', stats_glines, 1, 0 },
1502     { 'h', stats_hooks, 1, 1 },
1503     { 'H', stats_hubleaf, 1, 0 },
1504     { 'i', stats_auth, 0, 0 },
1505     { 'I', stats_auth, 0, 0 },
1506     { 'k', stats_tklines, 0, 0 },
1507     { 'K', stats_klines, 0, 0 },
1508     { 'l', stats_ltrace, 1, 0 },
1509     { 'L', stats_ltrace, 1, 0 },
1510     { 'm', stats_messages, 0, 0 },
1511     { 'M', stats_messages, 0, 0 },
1512     { 'o', stats_oper, 0, 0 },
1513     { 'O', stats_oper, 0, 0 },
1514     { 'p', stats_operedup, 0, 0 },
1515     { 'P', stats_ports, 0, 0 },
1516     { 'q', stats_resv, 1, 0 },
1517     { 'Q', stats_resv, 1, 0 },
1518     { 'r', stats_usage, 1, 0 },
1519     { 'R', stats_usage, 1, 0 },
1520 michael 1875 { 's', stats_service, 1, 0 },
1521 michael 1457 { 'S', stats_service, 1, 0 },
1522     { 't', stats_tstats, 1, 0 },
1523 michael 2150 { 'T', motd_report, 1, 0 },
1524 michael 1457 { 'u', stats_uptime, 0, 0 },
1525     { 'U', stats_shared, 1, 0 },
1526     { 'v', stats_servers, 1, 0 },
1527     { 'x', stats_gecos, 1, 0 },
1528     { 'X', stats_gecos, 1, 0 },
1529     { 'y', stats_class, 1, 0 },
1530     { 'Y', stats_class, 1, 0 },
1531     { 'z', stats_memory, 1, 0 },
1532     { '?', stats_servlinks, 0, 0 },
1533     { '\0', NULL, 0, 0 }
1534     };
1535    
1536     static void
1537     do_stats(struct Client *source_p, int parc, char *parv[])
1538     {
1539     const char statchar = *parv[1];
1540    
1541     if (statchar == '\0')
1542     {
1543 michael 3109 sendto_one_numeric(source_p, &me, RPL_ENDOFSTATS, '*');
1544 michael 1457 return;
1545     }
1546    
1547 michael 3283 for (const struct StatsStruct *tab = stats_cmd_table; tab->handler; ++tab)
1548 michael 1457 {
1549     if (tab->letter == statchar)
1550     {
1551     /* The stats table says what privs are needed, so check --fl_ */
1552     if ((tab->need_admin && !HasUMode(source_p, UMODE_ADMIN)) ||
1553     (tab->need_oper && !HasUMode(source_p, UMODE_OPER)))
1554     {
1555 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
1556 michael 1457 break;
1557     }
1558    
1559 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
1560 michael 1532 "STATS %c requested by %s (%s@%s) [%s]",
1561 michael 1457 statchar, source_p->name, source_p->username,
1562     source_p->host, source_p->servptr->name);
1563     tab->handler(source_p, parc, parv);
1564     break;
1565     }
1566     }
1567    
1568 michael 3109 sendto_one_numeric(source_p, &me, RPL_ENDOFSTATS, statchar);
1569 michael 1457 }
1570    
1571     /*
1572     * m_stats()
1573 michael 3096 * parv[0] = command
1574 michael 1457 * parv[1] = stat letter/command
1575     * parv[2] = (if present) server/mask in stats L
1576 adx 30 */
1577 michael 2820 static int
1578 michael 3156 m_stats(struct Client *source_p, int parc, char *parv[])
1579 adx 30 {
1580 michael 1457 static time_t last_used = 0;
1581 adx 30
1582 michael 1457 /* Check the user is actually allowed to do /stats, and isnt flooding */
1583     if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
1584     {
1585 michael 3109 sendto_one_numeric(source_p, &me, RPL_LOAD2HI);
1586 michael 2820 return 0;
1587 michael 1457 }
1588 adx 30
1589 michael 1457 last_used = CurrentTime;
1590 adx 30
1591 michael 2341 /* Is the stats meant for us? */
1592     if (!ConfigServerHide.disable_remote_commands)
1593 michael 3156 if (hunt_server(source_p, ":%s STATS %s :%s", 2,
1594 michael 2341 parc, parv) != HUNTED_ISME)
1595 michael 2820 return 0;
1596 michael 2341
1597 michael 1457 do_stats(source_p, parc, parv);
1598 michael 2820 return 0;
1599 michael 1457 }
1600    
1601     /*
1602 michael 3219 * ms_stats()
1603 michael 3096 * parv[0] = command
1604 michael 1457 * parv[1] = stat letter/command
1605     * parv[2] = (if present) server/mask in stats L, or target
1606     */
1607 michael 2820 static int
1608 michael 3219 ms_stats(struct Client *source_p, int parc, char *parv[])
1609 michael 1457 {
1610 michael 3156 if (hunt_server(source_p, ":%s STATS %s :%s", 2,
1611 michael 1457 parc, parv) != HUNTED_ISME)
1612 michael 2820 return 0;
1613 michael 1457
1614     do_stats(source_p, parc, parv);
1615 michael 2820 return 0;
1616 adx 30 }
1617 michael 1230
1618 michael 2820 static struct Message stats_msgtab =
1619     {
1620 michael 1230 "STATS", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
1621 michael 3219 { m_unregistered, m_stats, ms_stats, m_ignore, ms_stats, m_ignore }
1622 michael 1230 };
1623    
1624     static void
1625     module_init(void)
1626     {
1627     mod_add_cmd(&stats_msgtab);
1628     }
1629    
1630     static void
1631     module_exit(void)
1632     {
1633     mod_del_cmd(&stats_msgtab);
1634     }
1635    
1636 michael 2820 struct module module_entry =
1637     {
1638 michael 1230 .node = { NULL, NULL, NULL },
1639     .name = NULL,
1640     .version = "$Revision$",
1641     .handle = NULL,
1642     .modinit = module_init,
1643     .modexit = module_exit,
1644     .flags = 0
1645     };

Properties

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