Click to See Complete Forum and Search --> : WCCP


flar
12-14-2000, 12:31 AM
i just need this one to compile as a network module. how it is to be done? (sori)


/*
* $Id: ip_wccp.c,v 1.1 1999/09/30 20:43:37 wessels Exp $
*
* Glenn Chisholm <glenn@ircache.net>
*/

#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/in.h>
#include <linux/if_arp.h>
#include <linux/init.h>
#include <linux/inetdevice.h>

#include <netinet/ip.h>

#define WCCP_PROTOCOL_TYPE 0x883E
#define WCCP_GRE_LEN sizeof(long)

int ip_wccp_rcv(struct sk_buff *skb, unsigned short len)
{
long *gre_hdr;

gre_hdr = (unsigned long *)skb->h.raw;
if(*gre_hdr != htonl(WCCP_PROTOCOL_TYPE))
goto drop;

skb->mac.raw = skb->nh.raw;
skb->nh.raw = skb_pull(skb, skb->h.raw + WCCP_GRE_LEN - skb->data);

if (skb->len <= 0)
goto drop;

memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
skb->protocol = __constant_htons(ETH_P_IP);
skb->pkt_type = PACKET_HOST;
skb->ip_summed = 0;
dst_release(skb->dst);
skb->dst = NULL;

return ip_rcv(skb, skb->dev, NULL);

drop:
kfree_skb(skb);
return(0);
}

static struct inet_protocol ipgre_protocol = {
ip_wccp_rcv,
NULL,
0,
IPPROTO_GRE,
0,
NULL,
"GRE"
};

int init_module(void)
{
printk(KERN_INFO "WCCP IPv4/GRE driver\n");
inet_add_protocol(&ipgre_protocol);
return 0;
}

void cleanup_module(void)
{
if ( inet_del_protocol(&ipgre_protocol) < 0 )
printk(KERN_INFO "ipgre close: can't remove protocol\n");
else
printk(KERN_INFO "WCCP IPv4/GRE driver unloaded\n");
}



-flar-

flar
12-15-2000, 06:41 PM
does anyone knows how is this to be done? pls! http://www.linuxnewbie.org/ubb/frown.gif

-flar-

PLBlaze
12-15-2000, 10:11 PM
To compile ip_wccp you need to issue the same command as the one used to compile kernel modules (gcc -DHAVE_KERNEL -DMODULES_VER -wno-strict-aliasing -pipe ip_wccp.o -c).Sorry, can't remember it all but once i get home i'll post here.

flar
12-15-2000, 11:58 PM
k! am waitin. coz i need this to work fine. BTW am running Mandrake6.0 (Linux 2.2.9-12)

thanks in advance

PLBlaze
12-16-2000, 03:16 AM
:Here i come: http://www.linuxnewbie.org/ubb/biggrin.gif


Try this gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=686 -DMODULE -c ip_wccp.c


Note the -m486 and -DCPU=i686 flags,make sure to addjust them to your arch and cpu ,eg. 386,586 etc...


I'd suggest that you upgrade to latest 2.2.18 kernel to insure better compatibility and security this kernel release offers.Let me know if it worked for you.Good luck http://www.linuxnewbie.org/ubb/smile.gif.

[This message has been edited by PLBlaze (edited 16 December 2000).]

flar
12-16-2000, 07:51 PM
it didnt! http://www.linuxnewbie.org/ubb/frown.gif it says a bunch of 'invalid' and a bunch of 'warning'(but i think warning r ok right?) it didnt even give a file ip_wccp.o

here are the errors:


In file included from /usr/include/netinet/in.h:27,
from /usr/include/netinet/ip.h:25,
from ip_wccp.c:19:
/usr/include/bits/socket.h:40: parse error before `1'
In file included from /usr/include/bits/socket.h:133,
from /usr/include/netinet/in.h:27,
from /usr/include/netinet/ip.h:25,
from ip_wccp.c:19:



-flar-

PLBlaze
12-16-2000, 08:16 PM
Since you run on 2.2.9 kernel maybe that's why or perhaps the module build command i gave is wrong.Try build modules for your kernel make modules in /usr/src/linux and you'll see the exact command that your system uses to build modules,maybe try that one.

Sorry but on my box i get no warnings and module build just fine i can even insmod it,iremember someone else i was helping with ip_wccp had similar problem but i think that person gave up on it.If you need more info or help or perhaps the module (could alter kernel version using a hex editor to match yours) i've build let me know.

flar
12-17-2000, 12:39 AM
ok. ill get back here whatever happens. am not giving up on this! i swear http://www.linuxnewbie.org/ubb/mad.gif

-flar-

PLBlaze
12-18-2000, 01:08 AM
Did you get it to work yet? if not check your email and take a look at this url http://www.spc.int/it/TechHead/Wccp-squid.html .Hope this helps.

flar
12-18-2000, 04:08 AM
yes! iv compiled it already! but here's another problem. (damn!)


#insmod ip_wccp
./ip_wccp.o: unresolved symbol __kfree_skb
./ip_wccp.o: unresolved symbol inet_del_protocol
./ip_wccp.o: unresolved symbol inet_add_protocol
./ip_wccp.o: unresolved symbol ip_rcv
./ip_wccp.o: unresolved symbol printk


can anyone help me with this? (or is there a problem with the code)

p.s.

thanks much PAUL ur a great help (but i need help on this next prob http://www.linuxnewbie.org/ubb/smile.gif )


[This message has been edited by flar (edited 18 December 2000).]

flar
12-18-2000, 06:02 AM
yes! http://www.linuxnewbie.org/ubb/smile.gif iv got it working on slack7.1 but not yet on mandrake. http://www.linuxnewbie.org/ubb/smile.gif thanks PAUL

-flar-

PLBlaze
12-18-2000, 12:33 PM
Great http://www.linuxnewbie.org/ubb/biggrin.gif ,

Originaly i've compiled the modules under slack too...have you put the module in /lib/modules/<kernel name>/net and run depmod -a?
You might try this to set the dependencies,after that all the unresolved symbols should go away.Yet again hope this helps.

flar
12-19-2000, 02:12 AM
i think it should be in /lib/modules/<kernel>/ipv4 (right?) but then i tried to put it in 'net' and d error is the same. it says 'unresolve symbols'


#depmod -a -e
/lib/modules/2.2.9-19mdk/net/ip_wccp.o: unresolved symbol(s)
__kfree_skb
inet_del_protocol
inet_add_protocol
ip_rcv
printk



the problem is still unresolve http://www.linuxnewbie.org/ubb/mad.gif

-flar-

[This message has been edited by flar (edited 19 December 2000).]

flar
12-23-2000, 05:32 AM
GUESS WHAT??!! i did it!! hehehehe. said to u all that i wont give up eh?? hehehe damn! wccp. i upgraded to 2.2.18 and *whosh* it damn work. then i shift to 2.3.stable4 squid. and add rules on my routing from my router and some configs on my squid. thanks much to paul (PLBLAZE). ur a great help man!

-flar-

[This message has been edited by flar (edited 23 December 2000).]