--------------423CD1C81ACF6917391749EB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
HI,
This quick hack to play Quake over the net with Masquerading-Support.
I know that the initial Datastream has to be checked against
a string like "\200\0\0\f\1QUAKE\0\3", but it's to late now and I have
to study a lot in the next weeks.
The File ip_masq_quake.c is attached. You may put it in your
/usr/src/linux/net/ipv4 Directory, add ip_masq_quake.o to the other
Masquerading-Modules in the Makefile, compile, load the module
and stomp the other players to the ground!
Keep on hacking,
Harald
-- Harald Hoyer saturn@studbox.uni-stuttgart.de http://saturnnet.wh.uni-stuttgart.de/~saturn ------------------------------------------------------------------------- > Someone: > Asking Linus to add such things in the kernel is as pertinent as asking > to still support 80286 CPU (IMHO). We are working on it. Alan Cox--------------423CD1C81ACF6917391749EB Content-Type: text/plain; charset=us-ascii; name="ip_masq_quake.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ip_masq_quake.c"
/* * IP_MASQ_QUAKE quake masquerading module * * * Version: @(#)ip_masq_quake.c 0.01 22/02/97 * * Author: Harald Hoyer * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * */
#include <linux/module.h> #include <asm/system.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/skbuff.h> #include <linux/in.h> #include <linux/ip.h> #include <net/protocol.h> #include <net/tcp.h> #include <net/ip_masq.h>
static int masq_quake_init_1 (struct ip_masq_app *mapp, struct ip_masq *ms) { MOD_INC_USE_COUNT; return 0; }
static int masq_quake_done_1 (struct ip_masq_app *mapp, struct ip_masq *ms) { MOD_DEC_USE_COUNT; return 0; }
int masq_quake_in (struct ip_masq_app *mapp, struct ip_masq *ms, struct sk_buff **skb_p, struct device *dev) { struct sk_buff *skb; struct iphdr *iph; __u16 *portptr, s_port;
if(!(ms->flags & IP_MASQ_F_NO_DPORT)) return 0;
skb = *skb_p; iph = skb->nh.iph; portptr = (__u16 *)&(((char *)iph)[iph->ihl*4]); s_port = portptr[0]; if(s_port == ms->dport) return 0;
ms->dport = s_port; ms->flags &= ~IP_MASQ_F_NO_DPORT; return 0; }
int masq_quake_out (struct ip_masq_app *mapp, struct ip_masq *ms, struct sk_buff **skb_p, struct device *dev) { /* SHOULD CHECK DATA "\200\0\0\f\1QUAKE\0\3" or something like that */
if(!(ms->flags & IP_MASQ_F_NO_DPORT)) { ms->flags |= IP_MASQ_F_NO_DPORT; }
return 0; }
struct ip_masq_app ip_masq_quake = { NULL, /* next */ "Quake_26", /* name */ 0, /* type */ 0, /* n_attach */ masq_quake_init_1, /* ip_masq_init_1 */ masq_quake_done_1, /* ip_masq_done_1 */ masq_quake_out, /* pkt_out */ masq_quake_in /* pkt_in */ }; struct ip_masq_app ip_masq_quakenew = { NULL, /* next */ "Quake_27", /* name */ 0, /* type */ 0, /* n_attach */ masq_quake_init_1, /* ip_masq_init_1 */ masq_quake_done_1, /* ip_masq_done_1 */ masq_quake_out, /* pkt_out */ masq_quake_in /* pkt_in */ };
/* * ip_masq_quake initialization */
int ip_masq_quake_init(void) { return (register_ip_masq_app(&ip_masq_quake, IPPROTO_UDP, 26000) + register_ip_masq_app(&ip_masq_quakenew, IPPROTO_UDP, 27000)); }
/* * ip_masq_quake fin. */
int ip_masq_quake_done(void) { return (unregister_ip_masq_app(&ip_masq_quake) + unregister_ip_masq_app(&ip_masq_quakenew)); }
#ifdef MODULE
int init_module(void) { if (ip_masq_quake_init() != 0) return -EIO; register_symtab(0); return 0; }
void cleanup_module(void) { if (ip_masq_quake_done() != 0) printk("ip_masq_quake: can't remove module"); }
#endif /* MODULE */
--------------423CD1C81ACF6917391749EB--