ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/packet.c
(Generate patch)

Comparing:
ircd-hybrid-7.3/src/packet.c (file contents), Revision 1123 by michael, Sun Feb 6 21:57:50 2011 UTC vs.
ircd-hybrid/trunk/src/packet.c (file contents), Revision 1592 by michael, Sat Oct 27 21:02:32 2012 UTC

# Line 24 | Line 24
24   #include "stdinc.h"
25   #include "list.h"
26   #include "s_bsd.h"
27 < #include "s_conf.h"
27 > #include "conf.h"
28   #include "s_serv.h"
29   #include "client.h"
30 #include "common.h"
30   #include "ircd.h"
31   #include "parse.h"
32   #include "fdlist.h"
# Line 36 | Line 35
35   #include "memory.h"
36   #include "hook.h"
37   #include "send.h"
38 + #include "s_misc.h"
39  
40   #define READBUF_SIZE 16384
41  
42   struct Callback *iorecv_cb = NULL;
43 struct Callback *iorecvctrl_cb = NULL;
43  
44   static char readBuf[READBUF_SIZE];
45   static void client_dopacket(struct Client *, char *, size_t);
# Line 166 | Line 165 | parse_client_queued(struct Client *clien
165    }
166    else if (IsClient(client_p))
167    {
168 <    if (ConfigFileEntry.no_oper_flood && (IsOper(client_p) || IsCanFlood(client_p)))
168 >    if (ConfigFileEntry.no_oper_flood && (HasUMode(client_p, UMODE_OPER) || IsCanFlood(client_p)))
169      {
170        if (ConfigFileEntry.true_no_oper_flood)
171          checkflood = -1;
# Line 272 | Line 271 | flood_recalc(fde_t *fd, void *data)
271   }
272  
273   /*
275 * read_ctrl_packet - Read a 'packet' of data from a servlink control
276 *                    link and process it.
277 */
278 void
279 read_ctrl_packet(fde_t *fd, void *data)
280 {
281  struct Client *server = data;
282  struct LocalUser *lserver = server->localClient;
283  struct SlinkRpl *reply;
284  int length = 0;
285  unsigned char tmp[2];
286  unsigned char *len = tmp;
287  struct SlinkRplDef *replydef;
288
289  assert(lserver != NULL);
290    
291  reply = &lserver->slinkrpl;
292
293  if (IsDefunct(server))
294    return;
295
296  if (!reply->command)
297  {
298    reply->gotdatalen = 0;
299    reply->readdata = 0;
300    reply->data = NULL;
301
302    length = recv(fd->fd, tmp, 1, 0);
303
304    if (length <= 0)
305    {
306      if ((length == -1) && ignoreErrno(errno))
307        goto nodata;
308      dead_link_on_read(server, length);
309      return;
310    }
311    reply->command = tmp[0];
312  }
313
314  for (replydef = slinkrpltab; replydef->handler; replydef++)
315  {
316    if (replydef->replyid == (unsigned int)reply->command)
317      break;
318  }
319
320  /* we should be able to trust a local slink process...
321   * and if it sends an invalid command, that's a bug.. */
322  assert(replydef->handler);
323
324  if ((replydef->flags & SLINKRPL_FLAG_DATA) && (reply->gotdatalen < 2))
325  {
326    /* we need a datalen u16 which we don't have yet... */
327    length = recv(fd->fd, len, (2 - reply->gotdatalen), 0);
328    if (length <= 0)
329    {
330      if ((length == -1) && ignoreErrno(errno))
331        goto nodata;
332      dead_link_on_read(server, length);
333      return;
334    }
335
336    if (reply->gotdatalen == 0)
337    {
338      reply->datalen = *len << 8;
339      reply->gotdatalen++;
340      length--;
341      len++;
342    }
343    if (length && (reply->gotdatalen == 1))
344    {
345      reply->datalen |= *len;
346      reply->gotdatalen++;
347      if (reply->datalen > 0)
348        reply->data = MyMalloc(reply->datalen);
349    }
350
351    if (reply->gotdatalen < 2)
352      return; /* wait for more data */
353  }
354
355  if (reply->readdata < reply->datalen) /* try to get any remaining data */
356  {
357    length = recv(fd->fd, (reply->data + reply->readdata),
358                  (reply->datalen - reply->readdata), 0);
359    if (length <= 0)
360    {
361      if ((length == -1) && ignoreErrno(errno))
362        goto nodata;
363      dead_link_on_read(server, length);
364      return;
365    }
366
367    reply->readdata += length;
368    if (reply->readdata < reply->datalen)
369      return; /* wait for more data */
370  }
371
372  execute_callback(iorecvctrl_cb, server, reply->command);
373
374  /* we now have the command and any data, pass it off to the handler */
375  (*replydef->handler)(reply->command, reply->datalen, reply->data, server);
376
377  /* reset SlinkRpl */                      
378  if (reply->datalen > 0)
379    MyFree(reply->data);
380  reply->command = 0;
381
382  if (IsDead(server))
383    return;
384
385 nodata:
386  /* If we get here, we need to register for another COMM_SELECT_READ */
387  comm_setselect(fd, COMM_SELECT_READ, read_ctrl_packet, server, 0);
388 }
389
390 /*
274   * iorecv_default - append a packet to the recvq dbuf
275   */
276   void *
# Line 466 | Line 349 | read_packet(fde_t *fd, void *data)
349  
350      execute_callback(iorecv_cb, client_p, length, readBuf);
351  
352 <    if (client_p->lasttime < CurrentTime)
353 <      client_p->lasttime = CurrentTime;
354 <    if (client_p->lasttime > client_p->since)
355 <      client_p->since = CurrentTime;
352 >    if (client_p->localClient->lasttime < CurrentTime)
353 >      client_p->localClient->lasttime = CurrentTime;
354 >    if (client_p->localClient->lasttime > client_p->localClient->since)
355 >      client_p->localClient->since = CurrentTime;
356      ClearPingSent(client_p);
357  
358      /* Attempt to parse what we have */
# Line 479 | Line 362 | read_packet(fde_t *fd, void *data)
362        return;
363  
364      /* Check to make sure we're not flooding */
482    /* TBD - ConfigFileEntry.client_flood should be a size_t */
365      if (!(IsServer(client_p) || IsHandshake(client_p) || IsConnecting(client_p))
366          && (dbuf_length(&client_p->localClient->buf_recvq) >
367 <            (unsigned int)ConfigFileEntry.client_flood))
367 >            get_recvq(client_p)))
368      {
369 <      if (!(ConfigFileEntry.no_oper_flood && IsOper(client_p)))
369 >      if (!(ConfigFileEntry.no_oper_flood && HasUMode(client_p, UMODE_OPER)))
370        {
371          exit_client(client_p, client_p, "Excess Flood");
372          return;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)