Changeset 828
- Timestamp:
- 11/26/08 02:51:23 (3 years ago)
- Location:
- branches/ithildin-1.1/modules/ircd
- Files:
-
- 2 edited
-
connection.h (modified) (2 diffs)
-
protocols/shared/rfc1459_io.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ithildin-1.1/modules/ircd/connection.h
r772 r828 46 46 } stats; 47 47 48 #define IRCD_CONNFL_DNS_PTR 0x149 #define IRCD_CONNFL_DNS_ADDR 0x250 #define IRCD_CONNFL_DNS (IRCD_CONNFL_DNS_PTR | IRCD_CONNFL_DNS_ADDR)51 #define IRCD_CONNFL_IDENT 0x452 #define IRCD_CONNFL_STAGE2 0x848 #define IRCD_CONNFL_DNS_PTR 0x1 49 #define IRCD_CONNFL_DNS_ADDR 0x2 50 #define IRCD_CONNFL_DNS (IRCD_CONNFL_DNS_PTR | IRCD_CONNFL_DNS_ADDR) 51 #define IRCD_CONNFL_IDENT 0x4 52 #define IRCD_CONNFL_STAGE2 0x8 53 53 #define IRCD_CONN_DONE(x) \ 54 54 (((x)->flags & (IRCD_CONNFL_DNS | IRCD_CONNFL_IDENT)) == \ … … 56 56 #define IRCD_CONN_NEED_STAGE2(x) (!((x)->flags & IRCD_CONNFL_STAGE2)) 57 57 58 #define IRCD_CONNFL_WRITEABLE 0x100 /* set if the socket is writeable */58 #define IRCD_CONNFL_WRITEABLE 0x100 /* set if the socket is writeable */ 59 59 #define CONN_PINGSENT(conn) (conn->flags & IRCD_CONNFL_PINGSENT) 60 #define IRCD_CONNFL_PINGSENT 0x200 /* set when a PING is sent to test for61 activity */60 #define IRCD_CONNFL_PINGSENT 0x200 /* set when a PING is sent to test 61 for activity */ 62 62 63 #define IRCD_CONNFL_NOSENDQ 0x400 /* this is set if we don't want to observe 64 send queue limits on the connection 65 (mostly useful for sending 66 synchronization data to servers). it is 67 not unset until sendq drops to 0. */ 63 #define IRCD_CONNFL_NOSENDQ 0x400 /* this is set if we don't want to 64 observe send queue limits on the 65 connection (mostly useful for 66 sending synchronization data to 67 servers). it is not unset until 68 sendq drops to 0. */ 68 69 #ifdef HAVE_OPENSSL 69 #define IRCD_CONNFL_SSLINIT 0x800 /* set when we're waiting for the first 70 data event for an initiating SSL socket. 71 when we get this event we can begin the 72 regular connection initiation. */ 70 #define IRCD_CONNFL_SSLINIT 0x800 /* set when we're waiting for the 71 first data event for an initiating 72 SSL socket. when we get this 73 event we can begin the regular 74 connection initiation. */ 73 75 #endif 76 #define IRCD_CONNFL_DIRTYBUFFER 0x1000 /* set when the contents of the 77 buffer are 'dirty' (typically 78 an overflow command which must 79 be discarded) */ 74 80 75 81 int flags; /* connection flags (DO NOT PUT -
branches/ithildin-1.1/modules/ircd/protocols/shared/rfc1459_io.c
r825 r828 22 22 int ret = 0; 23 23 char *s; 24 bool dirtybuffer; 24 25 25 26 /* If we were force-called (ep is NULL) we assume there is data in our … … 35 36 36 37 while (cp->buflen > 0) { 38 dirtybuffer = false; 37 39 /* if the buffer is full but no terminating character (\n) is 38 40 found, we cheat */ … … 45 47 s++; 46 48 49 /* A command without a newline, add it and note that the 50 * future contents of the buffer are dirty (handled below 51 * when we pass out the data) */ 47 52 if (s == cp->buf + cp->bufsize) { 48 53 cp->buf[cp->bufsize - 1] = '\n'; 49 54 s = cp->buf + cp->bufsize - 1; 55 dirtybuffer = true; 50 56 } 51 57 } else { … … 55 61 break; /* no separator found, try reading some more */ 56 62 } 57 /* make a local copy of the packet, then pass it off to the parser. 58 * Bump the rest of the contents of 'buf' down if we read more than 59 * we have parsed. */ 63 60 64 /* null-terminate and get rid of the [\r]\n sequence. */ 61 65 if (s > cp->buf && *(s - 1) == '\r') … … 63 67 else 64 68 *s = '\0'; 69 65 70 log_debug("[%s] <%s< %s", ircd.me->name, 66 71 (cp->cli != NULL ? cp->cli->nick : 67 72 (cp->srv != NULL ? cp->srv->name : "")), cp->buf); 68 if ((ret = packet_parse(cp)) == IRCD_CONNECTION_CLOSED) 69 return (void *)ret; /* connection closed, stop immediately */ 73 /* Don't parse the packet if the buffer is dirty, otherwise do 74 * call the parser. */ 75 if (!(cp->flags & IRCD_CONNFL_DIRTYBUFFER)) 76 { 77 if ((ret = packet_parse(cp)) == IRCD_CONNECTION_CLOSED) 78 return (void *)ret; /* connection closed, stop immediately */ 79 } else 80 cp->flags &= ~IRCD_CONNFL_DIRTYBUFFER; 81 70 82 s++; /* increment s, now we see if our packet contains more data */ 71 83 if (s - cp->buf < cp->buflen) { … … 77 89 *cp->buf = '\0'; /* zero it out */ 78 90 } 91 92 /* If the buffer is marked dirty, set the flag now on the 93 * connection (since we have passed off the previous command) */ 94 if (dirtybuffer) 95 cp->flags |= IRCD_CONNFL_DIRTYBUFFER; 79 96 80 97 if (ret == IRCD_PROTOCOL_CHANGED) … … 128 145 buf[sm.len++] = ' '; 129 146 130 sm.len += vsnprintf(&buf[sm.len], MAX_PACKET_LEN - 3 - sm.len, msg, 131 args); 147 sm.len += vsnprintf(&buf[sm.len], MAX_PACKET_LEN - sm.len, msg, args); 132 148 } 133 149 … … 139 155 (to != NULL ? to : ""), buf); 140 156 141 strcpy(&buf[sm.len], "\r\n"); 142 sm.len += 2; 157 /* Terminate the command */ 158 if (sm.len > MAX_PACKET_LEN - 2) 159 sm.len = MAX_PACKET_LEN - 2; 160 buf[sm.len++] = '\r'; 161 buf[sm.len++] = '\n'; 143 162 144 163 return &sm;
Note: See TracChangeset
for help on using the changeset viewer.
