ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_stats.c
Revision: 2116
Committed: Sun May 26 11:44:01 2013 UTC (13 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 54234 byte(s)
Log Message:
- Got rid of CONF_CLASS enum type

File Contents

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

Properties

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