aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/libalias/alias_irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/libalias/alias_irc.c')
-rw-r--r--sys/netinet/libalias/alias_irc.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/sys/netinet/libalias/alias_irc.c b/sys/netinet/libalias/alias_irc.c
index ed8e9a95926d..32e831742048 100644
--- a/sys/netinet/libalias/alias_irc.c
+++ b/sys/netinet/libalias/alias_irc.c
@@ -91,13 +91,12 @@ char *newpacket;
#define DBprintf(a)
static void
-AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *,
- int maxpacketsize);
+AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *,
+ int maxpacketsize);
static int
fingerprint(struct libalias *la, struct alias_data *ah)
{
-
if (ah->dport == NULL || ah->lnk == NULL || ah->maxpktsize == 0)
return (-1);
if (ntohs(*ah->dport) == IRC_CONTROL_PORT_NUMBER_1
@@ -109,7 +108,6 @@ fingerprint(struct libalias *la, struct alias_data *ah)
static int
protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
{
-
newpacket = malloc(PKTSIZE);
if (newpacket) {
AliasHandleIrcOut(la, pip, ah->lnk, ah->maxpktsize);
@@ -157,7 +155,7 @@ moduledata_t alias_mod = {
};
/* Kernel module definition. */
-#ifdef _KERNEL
+#ifdef _KERNEL
DECLARE_MODULE(alias_irc, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
MODULE_VERSION(alias_irc, 1);
MODULE_DEPEND(alias_irc, libalias, 1, 1, 1);
@@ -178,7 +176,7 @@ AliasHandleIrcOut(struct libalias *la,
struct tcphdr *tc;
int i; /* Iterator through the source */
-/* Calculate data length of TCP packet */
+ /* Calculate data length of TCP packet */
tc = (struct tcphdr *)ip_next(pip);
hlen = (pip->ip_hl + tc->th_off) << 2;
tlen = ntohs(pip->ip_len);
@@ -191,7 +189,7 @@ AliasHandleIrcOut(struct libalias *la,
if (dlen < (int)sizeof(":A!a@n.n PRIVMSG A :aDCC 1 1a") - 1)
return;
-/* Place string pointer at beginning of data */
+ /* Place string pointer at beginning of data */
sptr = (char *)pip;
sptr += hlen;
maxsize -= hlen; /* We're interested in maximum size of
@@ -204,7 +202,7 @@ AliasHandleIrcOut(struct libalias *la,
}
return; /* No CTCP commands in */
/* Handle CTCP commands - the buffer may have to be copied */
-lFOUND_CTCP:
+ lFOUND_CTCP:
{
unsigned int copyat = i;
unsigned int iCopy = 0; /* How much data have we written to
@@ -213,7 +211,7 @@ lFOUND_CTCP:
unsigned short org_port; /* Original source port
* address */
-lCTCP_START:
+ lCTCP_START:
if (i >= dlen || iCopy >= PKTSIZE)
goto lPACKET_DONE;
newpacket[iCopy++] = sptr[i++]; /* Copy the CTCP start
@@ -413,7 +411,7 @@ lCTCP_START:
* has been pushed. Also used to copy the rest of a DCC,
* after IP address and port has been handled
*/
-lBAD_CTCP:
+ lBAD_CTCP:
for (; i < dlen && iCopy < PKTSIZE; i++, iCopy++) {
newpacket[iCopy] = sptr[i]; /* Copy CTCP unchanged */
if (sptr[i] == '\001') {
@@ -422,7 +420,7 @@ lBAD_CTCP:
}
goto lPACKET_DONE;
/* Normal text */
-lNORMAL_TEXT:
+ lNORMAL_TEXT:
for (; i < dlen && iCopy < PKTSIZE; i++, iCopy++) {
newpacket[iCopy] = sptr[i]; /* Copy CTCP unchanged */
if (sptr[i] == '\001') {
@@ -430,16 +428,16 @@ lNORMAL_TEXT:
}
}
/* Handle the end of a packet */
-lPACKET_DONE:
+ lPACKET_DONE:
iCopy = iCopy > maxsize - copyat ? maxsize - copyat : iCopy;
memcpy(sptr + copyat, newpacket, iCopy);
-/* Save information regarding modified seq and ack numbers */
+ /* Save information regarding modified seq and ack numbers */
{
int delta;
SetAckModified(lnk);
- tc = (struct tcphdr *)ip_next(pip);
+ tc = (struct tcphdr *)ip_next(pip);
delta = GetDeltaSeqOut(tc->th_seq, lnk);
AddSeq(lnk, delta + copyat + iCopy - dlen, pip->ip_hl,
pip->ip_len, tc->th_seq, tc->th_off);
@@ -469,20 +467,20 @@ lPACKET_DONE:
}
/* Notes:
- [Note 1]
- The initial search will most often fail; it could be replaced with a 32-bit specific search.
- Such a search would be done for 32-bit unsigned value V:
- V ^= 0x01010101; (Search is for null bytes)
- if( ((V-0x01010101)^V) & 0x80808080 ) {
+ [Note 1]
+ The initial search will most often fail; it could be replaced with a 32-bit specific search.
+ Such a search would be done for 32-bit unsigned value V:
+ V ^= 0x01010101; (Search is for null bytes)
+ if( ((V-0x01010101)^V) & 0x80808080 ) {
(found a null bytes which was a 01 byte)
- }
- To assert that the processor is 32-bits, do
+ }
+ To assert that the processor is 32-bits, do
extern int ircdccar[32]; (32 bits)
extern int ircdccar[CHAR_BIT*sizeof(unsigned int)];
- which will generate a type-error on all but 32-bit machines.
+ which will generate a type-error on all but 32-bit machines.
- [Note 2] This routine really ought to be replaced with one that
- creates a transparent proxy on the aliasing host, to allow arbitrary
- changes in the TCP stream. This should not be too difficult given
- this base; I (ee) will try to do this some time later.
- */
+ [Note 2] This routine really ought to be replaced with one that
+ creates a transparent proxy on the aliasing host, to allow arbitrary
+ changes in the TCP stream. This should not be too difficult given
+ this base; I (ee) will try to do this some time later.
+*/