[PATCH] ip_masq_irc.c, kernel 2.2.16

From: Zack Geers (howdy@austin.rr.com)
Date: Tue Aug 01 2000 - 14:21:42 EST


This is an upgrade for the ip_masq_irc.c file, to make it support mIRC's

RESUME feature, it has one shortcoming, but I don't know how ipchains
works well
enough to get around it. I have a global that stores the ip_masq of the
last DCC SEND messsage sent (hopfully two sends won't start within a few
seconds of each other). it's mostly made by copying the the code already
there and modifying it, I have only check it with version 2.04 of mIRC

Zackary Geers


--- ip_masq_irc.c Tue Aug 1 10:28:36 2000
+++ ip_masq_irc.c.good Mon Jul 31 18:25:52 2000
@@ -41,7 +41,6 @@
  * modules.
  *
  */
-/* this also has has support for mIRC's resume feature by Zack Geers */
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -57,6 +56,7 @@
 #include <net/tcp.h>
 #include <net/ip_masq.h>
 
+
 /*
  * List of ports (up to MAX_MASQ_APP_PORTS) to be handled by helper
  * First port is set to the default port.
@@ -73,10 +73,6 @@
 
 MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i");
 
-/* Bad Zack, globals bad!!! it'll only handle one send at a time, but this is best idea so far */
-struct ip_masq *d_ms; /* the ip_masq of the DCC SEND */
-
-
 
 /*
  * List of supported DCC protocols
@@ -119,7 +115,7 @@
         struct sk_buff *skb;
         struct iphdr *iph;
         struct tcphdr *th;
- char *data, *data_limit, *old_data /*for louie's hack*/;
+ char *data, *data_limit;
         __u32 s_addr;
         __u16 s_port;
         struct ip_masq *n_ms;
@@ -161,65 +157,6 @@
                 dcc_p = data;
                 data += 5; /* point to DCC cmd */
 
- old_data = data; /* The second modification by Zack */
-
- if (!memcmp(data,"ACCEPT ",7)) {
-
- data += 7;
-
- while( *data++ != ' ')
- if (data > (data_limit-1)) return 0;
-
- addr_beg_p = data;
-
- /*
- * client bound port in dec base
- */
-
- s_port = simple_strtoul(data,&data,10);
- addr_end_p = data;
-
- /*
- * Look up the DCC SEND's ip_masq struct
- * replaced with the global
- */
-
- /*
- * Replace the old "port" with the new one
- */
-
- buf_len = sprintf(buf,"%u",
- ntohs(d_ms->mport));
-
- /*
- * Calculate required delta-offset to keep TCP happy
- */
-
- diff = buf_len - (addr_end_p-addr_beg_p);
-
- *addr_beg_p = '\0';
- IP_MASQ_DEBUG(1-debug, "masq_irc_out(): '%s' %X:%X detected (diff=%d)\n", dcc_p, s_addr,s_port, diff);
-
- /*
- * No shift.
- */
-
- if (diff==0) {
- /*
- * simple case, just copy.
- */
- memcpy(addr_beg_p,buf,buf_len);
- } else {
-
- *skb_p = ip_masq_skb_replace(skb, GFP_ATOMIC,
- addr_beg_p, addr_end_p-addr_beg_p,
- buf, buf_len);
- }
- return diff;
- }
-
- data = old_data;
-
                 for(i=0; i<NUM_DCCPROTO; i++)
                 {
                         /*
@@ -274,9 +211,6 @@
                                 if (n_ms==NULL)
                                         return 0;
 
- /* hack for Zack's code... store the n_ms for later use*/
- d_ms = n_ms;
-
                                 /*
                                  * Replace the old "address port" with the new one
                                  */
@@ -318,98 +252,6 @@
 
 }
 
-/* Zack's hack for use with mirc so that resume works, lots was borrow from masq_irc_out, but will only handle one dcc send starting at a time */
-int
-masq_irc_in (struct ip_masq_app *mapp, struct ip_masq *ms, struct sk_buff **skb_p, __u32 maddr)
-{
- struct sk_buff *skb;
- struct iphdr *iph;
- struct tcphdr *th;
- char *data, *data_limit;
- __u16 d_port;
- char buf[20]; /* "m_addr m_port" (dec base)*/
- unsigned buf_len;
- int diff;
- char *dcc_p, *addr_beg_p, *addr_end_p;
-
- skb = *skb_p;
- iph = skb->nh.iph;
- th = (struct tcphdr *)&(((char *)iph)[iph->ihl*4]);
- data = (char *)&th[1];
-
- data_limit = skb->h.raw + skb->len;
-
- while (data < (data_limit - 34 ) )
- {
- if (memcmp(data,"\1DCC RESUME ",12)) {
- data ++;
- continue;
- }
-
- dcc_p = data;
- data += 12; /* point to RESUME cmd */
-
- while( *data++ != ' ')
- /*
- * must still parse, at least, "AAAAAAAA P\1\n",
- * 12 bytes left.
- */
- if (data > (data_limit-12)) return 0;
-
- addr_beg_p = data;
-
- /*
- * client bound port in dec base
- */
-
- d_port = simple_strtoul(data,&data,10);
- addr_end_p = data;
-
- /*
- * Look up the DCC SEND's ip_masq struct
- * replaced with the global
- */
-
-
- /*
- * Replace the old "port" with the new one
- */
-
- buf_len = sprintf(buf,"%u",
- ntohs(d_ms->sport));
-
- /*
- * Calculate required delta-offset to keep TCP happy
- */
-
- diff = buf_len - (addr_end_p-addr_beg_p);
-
- *addr_beg_p = '\0';
- IP_MASQ_DEBUG(1-debug, "masq_irc_in(): '%s' %X:%X detected (diff=%d)\n", dcc_p, s_addr,s_port, diff);
-
- /*
- * No shift.
- */
-
- if (diff==0) {
- /*
- * simple case, just copy.
- */
- memcpy(addr_beg_p,buf,buf_len);
- } else {
-
- *skb_p = ip_masq_skb_replace(skb, GFP_ATOMIC,
- addr_beg_p, addr_end_p-addr_beg_p,
- buf, buf_len);
- }
- /*ip_masq_listen(ms);
- ip_masq_put(ms);*/
- return diff;
- }
- return 0;
-}
-
-
 /*
  * Main irc object
  * You need 1 object per port in case you need
@@ -426,7 +268,7 @@
         masq_irc_init_1, /* init_1 */
         masq_irc_done_1, /* done_1 */
         masq_irc_out, /* pkt_out */
- masq_irc_in /* pkt_in */
+ NULL /* pkt_in */
 };
 
 /*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Aug 07 2000 - 21:00:06 EST