]> jfr.im git - irc/rqf/shadowircd.git/blob - src/hostmask.c
comment to fix egd (not work currently)
[irc/rqf/shadowircd.git] / src / hostmask.c
1 /*
2 * charybdis: an advanced internet relay chat daemon (ircd).
3 * hostmask.c: Code to efficiently find IP & hostmask based configs.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 * Copyright (C) 2005-2008 charybdis development team
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * $Id: hostmask.c 2757 2006-11-10 22:58:15Z jilles $
26 */
27
28 #include "stdinc.h"
29 #include "ircd_defs.h"
30 #include "s_conf.h"
31 #include "hostmask.h"
32 #include "numeric.h"
33 #include "send.h"
34 #include "match.h"
35
36 #ifdef RB_IPV6
37 static unsigned long hash_ipv6(struct sockaddr *, int);
38 #endif
39 static unsigned long hash_ipv4(struct sockaddr *, int);
40
41
42 /* int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
43 * Input: A hostmask, or an IPV4/6 address.
44 * Output: An integer describing whether it is an IPV4, IPV6 address or a
45 * hostmask, an address(if it is an IP mask),
46 * a bitlength(if it is IP mask).
47 * Side effects: None
48 */
49 int
50 parse_netmask(const char *text, struct sockaddr *naddr, int *nb)
51 {
52 char *ip = LOCAL_COPY(text);
53 char *ptr;
54 struct rb_sockaddr_storage *addr, xaddr;
55 int *b, xb;
56 if(nb == NULL)
57 b = &xb;
58 else
59 b = nb;
60
61 if(naddr == NULL)
62 addr = (struct rb_sockaddr_storage *)&xaddr;
63 else
64 addr = (struct rb_sockaddr_storage *)naddr;
65
66 #ifdef RB_IPV6
67 if(strchr(ip, ':'))
68 {
69 if((ptr = strchr(ip, '/')))
70 {
71 *ptr = '\0';
72 ptr++;
73 *b = atoi(ptr);
74 if(*b > 128)
75 *b = 128;
76 } else
77 *b = 128;
78 if(rb_inet_pton_sock(ip, (struct sockaddr *)addr) > 0)
79 return HM_IPV6;
80 else
81 return HM_HOST;
82 } else
83 #endif
84 if(strchr(text, '.'))
85 {
86 if((ptr = strchr(ip, '/')))
87 {
88 *ptr = '\0';
89 ptr++;
90 *b = atoi(ptr);
91 if(*b > 32)
92 *b = 32;
93 } else
94 *b = 32;
95 if(rb_inet_pton_sock(ip, (struct sockaddr *)addr) > 0)
96 return HM_IPV4;
97 else
98 return HM_HOST;
99 }
100 return HM_HOST;
101 }
102
103 /* Hashtable stuff...now external as its used in m_stats.c */
104 struct AddressRec *atable[ATABLE_SIZE];
105
106 void
107 init_host_hash(void)
108 {
109 memset(&atable, 0, sizeof(atable));
110 }
111
112 /* unsigned long hash_ipv4(struct rb_sockaddr_storage*)
113 * Input: An IP address.
114 * Output: A hash value of the IP address.
115 * Side effects: None
116 */
117 static unsigned long
118 hash_ipv4(struct sockaddr *saddr, int bits)
119 {
120 struct sockaddr_in *addr = (struct sockaddr_in *) saddr;
121
122 if(bits != 0)
123 {
124 unsigned long av = ntohl(addr->sin_addr.s_addr) & ~((1 << (32 - bits)) - 1);
125 return (av ^ (av >> 12) ^ (av >> 24)) & (ATABLE_SIZE - 1);
126 }
127
128 return 0;
129 }
130
131 /* unsigned long hash_ipv6(struct rb_sockaddr_storage*)
132 * Input: An IP address.
133 * Output: A hash value of the IP address.
134 * Side effects: None
135 */
136 #ifdef RB_IPV6
137 static unsigned long
138 hash_ipv6(struct sockaddr *saddr, int bits)
139 {
140 struct sockaddr_in6 *addr = (struct sockaddr_in6 *) saddr;
141 unsigned long v = 0, n;
142 for (n = 0; n < 16; n++)
143 {
144 if(bits >= 8)
145 {
146 v ^= addr->sin6_addr.s6_addr[n];
147 bits -= 8;
148 }
149 else if(bits)
150 {
151 v ^= addr->sin6_addr.s6_addr[n] & ~((1 << (8 - bits)) - 1);
152 return v & (ATABLE_SIZE - 1);
153 }
154 else
155 return v & (ATABLE_SIZE - 1);
156 }
157 return v & (ATABLE_SIZE - 1);
158 }
159 #endif
160
161 /* int hash_text(const char *start)
162 * Input: The start of the text to hash.
163 * Output: The hash of the string between 1 and (TH_MAX-1)
164 * Side-effects: None.
165 */
166 static int
167 hash_text(const char *start)
168 {
169 const char *p = start;
170 unsigned long h = 0;
171
172 while(*p)
173 {
174 h = (h << 4) - (h + (unsigned char) ToLower(*p++));
175 }
176
177 return (h & (ATABLE_SIZE - 1));
178 }
179
180 /* unsigned long get_hash_mask(const char *)
181 * Input: The text to hash.
182 * Output: The hash of the string right of the first '.' past the last
183 * wildcard in the string.
184 * Side-effects: None.
185 */
186 static unsigned long
187 get_mask_hash(const char *text)
188 {
189 const char *hp = "", *p;
190
191 for (p = text + strlen(text) - 1; p >= text; p--)
192 if(*p == '*' || *p == '?')
193 return hash_text(hp);
194 else if(*p == '.')
195 hp = p + 1;
196 return hash_text(text);
197 }
198
199 /* struct ConfItem* find_conf_by_address(const char*, struct rb_sockaddr_storage*,
200 * int type, int fam, const char *username)
201 * Input: The hostname, the address, the type of mask to find, the address
202 * family, the username.
203 * Output: The matching value with the highest precedence.
204 * Side-effects: None
205 * Note: Setting bit 0 of the type means that the username is ignored.
206 */
207 struct ConfItem *
208 find_conf_by_address(const char *name, const char *sockhost,
209 const char *orighost,
210 struct sockaddr *addr, int type, int fam,
211 const char *username, const char *auth_user)
212 {
213 unsigned long hprecv = 0;
214 struct ConfItem *hprec = NULL;
215 struct AddressRec *arec;
216 int b;
217
218 if(username == NULL)
219 username = "";
220
221 if(addr)
222 {
223 /* Check for IPV6 matches... */
224 #ifdef RB_IPV6
225 if(fam == AF_INET6)
226 {
227
228 for (b = 128; b >= 0; b -= 16)
229 {
230 for (arec = atable[hash_ipv6(addr, b)]; arec; arec = arec->next)
231 if(arec->type == (type & ~0x1) &&
232 arec->masktype == HM_IPV6 &&
233 comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
234 arec->Mask.ipa.bits) &&
235 (type & 0x1 || match(arec-> username, username)) &&
236 (type != CONF_CLIENT || !arec->auth_user ||
237 (auth_user && match(arec->auth_user, auth_user))) &&
238 arec->precedence > hprecv)
239 {
240 hprecv = arec->precedence;
241 hprec = arec->aconf;
242 }
243 }
244 }
245 else
246 #endif
247 if(fam == AF_INET)
248 {
249 for (b = 32; b >= 0; b -= 8)
250 {
251 for (arec = atable[hash_ipv4(addr, b)]; arec; arec = arec->next)
252 if(arec->type == (type & ~0x1) &&
253 arec->masktype == HM_IPV4 &&
254 comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
255 arec->Mask.ipa.bits) &&
256 (type & 0x1 || match(arec->username, username)) &&
257 (type != CONF_CLIENT || !arec->auth_user ||
258 (auth_user && match(arec->auth_user, auth_user))) &&
259 arec->precedence > hprecv)
260 {
261 hprecv = arec->precedence;
262 hprec = arec->aconf;
263 }
264 }
265 }
266 }
267
268 if(orighost != NULL)
269 {
270 const char *p;
271
272 for (p = orighost; p != NULL;)
273 {
274 for (arec = atable[hash_text(p)]; arec; arec = arec->next)
275
276 if((arec->type == (type & ~0x1)) &&
277 (arec->masktype == HM_HOST) &&
278 arec->precedence > hprecv &&
279 match(arec->Mask.hostname, orighost) &&
280 (type != CONF_CLIENT || !arec->auth_user ||
281 (auth_user && match(arec->auth_user, auth_user))) &&
282 (type & 0x1 || match(arec->username, username)))
283 {
284 hprecv = arec->precedence;
285 hprec = arec->aconf;
286 }
287 p = strchr(p, '.');
288 if(p != NULL)
289 p++;
290 else
291 break;
292 }
293 for (arec = atable[0]; arec; arec = arec->next)
294 {
295 if(arec->type == (type & ~0x1) &&
296 arec->masktype == HM_HOST &&
297 arec->precedence > hprecv &&
298 (match(arec->Mask.hostname, orighost) ||
299 (sockhost && match(arec->Mask.hostname, sockhost))) &&
300 (type != CONF_CLIENT || !arec->auth_user ||
301 (auth_user && match(arec->auth_user, auth_user))) &&
302 (type & 0x1 || match(arec->username, username)))
303 {
304 hprecv = arec->precedence;
305 hprec = arec->aconf;
306 }
307 }
308 }
309
310 if(name != NULL)
311 {
312 const char *p;
313 /* And yes - we have to check p after strchr and p after increment for
314 * NULL -kre */
315 for (p = name; p != NULL;)
316 {
317 for (arec = atable[hash_text(p)]; arec; arec = arec->next)
318 if((arec->type == (type & ~0x1)) &&
319 (arec->masktype == HM_HOST) &&
320 arec->precedence > hprecv &&
321 match(arec->Mask.hostname, name) &&
322 (type != CONF_CLIENT || !arec->auth_user ||
323 (auth_user && match(arec->auth_user, auth_user))) &&
324 (type & 0x1 || match(arec->username, username)))
325 {
326 hprecv = arec->precedence;
327 hprec = arec->aconf;
328 }
329 p = strchr(p, '.');
330 if(p != NULL)
331 p++;
332 else
333 break;
334 }
335 for (arec = atable[0]; arec; arec = arec->next)
336 {
337 if(arec->type == (type & ~0x1) &&
338 arec->masktype == HM_HOST &&
339 arec->precedence > hprecv &&
340 (match(arec->Mask.hostname, name) ||
341 (sockhost && match(arec->Mask.hostname, sockhost))) &&
342 (type != CONF_CLIENT || !arec->auth_user ||
343 (auth_user && match(arec->auth_user, auth_user))) &&
344 (type & 0x1 || match(arec->username, username)))
345 {
346 hprecv = arec->precedence;
347 hprec = arec->aconf;
348 }
349 }
350 }
351 return hprec;
352 }
353
354 /* struct ConfItem* find_address_conf(const char*, const char*,
355 * struct rb_sockaddr_storage*, int);
356 * Input: The hostname, username, address, address family.
357 * Output: The applicable ConfItem.
358 * Side-effects: None
359 */
360 struct ConfItem *
361 find_address_conf(const char *host, const char *sockhost, const char *user,
362 const char *notildeuser, struct sockaddr *ip, int aftype, char *auth_user)
363 {
364 struct ConfItem *iconf, *kconf;
365 const char *vuser;
366
367 /* Find the best I-line... If none, return NULL -A1kmm */
368 if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user, auth_user)))
369 return NULL;
370 /* Find what their visible username will be.
371 * Note that the username without tilde may contain one char more.
372 * -- jilles */
373 vuser = IsNoTilde(iconf) ? notildeuser : user;
374
375 /* If they are exempt from K-lines, return the best I-line. -A1kmm */
376 if(IsConfExemptKline(iconf))
377 return iconf;
378
379 /* Find the best K-line... -A1kmm */
380 kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user, NULL);
381
382 /* If they are K-lined, return the K-line */
383 if(kconf)
384 return kconf;
385
386 /* if theres a spoof, check it against klines.. */
387 if(IsConfDoSpoofIp(iconf))
388 {
389 char *p = strchr(iconf->name, '@');
390
391 /* note, we dont need to pass sockhost here, as its
392 * guaranteed to not match by whats above.. --anfl
393 */
394 if(p)
395 {
396 *p = '\0';
397 kconf = find_conf_by_address(p+1, NULL, NULL, ip, CONF_KILL, aftype, iconf->name, NULL);
398 *p = '@';
399 }
400 else
401 kconf = find_conf_by_address(iconf->name, NULL, NULL, ip, CONF_KILL, aftype, vuser, NULL);
402
403 if(kconf)
404 return kconf;
405 }
406
407 /* if no_tilde, check the username without tilde against klines too
408 * -- jilles */
409 if(user != vuser)
410 {
411 kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser, NULL);
412 if(kconf)
413 return kconf;
414 }
415
416 return iconf;
417 }
418
419 /* struct ConfItem* find_dline(struct rb_sockaddr_storage*, int)
420 * Input: An address, an address family.
421 * Output: The best matching D-line or exempt line.
422 * Side effects: None.
423 */
424 struct ConfItem *
425 find_dline(struct sockaddr *addr, int aftype)
426 {
427 struct ConfItem *eline;
428 eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL, NULL);
429 if(eline)
430 return eline;
431 return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
432 }
433
434 /* void find_exact_conf_by_address(const char*, int, const char *)
435 * Input:
436 * Output: ConfItem if found
437 * Side-effects: None
438 */
439 struct ConfItem *
440 find_exact_conf_by_address(const char *address, int type, const char *username)
441 {
442 int masktype, bits;
443 unsigned long hv;
444 struct AddressRec *arec;
445 struct rb_sockaddr_storage addr;
446
447 if(address == NULL)
448 address = "/NOMATCH!/";
449 arec = rb_malloc(sizeof(struct AddressRec));
450 masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
451 #ifdef RB_IPV6
452 if(masktype == HM_IPV6)
453 {
454 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
455 hv = hash_ipv6((struct sockaddr *)&addr, bits - bits % 16);
456 }
457 else
458 #endif
459 if(masktype == HM_IPV4)
460 {
461 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
462 hv = hash_ipv4((struct sockaddr *)&addr, bits - bits % 8);
463 }
464 else
465 {
466 hv = get_mask_hash(address);
467 }
468 for (arec = atable[hv]; arec; arec = arec->next)
469 {
470 if (arec->type == type &&
471 arec->masktype == masktype &&
472 (arec->username == NULL || username == NULL ? arec->username == username : !irccmp(arec->username, username)))
473 {
474 if (masktype == HM_HOST)
475 {
476 if (!irccmp(arec->Mask.hostname, address))
477 return arec->aconf;
478 }
479 else
480 {
481 if (arec->Mask.ipa.bits == bits &&
482 comp_with_mask_sock((struct sockaddr *)&arec->Mask.ipa.addr, (struct sockaddr *)&addr, bits))
483 return arec->aconf;
484 }
485 }
486 }
487 return NULL;
488 }
489
490 /* void add_conf_by_address(const char*, int, const char *,
491 * struct ConfItem *aconf)
492 * Input:
493 * Output: None
494 * Side-effects: Adds this entry to the hash table.
495 */
496 void
497 add_conf_by_address(const char *address, int type, const char *username, const char *auth_user, struct ConfItem *aconf)
498 {
499 static unsigned long prec_value = 0xFFFFFFFF;
500 int masktype, bits;
501 unsigned long hv;
502 struct AddressRec *arec;
503
504 if(address == NULL)
505 address = "/NOMATCH!/";
506 arec = rb_malloc(sizeof(struct AddressRec));
507 masktype = parse_netmask(address, (struct sockaddr *)&arec->Mask.ipa.addr, &bits);
508 arec->Mask.ipa.bits = bits;
509 arec->masktype = masktype;
510 #ifdef RB_IPV6
511 if(masktype == HM_IPV6)
512 {
513 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
514 bits -= bits % 16;
515 arec->next = atable[(hv = hash_ipv6((struct sockaddr *)&arec->Mask.ipa.addr, bits))];
516 atable[hv] = arec;
517 }
518 else
519 #endif
520 if(masktype == HM_IPV4)
521 {
522 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
523 bits -= bits % 8;
524 arec->next = atable[(hv = hash_ipv4((struct sockaddr *)&arec->Mask.ipa.addr, bits))];
525 atable[hv] = arec;
526 }
527 else
528 {
529 arec->Mask.hostname = address;
530 arec->next = atable[(hv = get_mask_hash(address))];
531 atable[hv] = arec;
532 }
533 arec->username = username;
534 arec->auth_user = auth_user;
535 arec->aconf = aconf;
536 arec->precedence = prec_value--;
537 arec->type = type;
538 }
539
540 /* void delete_one_address(const char*, struct ConfItem*)
541 * Input: An address string, the associated ConfItem.
542 * Output: None
543 * Side effects: Deletes an address record. Frees the ConfItem if there
544 * is nothing referencing it, sets it as illegal otherwise.
545 */
546 void
547 delete_one_address_conf(const char *address, struct ConfItem *aconf)
548 {
549 int masktype, bits;
550 unsigned long hv;
551 struct AddressRec *arec, *arecl = NULL;
552 struct rb_sockaddr_storage addr;
553 masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
554 #ifdef RB_IPV6
555 if(masktype == HM_IPV6)
556 {
557 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
558 bits -= bits % 16;
559 hv = hash_ipv6((struct sockaddr *)&addr, bits);
560 }
561 else
562 #endif
563 if(masktype == HM_IPV4)
564 {
565 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
566 bits -= bits % 8;
567 hv = hash_ipv4((struct sockaddr *)&addr, bits);
568 }
569 else
570 hv = get_mask_hash(address);
571 for (arec = atable[hv]; arec; arec = arec->next)
572 {
573 if(arec->aconf == aconf)
574 {
575 if(arecl)
576 arecl->next = arec->next;
577 else
578 atable[hv] = arec->next;
579 aconf->status |= CONF_ILLEGAL;
580 if(!aconf->clients)
581 free_conf(aconf);
582 rb_free(arec);
583 return;
584 }
585 arecl = arec;
586 }
587 }
588
589 /* void clear_out_address_conf(void)
590 * Input: None
591 * Output: None
592 * Side effects: Clears out all address records in the hash table,
593 * frees them, and frees the ConfItems if nothing references
594 * them, otherwise sets them as illegal.
595 */
596 void
597 clear_out_address_conf(void)
598 {
599 int i;
600 struct AddressRec **store_next;
601 struct AddressRec *arec, *arecn;
602
603 for (i = 0; i < ATABLE_SIZE; i++)
604 {
605 store_next = &atable[i];
606 for (arec = atable[i]; arec; arec = arecn)
607 {
608 arecn = arec->next;
609 /* We keep the temporary K-lines and destroy the
610 * permanent ones, just to be confusing :) -A1kmm */
611 if(arec->aconf->flags & CONF_FLAGS_TEMPORARY ||
612 (arec->type != CONF_CLIENT && arec->type != CONF_EXEMPTDLINE))
613 {
614 *store_next = arec;
615 store_next = &arec->next;
616 }
617 else
618 {
619 arec->aconf->status |= CONF_ILLEGAL;
620 if(!arec->aconf->clients)
621 free_conf(arec->aconf);
622 rb_free(arec);
623 }
624 }
625 *store_next = NULL;
626 }
627 }
628
629 void
630 clear_out_address_conf_bans(void)
631 {
632 int i;
633 struct AddressRec **store_next;
634 struct AddressRec *arec, *arecn;
635
636 for (i = 0; i < ATABLE_SIZE; i++)
637 {
638 store_next = &atable[i];
639 for (arec = atable[i]; arec; arec = arecn)
640 {
641 arecn = arec->next;
642 /* We keep the temporary K-lines and destroy the
643 * permanent ones, just to be confusing :) -A1kmm */
644 if(arec->aconf->flags & CONF_FLAGS_TEMPORARY ||
645 (arec->type == CONF_CLIENT || arec->type == CONF_EXEMPTDLINE))
646 {
647 *store_next = arec;
648 store_next = &arec->next;
649 }
650 else
651 {
652 arec->aconf->status |= CONF_ILLEGAL;
653 if(!arec->aconf->clients)
654 free_conf(arec->aconf);
655 rb_free(arec);
656 }
657 }
658 *store_next = NULL;
659 }
660 }
661
662
663 /*
664 * show_iline_prefix()
665 *
666 * inputs - pointer to struct Client requesting output
667 * - pointer to struct ConfItem
668 * - name to which iline prefix will be prefixed to
669 * output - pointer to static string with prefixes listed in ascii form
670 * side effects - NONE
671 */
672 char *
673 show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name)
674 {
675 static char prefix_of_host[USERLEN + 15];
676 char *prefix_ptr;
677
678 prefix_ptr = prefix_of_host;
679 if(IsNoTilde(aconf))
680 *prefix_ptr++ = '-';
681 if(IsNeedIdentd(aconf))
682 *prefix_ptr++ = '+';
683 if(IsConfDoSpoofIp(aconf))
684 *prefix_ptr++ = '=';
685 if(IsOper(sptr) && IsConfExemptFlood(aconf))
686 *prefix_ptr++ = '|';
687 if(IsOper(sptr) && IsConfExemptDNSBL(aconf) && !IsConfExemptKline(aconf))
688 *prefix_ptr++ = '$';
689 if(IsOper(sptr) && IsConfExemptKline(aconf))
690 *prefix_ptr++ = '^';
691 if(IsOper(sptr) && IsConfExemptLimits(aconf))
692 *prefix_ptr++ = '>';
693 *prefix_ptr = '\0';
694 strncpy(prefix_ptr, name, USERLEN);
695 return (prefix_of_host);
696 }
697
698 /* report_auth()
699 *
700 * Inputs: pointer to client to report to
701 * Output: None
702 * Side effects: Reports configured auth{} blocks to client_p
703 */
704 void
705 report_auth(struct Client *client_p)
706 {
707 char *name, *host, *pass = "*", *user, *classname;
708 struct AddressRec *arec;
709 struct ConfItem *aconf;
710 int i, port;
711
712 for (i = 0; i < ATABLE_SIZE; i++)
713 for (arec = atable[i]; arec; arec = arec->next)
714 if(arec->type == CONF_CLIENT)
715 {
716 aconf = arec->aconf;
717
718 if(!IsOper(client_p) && IsConfDoSpoofIp(aconf))
719 continue;
720
721 get_printable_conf(aconf, &name, &host, &pass, &user, &port,
722 &classname);
723
724 if(!EmptyString(aconf->spasswd))
725 pass = aconf->spasswd;
726
727 sendto_one_numeric(client_p, RPL_STATSILINE,
728 form_str(RPL_STATSILINE),
729 name, pass, show_iline_prefix(client_p, aconf, user),
730 show_ip_conf(aconf, client_p) ? host : "255.255.255.255",
731 port, classname);
732 }
733 }
734
735 /* report_Klines()
736 *
737 * inputs - Client to report to, mask
738 * outputs -
739 * side effects - Reports configured K-lines to client_p.
740 */
741 void
742 report_Klines(struct Client *source_p)
743 {
744 char *host, *pass, *user, *oper_reason;
745 struct AddressRec *arec;
746 struct ConfItem *aconf = NULL;
747 int i;
748
749 for (i = 0; i < ATABLE_SIZE; i++)
750 {
751 for (arec = atable[i]; arec; arec = arec->next)
752 {
753 if(arec->type == CONF_KILL)
754 {
755 aconf = arec->aconf;
756
757 /* its a tempkline, theyre reported elsewhere */
758 if(aconf->flags & CONF_FLAGS_TEMPORARY)
759 continue;
760
761 get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
762 sendto_one_numeric(source_p, RPL_STATSKLINE,
763 form_str(RPL_STATSKLINE),
764 'K', host, user, pass,
765 oper_reason ? "|" : "",
766 oper_reason ? oper_reason : "");
767 }
768 }
769 }
770 }