static void parse_request(rb_helper *helper) { int len; static char *parv[MAXPARA + 1]; int parc; while((len = rb_helper_read(helper, readBuf, sizeof(readBuf))) > 0) { parc = rb_string_to_array(readBuf, parv, MAXPARA); switch (*parv[0]) { case 'I': if(parc != 4) abort(); resolve_ip(parv); break; case 'H': if(parc != 4) abort(); resolve_host(parv); break; case 'B': if(parc != 4) abort(); set_bind(parv); break; case 'R': restart_resolver(); report_nameservers(); break; default: break; } } }
static void parse_request(rb_helper *helper) { static char *parv[MAXPARA + 1]; static char readbuf[READBUF_SIZE]; int parc; int len; while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) { parc = rb_string_to_array(readbuf, parv, MAXPARA); if(parc < 1) continue; switch (parv[0][0]) { case 'K': parse_ban(BANDB_KLINE, parv, parc); break; case 'D': parse_ban(BANDB_DLINE, parv, parc); break; case 'X': parse_ban(BANDB_XLINE, parv, parc); break; case 'R': parse_ban(BANDB_RESV, parv, parc); break; case 'k': parse_unban(BANDB_KLINE, parv, parc); break; case 'd': parse_unban(BANDB_DLINE, parv, parc); break; case 'x': parse_unban(BANDB_XLINE, parv, parc); break; case 'r': parse_unban(BANDB_RESV, parv, parc); break; case 'L': list_bans(); break; default: break; } } }
static void parse_request(rb_helper *helper) { static char *parv[MAXPARA + 1]; static char readbuf[READBUF_SIZE]; int parc; int len; authd_cmd_handler handler; while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) { parc = rb_string_to_array(readbuf, parv, MAXPARA); if(parc < 1) continue; handler = authd_cmd_handlers[(unsigned char)parv[0][0]]; if (handler != NULL) handler(parc, parv); } }
/* parse() * * given a raw buffer, parses it and generates parv, parc and sender */ void parse(struct Client *client_p, char *pbuffer, char *bufend) { struct Client *from = client_p; static char *para[MAXPARA + 2]; static char *sender; char *ch; char *s; char *end; int i = 1; char *numeric = 0; struct Message *mptr; s_assert(MyConnect(client_p)); if(IsAnyDead(client_p)) return; for(ch = pbuffer; *ch == ' '; ch++) /* skip spaces */ /* null statement */ ; if(from->name != NULL) para[0] = LOCAL_COPY(from->name); else para[0] = NULL; if(*ch == ':') { ch++; /* point sender to the sender param */ sender = ch; if((s = strchr(ch, ' '))) { *s = '\0'; s++; ch = s; } if(*sender && IsServer(client_p)) { from = find_any_client(sender); /* didnt find any matching client, issue a kill */ if(from == NULL) { ServerStats.is_unpf++; remove_unknown(client_p, sender, pbuffer); return; } para[0] = LOCAL_COPY(from->name); /* fake direction, hmm. */ if(from->from != client_p) { ServerStats.is_wrdi++; cancel_clients(client_p, from); return; } } while(*ch == ' ') ch++; } if(*ch == '\0') { ServerStats.is_empt++; return; } /* at this point there must be some sort of command parameter */ /* * Extract the command code from the packet. Point s to the end * of the command code and calculate the length using pointer * arithmetic. Note: only need length for numerics and *all* * numerics must have parameters and thus a space after the command * code. -avalon */ /* EOB is 3 chars long but is not a numeric */ if(*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */ IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2))) { mptr = NULL; numeric = ch; ServerStats.is_num++; s = ch + 3; /* I know this is ' ' from above if */ *s++ = '\0'; /* blow away the ' ', and point s to next part */ } else { int ii = 0; if((s = strchr(ch, ' '))) *s++ = '\0'; mptr = hash_find_data(HASH_COMMAND, ch); /* no command or its encap only, error */ if(mptr == NULL || mptr->cmd == NULL) { /* * Note: Give error message *only* to recognized * persons. It's a nightmare situation to have * two programs sending "Unknown command"'s or * equivalent to each other at full blast.... * If it has got to person state, it at least * seems to be well behaving. Perhaps this message * should never be generated, though... --msa * Hm, when is the buffer empty -- if a command * code has been found ?? -Armin */ if(pbuffer[0] != '\0') { if(IsClient(from)) sendto_one_numeric(from, s_RPL(ERR_UNKNOWNCOMMAND), ch); } ServerStats.is_unco++; return; } ii = bufend - ((s) ? s : ch); mptr->bytes += ii; } end = bufend - 1; /* XXX this should be done before parse() is called */ if(*end == '\n') *end-- = '\0'; if(*end == '\r') *end = '\0'; /* ugh. so rb_string_to_array isn't brain damaged like the original one * however..so accomdate the old behavior, pass ¶[1] * and add + 1 to i...the rest of this mess can e fixed */ if(s != NULL) i = rb_string_to_array(s, ¶[1], MAXPARA) + 1; if(mptr == NULL) { do_numeric(numeric, client_p, from, i, para); return; } if(handle_command(mptr, client_p, from, i, /* XXX discards const!!! */ (const char **)(uintptr_t) para) < -1) { char *p; for(p = pbuffer; p <= end; p += 8) { /* HACK HACK */ /* Its expected this nasty code can be removed * or rewritten later if still needed. */ if((unsigned long)(p + 8) > (unsigned long)end) { for(; p <= end; p++) { ilog(L_MAIN, "%02x |%c", p[0], p[0]); } } else ilog(L_MAIN, "%02x %02x %02x %02x %02x %02x %02x %02x |%c%c%c%c%c%c%c%c", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); } } }