]> jfr.im git - irc/rqf/shadowircd.git/blame - src/hostmask.c
update TODO
[irc/rqf/shadowircd.git] / src / hostmask.c
CommitLineData
212380e3 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
eb6e811f 8 * Copyright (C) 2005-2008 charybdis development team
212380e3 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"
212380e3 29#include "ircd_defs.h"
30#include "s_conf.h"
31#include "hostmask.h"
32#include "numeric.h"
33#include "send.h"
13ae2f4b 34#include "match.h"
212380e3 35
2c2e0aa9 36#ifdef RB_IPV6
212380e3 37static unsigned long hash_ipv6(struct sockaddr *, int);
38#endif
39static unsigned long hash_ipv4(struct sockaddr *, int);
40
41
3ea5fee7 42/* int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
212380e3 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 */
49int
50parse_netmask(const char *text, struct sockaddr *naddr, int *nb)
51{
52 char *ip = LOCAL_COPY(text);
53 char *ptr;
3ea5fee7 54 struct rb_sockaddr_storage *addr, xaddr;
212380e3 55 int *b, xb;
56 if(nb == NULL)
57 b = &xb;
58 else
59 b = nb;
60
61 if(naddr == NULL)
3ea5fee7 62 addr = (struct rb_sockaddr_storage *)&xaddr;
212380e3 63 else
3ea5fee7 64 addr = (struct rb_sockaddr_storage *)naddr;
212380e3 65
2c2e0aa9 66#ifdef RB_IPV6
212380e3 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;
9879cd59 78 if(rb_inet_pton_sock(ip, (struct sockaddr *)addr) > 0)
212380e3 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;
9879cd59 95 if(rb_inet_pton_sock(ip, (struct sockaddr *)addr) > 0)
212380e3 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 */
104struct AddressRec *atable[ATABLE_SIZE];
105
106void
107init_host_hash(void)
108{
109 memset(&atable, 0, sizeof(atable));
110}
111
3ea5fee7 112/* unsigned long hash_ipv4(struct rb_sockaddr_storage*)
212380e3 113 * Input: An IP address.
114 * Output: A hash value of the IP address.
115 * Side effects: None
116 */
117static unsigned long
118hash_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
3ea5fee7 131/* unsigned long hash_ipv6(struct rb_sockaddr_storage*)
212380e3 132 * Input: An IP address.
133 * Output: A hash value of the IP address.
134 * Side effects: None
135 */
2c2e0aa9 136#ifdef RB_IPV6
212380e3 137static unsigned long
138hash_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 */
166static int
167hash_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 */
186static unsigned long
187get_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
3ea5fee7 199/* struct ConfItem* find_conf_by_address(const char*, struct rb_sockaddr_storage*,
212380e3 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 */
207struct ConfItem *
208find_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)
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... */
2c2e0aa9 224#ifdef RB_IPV6
212380e3 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) && (type & 0x1
235 ||
236 match(arec->
237 username,
238 username))
239 && arec->precedence > hprecv)
240 {
241 hprecv = arec->precedence;
242 hprec = arec->aconf;
243 }
244 }
245 }
246 else
247#endif
248 if(fam == AF_INET)
249 {
250 for (b = 32; b >= 0; b -= 8)
251 {
252 for (arec = atable[hash_ipv4(addr, b)]; arec; arec = arec->next)
253 if(arec->type == (type & ~0x1) &&
254 arec->masktype == HM_IPV4 &&
255 arec->precedence > hprecv &&
256 comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
257 arec->Mask.ipa.bits) &&
258 (type & 0x1 || match(arec->username, username)))
259 {
260 hprecv = arec->precedence;
261 hprec = arec->aconf;
262 }
263 }
264 }
265 }
266
267 if(orighost != NULL)
268 {
269 const char *p;
270
271 for (p = orighost; p != NULL;)
272 {
273 for (arec = atable[hash_text(p)]; arec; arec = arec->next)
274
275 if((arec->type == (type & ~0x1)) &&
276 (arec->masktype == HM_HOST) &&
277 arec->precedence > hprecv &&
278 match(arec->Mask.hostname, orighost) &&
279 (type & 0x1 || match(arec->username, username)))
280 {
281 hprecv = arec->precedence;
282 hprec = arec->aconf;
283 }
284 p = strchr(p, '.');
285 if(p != NULL)
286 p++;
287 else
288 break;
289 }
290 for (arec = atable[0]; arec; arec = arec->next)
291 {
292 if(arec->type == (type & ~0x1) &&
293 arec->masktype == HM_HOST &&
294 arec->precedence > hprecv &&
295 (match(arec->Mask.hostname, orighost) ||
296 (sockhost && match(arec->Mask.hostname, sockhost))) &&
297 (type & 0x1 || match(arec->username, username)))
298 {
299 hprecv = arec->precedence;
300 hprec = arec->aconf;
301 }
302 }
303 }
304
305 if(name != NULL)
306 {
307 const char *p;
308 /* And yes - we have to check p after strchr and p after increment for
309 * NULL -kre */
310 for (p = name; p != NULL;)
311 {
312 for (arec = atable[hash_text(p)]; arec; arec = arec->next)
313 if((arec->type == (type & ~0x1)) &&
314 (arec->masktype == HM_HOST) &&
315 arec->precedence > hprecv &&
316 match(arec->Mask.hostname, name) &&
317 (type & 0x1 || match(arec->username, username)))
318 {
319 hprecv = arec->precedence;
320 hprec = arec->aconf;
321 }
322 p = strchr(p, '.');
323 if(p != NULL)
324 p++;
325 else
326 break;
327 }
328 for (arec = atable[0]; arec; arec = arec->next)
329 {
330 if(arec->type == (type & ~0x1) &&
331 arec->masktype == HM_HOST &&
332 arec->precedence > hprecv &&
333 (match(arec->Mask.hostname, name) ||
334 (sockhost && match(arec->Mask.hostname, sockhost))) &&
335 (type & 0x1 || match(arec->username, username)))
336 {
337 hprecv = arec->precedence;
338 hprec = arec->aconf;
339 }
340 }
341 }
342 return hprec;
343}
344
345/* struct ConfItem* find_address_conf(const char*, const char*,
3ea5fee7 346 * struct rb_sockaddr_storage*, int);
212380e3 347 * Input: The hostname, username, address, address family.
348 * Output: The applicable ConfItem.
349 * Side-effects: None
350 */
351struct ConfItem *
352find_address_conf(const char *host, const char *sockhost, const char *user,
353 const char *notildeuser, struct sockaddr *ip, int aftype)
354{
355 struct ConfItem *iconf, *kconf;
356 const char *vuser;
357
358 /* Find the best I-line... If none, return NULL -A1kmm */
359 if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user)))
360 return NULL;
361 /* Find what their visible username will be.
362 * Note that the username without tilde may contain one char more.
363 * -- jilles */
364 vuser = IsNoTilde(iconf) ? notildeuser : user;
365
366 /* If they are exempt from K-lines, return the best I-line. -A1kmm */
367 if(IsConfExemptKline(iconf))
368 return iconf;
369
370 /* Find the best K-line... -A1kmm */
371 kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user);
372
373 /* If they are K-lined, return the K-line */
374 if(kconf)
375 return kconf;
376
377 /* if theres a spoof, check it against klines.. */
378 if(IsConfDoSpoofIp(iconf))
379 {
380 char *p = strchr(iconf->name, '@');
381
382 /* note, we dont need to pass sockhost here, as its
383 * guaranteed to not match by whats above.. --anfl
384 */
385 if(p)
386 {
387 *p = '\0';
388 kconf = find_conf_by_address(p+1, NULL, NULL, ip, CONF_KILL, aftype, iconf->name);
389 *p = '@';
390 }
391 else
392 kconf = find_conf_by_address(iconf->name, NULL, NULL, ip, CONF_KILL, aftype, vuser);
393
394 if(kconf)
395 return kconf;
396 }
397
398 /* if no_tilde, check the username without tilde against klines too
399 * -- jilles */
400 if(user != vuser)
401 {
402 kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser);
403 if(kconf)
404 return kconf;
405 }
406
212380e3 407 return iconf;
408}
409
3ea5fee7 410/* struct ConfItem* find_dline(struct rb_sockaddr_storage*, int)
21c9d815
VY
411 * Input: An address, an address family.
412 * Output: The best matching D-line or exempt line.
413 * Side effects: None.
414 */
415struct ConfItem *
416find_dline(struct sockaddr *addr, int aftype)
417{
418 struct ConfItem *eline;
419 eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL);
420 if(eline)
421 return eline;
422 return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
423}
424
6f3a09ff 425/* void find_exact_conf_by_address(const char*, int, const char *)
4e0f14a0
JT
426 * Input:
427 * Output: ConfItem if found
428 * Side-effects: None
429 */
430struct ConfItem *
431find_exact_conf_by_address(const char *address, int type, const char *username)
432{
433 int masktype, bits;
434 unsigned long hv;
435 struct AddressRec *arec;
3ea5fee7 436 struct rb_sockaddr_storage addr;
4e0f14a0
JT
437
438 if(address == NULL)
439 address = "/NOMATCH!/";
8e43b0b4 440 arec = rb_malloc(sizeof(struct AddressRec));
4e0f14a0 441 masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
2c2e0aa9 442#ifdef RB_IPV6
4e0f14a0
JT
443 if(masktype == HM_IPV6)
444 {
445 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
446 hv = hash_ipv6((struct sockaddr *)&addr, bits - bits % 16);
447 }
448 else
449#endif
450 if(masktype == HM_IPV4)
451 {
452 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
453 hv = hash_ipv4((struct sockaddr *)&addr, bits - bits % 8);
454 }
455 else
456 {
457 hv = get_mask_hash(address);
458 }
459 for (arec = atable[hv]; arec; arec = arec->next)
460 {
461 if (arec->type == type &&
462 arec->masktype == masktype &&
6f3a09ff 463 (arec->username == NULL || username == NULL ? arec->username == username : !irccmp(arec->username, username)))
4e0f14a0
JT
464 {
465 if (masktype == HM_HOST)
466 {
467 if (!irccmp(arec->Mask.hostname, address))
468 return arec->aconf;
469 }
470 else
471 {
472 if (arec->Mask.ipa.bits == bits &&
473 comp_with_mask_sock((struct sockaddr *)&arec->Mask.ipa.addr, (struct sockaddr *)&addr, bits))
474 return arec->aconf;
475 }
476 }
477 }
478 return NULL;
479}
480
212380e3 481/* void add_conf_by_address(const char*, int, const char *,
482 * struct ConfItem *aconf)
483 * Input:
484 * Output: None
485 * Side-effects: Adds this entry to the hash table.
486 */
487void
488add_conf_by_address(const char *address, int type, const char *username, struct ConfItem *aconf)
489{
490 static unsigned long prec_value = 0xFFFFFFFF;
491 int masktype, bits;
492 unsigned long hv;
493 struct AddressRec *arec;
494
495 if(address == NULL)
496 address = "/NOMATCH!/";
8e43b0b4 497 arec = rb_malloc(sizeof(struct AddressRec));
212380e3 498 masktype = parse_netmask(address, (struct sockaddr *)&arec->Mask.ipa.addr, &bits);
499 arec->Mask.ipa.bits = bits;
500 arec->masktype = masktype;
2c2e0aa9 501#ifdef RB_IPV6
212380e3 502 if(masktype == HM_IPV6)
503 {
504 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
505 bits -= bits % 16;
506 arec->next = atable[(hv = hash_ipv6((struct sockaddr *)&arec->Mask.ipa.addr, bits))];
507 atable[hv] = arec;
508 }
509 else
510#endif
511 if(masktype == HM_IPV4)
512 {
513 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
514 bits -= bits % 8;
515 arec->next = atable[(hv = hash_ipv4((struct sockaddr *)&arec->Mask.ipa.addr, bits))];
516 atable[hv] = arec;
517 }
518 else
519 {
520 arec->Mask.hostname = address;
521 arec->next = atable[(hv = get_mask_hash(address))];
522 atable[hv] = arec;
523 }
524 arec->username = username;
525 arec->aconf = aconf;
526 arec->precedence = prec_value--;
527 arec->type = type;
528}
529
530/* void delete_one_address(const char*, struct ConfItem*)
531 * Input: An address string, the associated ConfItem.
532 * Output: None
533 * Side effects: Deletes an address record. Frees the ConfItem if there
534 * is nothing referencing it, sets it as illegal otherwise.
535 */
536void
537delete_one_address_conf(const char *address, struct ConfItem *aconf)
538{
539 int masktype, bits;
540 unsigned long hv;
541 struct AddressRec *arec, *arecl = NULL;
3ea5fee7 542 struct rb_sockaddr_storage addr;
212380e3 543 masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
2c2e0aa9 544#ifdef RB_IPV6
212380e3 545 if(masktype == HM_IPV6)
546 {
547 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
548 bits -= bits % 16;
549 hv = hash_ipv6((struct sockaddr *)&addr, bits);
550 }
551 else
552#endif
553 if(masktype == HM_IPV4)
554 {
555 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
556 bits -= bits % 8;
557 hv = hash_ipv4((struct sockaddr *)&addr, bits);
558 }
559 else
560 hv = get_mask_hash(address);
561 for (arec = atable[hv]; arec; arec = arec->next)
562 {
563 if(arec->aconf == aconf)
564 {
565 if(arecl)
566 arecl->next = arec->next;
567 else
568 atable[hv] = arec->next;
569 aconf->status |= CONF_ILLEGAL;
570 if(!aconf->clients)
571 free_conf(aconf);
90a3c35b 572 rb_free(arec);
212380e3 573 return;
574 }
575 arecl = arec;
576 }
577}
578
579/* void clear_out_address_conf(void)
580 * Input: None
581 * Output: None
582 * Side effects: Clears out all address records in the hash table,
583 * frees them, and frees the ConfItems if nothing references
584 * them, otherwise sets them as illegal.
585 */
586void
587clear_out_address_conf(void)
588{
589 int i;
590 struct AddressRec **store_next;
591 struct AddressRec *arec, *arecn;
592
593 for (i = 0; i < ATABLE_SIZE; i++)
594 {
595 store_next = &atable[i];
596 for (arec = atable[i]; arec; arec = arecn)
597 {
598 arecn = arec->next;
599 /* We keep the temporary K-lines and destroy the
600 * permanent ones, just to be confusing :) -A1kmm */
601 if(arec->aconf->flags & CONF_FLAGS_TEMPORARY ||
602 (arec->type != CONF_CLIENT && arec->type != CONF_EXEMPTDLINE))
603 {
604 *store_next = arec;
605 store_next = &arec->next;
606 }
607 else
608 {
609 arec->aconf->status |= CONF_ILLEGAL;
610 if(!arec->aconf->clients)
611 free_conf(arec->aconf);
90a3c35b 612 rb_free(arec);
212380e3 613 }
614 }
615 *store_next = NULL;
616 }
617}
618
619void
620clear_out_address_conf_bans(void)
621{
622 int i;
623 struct AddressRec **store_next;
624 struct AddressRec *arec, *arecn;
625
626 for (i = 0; i < ATABLE_SIZE; i++)
627 {
628 store_next = &atable[i];
629 for (arec = atable[i]; arec; arec = arecn)
630 {
631 arecn = arec->next;
632 /* We keep the temporary K-lines and destroy the
633 * permanent ones, just to be confusing :) -A1kmm */
634 if(arec->aconf->flags & CONF_FLAGS_TEMPORARY ||
635 (arec->type == CONF_CLIENT || arec->type == CONF_EXEMPTDLINE))
636 {
637 *store_next = arec;
638 store_next = &arec->next;
639 }
640 else
641 {
642 arec->aconf->status |= CONF_ILLEGAL;
643 if(!arec->aconf->clients)
644 free_conf(arec->aconf);
90a3c35b 645 rb_free(arec);
212380e3 646 }
647 }
648 *store_next = NULL;
649 }
650}
651
652
653/*
654 * show_iline_prefix()
655 *
656 * inputs - pointer to struct Client requesting output
657 * - pointer to struct ConfItem
658 * - name to which iline prefix will be prefixed to
659 * output - pointer to static string with prefixes listed in ascii form
660 * side effects - NONE
661 */
662char *
663show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name)
664{
665 static char prefix_of_host[USERLEN + 15];
666 char *prefix_ptr;
667
668 prefix_ptr = prefix_of_host;
669 if(IsNoTilde(aconf))
670 *prefix_ptr++ = '-';
212380e3 671 if(IsNeedIdentd(aconf))
672 *prefix_ptr++ = '+';
212380e3 673 if(IsConfDoSpoofIp(aconf))
674 *prefix_ptr++ = '=';
bd03481b
JT
675 if(IsOper(sptr) && IsConfExemptFlood(aconf))
676 *prefix_ptr++ = '|';
bd03481b
JT
677 if(IsOper(sptr) && IsConfExemptDNSBL(aconf) && !IsConfExemptKline(aconf))
678 *prefix_ptr++ = '$';
331c47e0 679 if(IsOper(sptr) && IsConfExemptKline(aconf))
212380e3 680 *prefix_ptr++ = '^';
331c47e0 681 if(IsOper(sptr) && IsConfExemptLimits(aconf))
212380e3 682 *prefix_ptr++ = '>';
212380e3 683 *prefix_ptr = '\0';
684 strncpy(prefix_ptr, name, USERLEN);
685 return (prefix_of_host);
686}
687
688/* report_auth()
689 *
690 * Inputs: pointer to client to report to
691 * Output: None
692 * Side effects: Reports configured auth{} blocks to client_p
693 */
694void
695report_auth(struct Client *client_p)
696{
697 char *name, *host, *pass, *user, *classname;
698 struct AddressRec *arec;
699 struct ConfItem *aconf;
700 int i, port;
701
702 for (i = 0; i < ATABLE_SIZE; i++)
703 for (arec = atable[i]; arec; arec = arec->next)
704 if(arec->type == CONF_CLIENT)
705 {
706 aconf = arec->aconf;
707
331c47e0 708 if(!IsOper(client_p) && IsConfDoSpoofIp(aconf))
212380e3 709 continue;
710
711 get_printable_conf(aconf, &name, &host, &pass, &user, &port,
712 &classname);
713
714 sendto_one_numeric(client_p, RPL_STATSILINE,
715 form_str(RPL_STATSILINE),
716 name, show_iline_prefix(client_p, aconf, user),
717 show_ip_conf(aconf, client_p) ? host : "255.255.255.255",
718 port, classname);
719 }
720}
721
722/* report_Klines()
723 *
724 * inputs - Client to report to, mask
725 * outputs -
726 * side effects - Reports configured K-lines to client_p.
727 */
728void
729report_Klines(struct Client *source_p)
730{
731 char *host, *pass, *user, *oper_reason;
732 struct AddressRec *arec;
733 struct ConfItem *aconf = NULL;
734 int i;
735
736 for (i = 0; i < ATABLE_SIZE; i++)
737 {
738 for (arec = atable[i]; arec; arec = arec->next)
739 {
740 if(arec->type == CONF_KILL)
741 {
742 aconf = arec->aconf;
743
744 /* its a tempkline, theyre reported elsewhere */
745 if(aconf->flags & CONF_FLAGS_TEMPORARY)
746 continue;
747
748 get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
749 sendto_one_numeric(source_p, RPL_STATSKLINE,
750 form_str(RPL_STATSKLINE),
751 'K', host, user, pass,
752 oper_reason ? "|" : "",
753 oper_reason ? oper_reason : "");
754 }
755 }
756 }
757}