/[svn]/branches/newio/src/parse.c
ViewVC logotype

Contents of /branches/newio/src/parse.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2408 - (show annotations)
Thu Jul 18 19:57:58 2013 UTC (6 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 23846 byte(s)
- ioengine changes as of 18JUL13

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * parse.c: The message parser.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "client.h"
27 #include "parse.h"
28 #include "channel.h"
29 #include "hash.h"
30 #include "irc_string.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "log.h"
34 #include "send.h"
35 #include "conf.h"
36 #include "memory.h"
37 #include "s_user.h"
38 #include "s_serv.h"
39
40 /*
41 * (based on orabidoo's parser code)
42 *
43 * This has always just been a trie. Look at volume III of Knuth ACP
44 *
45 *
46 * ok, you start out with an array of pointers, each one corresponds
47 * to a letter at the current position in the command being examined.
48 *
49 * so roughly you have this for matching 'trie' or 'tie'
50 *
51 * 't' points -> [MessageTree *] 'r' -> [MessageTree *] -> 'i'
52 * -> [MessageTree *] -> [MessageTree *] -> 'e' and matches
53 *
54 * 'i' -> [MessageTree *] -> 'e' and matches
55 *
56 * BUGS (Limitations!)
57 *
58 * I designed this trie to parse ircd commands. Hence it currently
59 * casefolds. This is trivial to fix by increasing MAXPTRLEN.
60 * This trie also "folds" '{' etc. down. This means, the input to this
61 * trie must be alpha tokens only. This again, is a limitation that
62 * can be overcome by increasing MAXPTRLEN to include upper/lower case
63 * at the expense of more memory. At the extreme end, you could make
64 * MAXPTRLEN 128.
65 *
66 * This is also not a patricia trie. On short ircd tokens, this is
67 * not likely going to matter.
68 *
69 * Diane Bruce (Dianora), June 6 2003
70 */
71
72 #define MAXPTRLEN 32
73 /* Must be a power of 2, and
74 * larger than 26 [a-z]|[A-Z]
75 * its used to allocate the set
76 * of pointers at each node of the tree
77 * There are MAXPTRLEN pointers at each node.
78 * Obviously, there have to be more pointers
79 * Than ASCII letters. 32 is a nice number
80 * since there is then no need to shift
81 * 'A'/'a' to base 0 index, at the expense
82 * of a few never used pointers. For a small
83 * parser like this, this is a good compromise
84 * and does make it somewhat faster.
85 *
86 * - Dianora
87 */
88
89 struct MessageTree
90 {
91 int links; /* Count of all pointers (including msg) at this node
92 * used as reference count for deletion of _this_ node.
93 */
94 struct Message *msg;
95 struct MessageTree *pointers[MAXPTRLEN];
96 };
97
98 static struct MessageTree msg_tree;
99
100 /*
101 * NOTE: parse() should not be called recursively by other functions!
102 */
103 static char *sender;
104 static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */
105
106 static int cancel_clients(struct Client *, struct Client *, char *);
107 static void remove_unknown(struct Client *, char *, char *);
108 static void handle_numeric(char[], struct Client *, struct Client *, int, char *[]);
109 static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char *[]);
110
111
112 /*
113 * parse a buffer.
114 *
115 * NOTE: parse() should not be called recusively by any other functions!
116 */
117 int
118 parse(struct Client *client_p, char *pbuffer, char *bufend)
119 {
120 struct Client *from = client_p;
121 struct Message *msg_ptr = NULL;
122 char *ch = NULL;
123 char *s = NULL;
124 char *numeric = NULL;
125 unsigned int parc = 0;
126 unsigned int paramcount;
127
128 if (IsDead(client_p))
129 return 0;
130
131 assert(client_p->localClient->fd.flags.open);
132 assert((bufend - pbuffer) < 512);
133
134 for (ch = pbuffer; *ch == ' '; ++ch) /* skip spaces */
135 /* null statement */ ;
136
137 if (*ch == ':')
138 {
139 /*
140 * Copy the prefix to 'sender' assuming it terminates
141 * with SPACE (or NULL, which is an error, though).
142 */
143 sender = ++ch;
144
145 if ((s = strchr(ch, ' ')) != NULL)
146 {
147 *s = '\0';
148 ch = ++s;
149 }
150
151 if (*sender && IsServer(client_p))
152 {
153 if ((from = find_person(client_p, sender)) == NULL)
154 from = hash_find_server(sender);
155
156 /*
157 * Hmm! If the client corresponding to the prefix is not found--what is
158 * the correct action??? Now, I will ignore the message (old IRC just
159 * let it through as if the prefix just wasn't there...) --msa
160 */
161 if (from == NULL)
162 {
163 ++ServerStats.is_unpf;
164 remove_unknown(client_p, sender, pbuffer);
165 return -1;
166 }
167
168 if (from->from != client_p)
169 {
170 ++ServerStats.is_wrdi;
171 cancel_clients(client_p, from, pbuffer);
172 return -1;
173 }
174 }
175
176 while (*ch == ' ')
177 ++ch;
178 }
179
180 if (*ch == '\0')
181 {
182 ++ServerStats.is_empt;
183 return -1;
184 }
185
186 /*
187 * Extract the command code from the packet. Point s to the end
188 * of the command code and calculate the length using pointer
189 * arithmetic. Note: only need length for numerics and *all*
190 * numerics must have parameters and thus a space after the command
191 * code. -avalon
192 */
193
194 /* EOB is 3 chars long but is not a numeric */
195 if (*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */
196 IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2)))
197 {
198 numeric = ch;
199 paramcount = 2; /* destination, and the rest of it */
200 ++ServerStats.is_num;
201 s = ch + 3; /* I know this is ' ' from above if */
202 *s++ = '\0'; /* blow away the ' ', and point s to next part */
203 }
204 else
205 {
206 unsigned int ii = 0;
207
208 if ((s = strchr(ch, ' ')) != NULL)
209 *s++ = '\0';
210
211 if ((msg_ptr = find_command(ch)) == NULL)
212 {
213 /*
214 * Note: Give error message *only* to recognized
215 * persons. It's a nightmare situation to have
216 * two programs sending "Unknown command"'s or
217 * equivalent to each other at full blast....
218 * If it has got to person state, it at least
219 * seems to be well behaving. Perhaps this message
220 * should never be generated, though... --msa
221 * Hm, when is the buffer empty -- if a command
222 * code has been found ?? -Armin
223 */
224 if (*pbuffer != '\0')
225 {
226 if (IsClient(from))
227 sendto_one(from, form_str(ERR_UNKNOWNCOMMAND),
228 me.name, from->name, ch);
229 }
230
231 ++ServerStats.is_unco;
232 return -1;
233 }
234
235 assert(msg_ptr->cmd != NULL);
236
237 paramcount = msg_ptr->args_max;
238 ii = bufend - ((s) ? s : ch);
239 msg_ptr->bytes += ii;
240 }
241
242
243 /*
244 * Allow only 1 msg per 2 seconds (on average) to prevent dumping.
245 * To keep the response rate up, bursts of up to 5 msgs
246 * are allowed -SRB
247 */
248 if ((msg_ptr->flags & MFLG_SLOW) && !IsServer(client_p))
249 client_p->localClient->since += (2 + i / 120);
250
251 /*
252 * Must the following loop really be so devious? On surface it
253 * splits the message to parameters from blank spaces. But, if
254 * paramcount has been reached, the rest of the message goes into
255 * this last parameter (about same effect as ":" has...) --msa
256 */
257
258 /* Note initially true: s==NULL || *(s-1) == '\0' !! */
259
260 para[parc] = from->name;
261
262 if (s)
263 {
264 if (paramcount > MAXPARA)
265 paramcount = MAXPARA;
266
267 while (1)
268 {
269 while (*s == ' ')
270 *s++ = '\0';
271
272 if (*s == '\0')
273 break;
274
275 if (*s == ':')
276 {
277 /* The rest is a single parameter */
278 para[++parc] = s + (!numeric); /* keep the colon if it's a numeric */
279 break;
280 }
281
282 para[++parc] = s;
283
284 if (parc >= paramcount)
285 break;
286
287 while (*s && *s != ' ')
288 ++s;
289 }
290 }
291
292 para[++parc] = NULL;
293
294 if (msg_ptr != NULL)
295 handle_command(msg_ptr, client_p, from, parc, para);
296 else
297 handle_numeric(numeric, client_p, from, parc, para);
298 return 5;
299 }
300
301 /* handle_command()
302 *
303 * inputs - pointer to message block
304 * - pointer to client
305 * - pointer to client message is from
306 * - count of number of args
307 * - pointer to argv[] array
308 * output - -1 if error from server
309 * side effects -
310 */
311 static void
312 handle_command(struct Message *mptr, struct Client *client_p,
313 struct Client *from, unsigned int i, char *hpara[])
314 {
315 MessageHandler handler = 0;
316
317 if (IsServer(client_p))
318 mptr->rcount++;
319
320 mptr->count++;
321
322 handler = mptr->handlers[client_p->handler];
323
324 /* check right amount of params is passed... --is */
325 if (i < mptr->args_min)
326 {
327 if (!IsServer(client_p))
328 {
329 sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name,
330 EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd);
331 }
332 else
333 {
334 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
335 "Dropping server %s due to (invalid) command '%s' "
336 "with only %d arguments (expecting %d).",
337 client_p->name, mptr->cmd, i, mptr->args_min);
338 ilog(LOG_TYPE_IRCD, "Insufficient parameters (%d) for command '%s' from %s.",
339 i, mptr->cmd, client_p->name);
340 exit_client(client_p, client_p,
341 "Not enough arguments to server command.");
342 }
343 }
344 else
345 (*handler)(client_p, from, i, hpara);
346 }
347
348 /* add_msg_element()
349 *
350 * inputs - pointer to MessageTree
351 * - pointer to Message to add for given command
352 * - pointer to current portion of command being added
353 * output - NONE
354 * side effects - recursively build the Message Tree ;-)
355 */
356 /*
357 * How this works.
358 *
359 * The code first checks to see if its reached the end of the command
360 * If so, that struct MessageTree has a msg pointer updated and the links
361 * count incremented, since a msg pointer is a reference.
362 * Then the code descends recursively, building the trie.
363 * If a pointer index inside the struct MessageTree is NULL a new
364 * child struct MessageTree has to be allocated.
365 * The links (reference count) is incremented as they are created
366 * in the parent.
367 */
368 static void
369 add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p,
370 const char *cmd)
371 {
372 struct MessageTree *ntree_p;
373
374 if (*cmd == '\0')
375 {
376 mtree_p->msg = msg_p;
377 mtree_p->links++; /* Have msg pointer, so up ref count */
378 }
379 else
380 {
381 /*
382 * *cmd & (MAXPTRLEN-1)
383 * convert the char pointed to at *cmd from ASCII to an integer
384 * between 0 and MAXPTRLEN.
385 * Thus 'A' -> 0x1 'B' -> 0x2 'c' -> 0x3 etc.
386 */
387 if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) == NULL)
388 {
389 ntree_p = MyMalloc(sizeof(struct MessageTree));
390 mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p;
391
392 mtree_p->links++; /* Have new pointer, so up ref count */
393 }
394
395 add_msg_element(ntree_p, msg_p, cmd + 1);
396 }
397 }
398
399 /* del_msg_element()
400 *
401 * inputs - Pointer to MessageTree to delete from
402 * - pointer to command name to delete
403 * output - NONE
404 * side effects - recursively deletes a token from the Message Tree ;-)
405 */
406 /*
407 * How this works.
408 *
409 * Well, first off, the code recursively descends into the trie
410 * until it finds the terminating letter of the command being removed.
411 * Once it has done that, it marks the msg pointer as NULL then
412 * reduces the reference count on that allocated struct MessageTree
413 * since a command counts as a reference.
414 *
415 * Then it pops up the recurse stack. As it comes back up the recurse
416 * The code checks to see if the child now has no pointers or msg
417 * i.e. the links count has gone to zero. If its no longer used, the
418 * child struct MessageTree can be deleted. The parent reference
419 * to this child is then removed and the parents link count goes down.
420 * Thus, we continue to go back up removing all unused MessageTree(s)
421 */
422 static void
423 del_msg_element(struct MessageTree *mtree_p, const char *cmd)
424 {
425 struct MessageTree *ntree_p;
426
427 /*
428 * In case this is called for a nonexistent command
429 * check that there is a msg pointer here, else links-- goes -ve
430 * -db
431 */
432 if ((*cmd == '\0') && (mtree_p->msg != NULL))
433 {
434 mtree_p->msg = NULL;
435 mtree_p->links--;
436 }
437 else
438 {
439 if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) != NULL)
440 {
441 del_msg_element(ntree_p, cmd + 1);
442
443 if (ntree_p->links == 0)
444 {
445 mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL;
446 mtree_p->links--;
447 MyFree(ntree_p);
448 }
449 }
450 }
451 }
452
453 /* msg_tree_parse()
454 *
455 * inputs - Pointer to command to find
456 * - Pointer to MessageTree root
457 * output - Find given command returning Message * if found NULL if not
458 * side effects - none
459 */
460 static struct Message *
461 msg_tree_parse(const char *cmd)
462 {
463 struct MessageTree *mtree = &msg_tree;
464 assert(cmd && *cmd);
465
466 while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)]))
467 if (*++cmd == '\0')
468 return mtree->msg;
469
470 return NULL;
471 }
472
473 /* mod_add_cmd()
474 *
475 * inputs - pointer to struct Message
476 * output - none
477 * side effects - load this one command name
478 * msg->count msg->bytes is modified in place, in
479 * modules address space. Might not want to do that...
480 */
481 void
482 mod_add_cmd(struct Message *msg)
483 {
484 assert(msg && msg->cmd);
485
486 /* command already added? */
487 if (msg_tree_parse(msg->cmd))
488 return;
489
490 add_msg_element(&msg_tree, msg, msg->cmd);
491 msg->count = msg->rcount = msg->bytes = 0;
492 }
493
494 /* mod_del_cmd()
495 *
496 * inputs - pointer to struct Message
497 * output - none
498 * side effects - unload this one command name
499 */
500 void
501 mod_del_cmd(struct Message *msg)
502 {
503 assert(msg && msg->cmd);
504
505 del_msg_element(&msg_tree, msg->cmd);
506 }
507
508 /* find_command()
509 *
510 * inputs - command name
511 * output - pointer to struct Message
512 * side effects - none
513 */
514 struct Message *
515 find_command(const char *cmd)
516 {
517 return msg_tree_parse(cmd);
518 }
519
520 static void
521 recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree)
522 {
523 unsigned int i;
524
525 if (mtree->msg != NULL)
526 sendto_one(source_p, form_str(RPL_STATSCOMMANDS),
527 me.name, source_p->name, mtree->msg->cmd,
528 mtree->msg->count, mtree->msg->bytes,
529 mtree->msg->rcount);
530
531 for (i = 0; i < MAXPTRLEN; ++i)
532 if (mtree->pointers[i] != NULL)
533 recurse_report_messages(source_p, mtree->pointers[i]);
534 }
535
536 /* report_messages()
537 *
538 * inputs - pointer to client to report to
539 * output - NONE
540 * side effects - client is shown list of commands
541 */
542 void
543 report_messages(struct Client *source_p)
544 {
545 const struct MessageTree *mtree = &msg_tree;
546 unsigned int i;
547
548 for (i = 0; i < MAXPTRLEN; ++i)
549 if (mtree->pointers[i] != NULL)
550 recurse_report_messages(source_p, mtree->pointers[i]);
551 }
552
553 /* cancel_clients()
554 *
555 * inputs -
556 * output -
557 * side effects -
558 */
559 static int
560 cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
561 {
562 /*
563 * Kill all possible points that are causing confusion here,
564 * I'm not sure I've got this all right...
565 * - avalon
566 *
567 * Knowing avalon, probably not.
568 */
569
570 /*
571 * With TS, fake prefixes are a common thing, during the
572 * connect burst when there's a nick collision, and they
573 * must be ignored rather than killed because one of the
574 * two is surviving.. so we don't bother sending them to
575 * all ops everytime, as this could send 'private' stuff
576 * from lagged clients. we do send the ones that cause
577 * servers to be dropped though, as well as the ones from
578 * non-TS servers -orabidoo
579 */
580 /*
581 * Incorrect prefix for a server from some connection. If it is a
582 * client trying to be annoying, just QUIT them, if it is a server
583 * then the same deal.
584 */
585 if (IsServer(source_p) || IsMe(source_p))
586 {
587 sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
588 "Message for %s[%s] from %s",
589 source_p->name, source_p->from->name,
590 get_client_name(client_p, SHOW_IP));
591 sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE,
592 "Message for %s[%s] from %s",
593 source_p->name, source_p->from->name,
594 get_client_name(client_p, MASK_IP));
595 sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
596 "Not dropping server %s (%s) for Fake Direction",
597 client_p->name, source_p->name);
598 return -1;
599 /* return exit_client(client_p, client_p, &me, "Fake Direction");*/
600 }
601
602 /*
603 * Ok, someone is trying to impose as a client and things are
604 * confused. If we got the wrong prefix from a server, send out a
605 * kill, else just exit the lame client.
606 */
607 /*
608 * If the fake prefix is coming from a TS server, discard it
609 * silently -orabidoo
610 *
611 * all servers must be TS these days --is
612 */
613 sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
614 "Message for %s[%s@%s!%s] from %s (TS, ignored)",
615 source_p->name, source_p->username, source_p->host,
616 source_p->from->name, get_client_name(client_p, SHOW_IP));
617 sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE,
618 "Message for %s[%s@%s!%s] from %s (TS, ignored)",
619 source_p->name, source_p->username, source_p->host,
620 source_p->from->name, get_client_name(client_p, MASK_IP));
621
622 return 0;
623 }
624
625 /* remove_unknown()
626 *
627 * inputs -
628 * output -
629 * side effects -
630 */
631 static void
632 remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
633 {
634 /*
635 * Do kill if it came from a server because it means there is a ghost
636 * user on the other server which needs to be removed. -avalon
637 * Tell opers about this. -Taner
638 */
639 /*
640 * '[0-9]something' is an ID (KILL/SQUIT depending on its length)
641 * 'nodots' is a nickname (KILL)
642 * 'no.dot.at.start' is a server (SQUIT)
643 */
644 if ((IsDigit(*lsender) && strlen(lsender) <= IRC_MAXSID) ||
645 strchr(lsender, '.') != NULL)
646 {
647 sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
648 "Unknown prefix (%s) from %s, Squitting %s",
649 lbuffer, get_client_name(client_p, SHOW_IP), lsender);
650 sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE,
651 "Unknown prefix (%s) from %s, Squitting %s",
652 lbuffer, client_p->name, lsender);
653 sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
654 me.name, lsender, lbuffer, client_p->name);
655 }
656 else
657 sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)",
658 me.name, lsender, me.name);
659 }
660
661 /*
662 *
663 * parc number of arguments ('sender' counted as one!)
664 * parv[0] pointer to 'sender' (may point to empty string) (not used)
665 * parv[1]..parv[parc-1]
666 * pointers to additional parameters, this is a NULL
667 * terminated list (parv[parc] == NULL).
668 *
669 * *WARNING*
670 * Numerics are mostly error reports. If there is something
671 * wrong with the message, just *DROP* it! Don't even think of
672 * sending back a neat error message -- big danger of creating
673 * a ping pong error message...
674 *
675 * Rewritten by Nemesi, Jan 1999, to support numeric nicks in parv[1]
676 *
677 * Called when we get a numeric message from a remote _server_ and we are
678 * supposed to forward it somewhere. Note that we always ignore numerics sent
679 * to 'me' and simply drop the message if we can't handle with this properly:
680 * the savvy approach is NEVER generate an error in response to an... error :)
681 */
682 static void
683 handle_numeric(char numeric[], struct Client *client_p, struct Client *source_p,
684 int parc, char *parv[])
685 {
686 struct Client *target_p = NULL;
687 struct Channel *chptr = NULL;
688
689 /*
690 * Avoid trash, we need it to come from a server and have a target
691 */
692 if (parc < 2 || !IsServer(source_p))
693 return;
694
695 /*
696 * Who should receive this message ? Will we do something with it ?
697 * Note that we use findUser functions, so the target can't be neither
698 * a server, nor a channel (?) nor a list of targets (?) .. u2.10
699 * should never generate numeric replies to non-users anyway
700 * Ahem... it can be a channel actually, csc bots use it :\ --Nem
701 */
702 if (IsChanPrefix(*parv[1]))
703 chptr = hash_find_channel(parv[1]);
704 else
705 target_p = find_person(client_p, parv[1]);
706
707 if (((!target_p) || (target_p->from == client_p)) && !chptr)
708 return;
709
710 /*
711 * Remap low number numerics, not that I understand WHY.. --Nemesi
712 */
713 /*
714 * Numerics below 100 talk about the current 'connection', you're not
715 * connected to a remote server so it doesn't make sense to send them
716 * remotely - but the information they contain may be useful, so we
717 * remap them up. Weird, but true. -- Isomer
718 */
719 if (numeric[0] == '0')
720 numeric[0] = '1';
721
722 if (target_p)
723 {
724 /* Fake it for server hiding, if its our client */
725 if (ConfigServerHide.hide_servers && MyClient(target_p) &&
726 !HasUMode(target_p, UMODE_OPER))
727 sendto_one(target_p, ":%s %s %s %s", me.name, numeric, target_p->name, parv[2]);
728 else
729 sendto_one(target_p, ":%s %s %s %s", ID_or_name(source_p, target_p->from),
730 numeric, ID_or_name(target_p, target_p->from), parv[2]);
731 }
732 else
733 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s",
734 source_p->name, numeric, chptr->chname, parv[2]);
735 }
736
737 /* m_not_oper()
738 * inputs -
739 * output -
740 * side effects - just returns a nastyogram to given user
741 */
742 void
743 m_not_oper(struct Client *client_p, struct Client *source_p,
744 int parc, char *parv[])
745 {
746 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
747 me.name, source_p->name);
748 }
749
750 void
751 m_unregistered(struct Client *client_p, struct Client *source_p,
752 int parc, char *parv[])
753 {
754 sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name,
755 source_p->name[0] ? source_p->name : "*");
756 }
757
758 void
759 m_registered(struct Client *client_p, struct Client *source_p,
760 int parc, char *parv[])
761 {
762 sendto_one(source_p, form_str(ERR_ALREADYREGISTRED),
763 me.name, source_p->name);
764 }
765
766 void
767 m_ignore(struct Client *client_p, struct Client *source_p,
768 int parc, char *parv[])
769 {
770 return;
771 }
772
773 void
774 rfc1459_command_send_error(struct Client *client_p, struct Client *source_p,
775 int parc, char *parv[])
776 {
777 const char *in_para;
778
779 in_para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
780
781 ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s",
782 source_p->name, in_para);
783
784 if (client_p == source_p)
785 {
786 sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
787 "ERROR :from %s -- %s",
788 get_client_name(client_p, HIDE_IP), in_para);
789 sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
790 "ERROR :from %s -- %s",
791 get_client_name(client_p, MASK_IP), in_para);
792 }
793 else
794 {
795 sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
796 "ERROR :from %s via %s -- %s",
797 source_p->name, get_client_name(client_p, HIDE_IP), in_para);
798 sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
799 "ERROR :from %s via %s -- %s",
800 source_p->name, get_client_name(client_p, MASK_IP), in_para);
801 }
802
803 if (MyClient(source_p))
804 exit_client(source_p, source_p, "ERROR");
805 }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28