Networking Forums

Networking Forums > Computer Networking > Linux Networking > linux networking at kernel level

Reply
Thread Tools Display Modes

linux networking at kernel level

 
 
84.le0n@gmail.com
Guest
Posts: n/a

 
      11-07-2008, 02:07 PM
Hi all, i'm a newbie of this list
i'm studying linux kernel 2.6.26.7 sourcecode for my thesis because
i've to create a kernel module that reads and writes tcp/ip packets;
for example i've to read infos from tcp and ip header and then route
to destination through an interface that i want from those that i've
installed on my pc (wireless, ethernet...) .
my work is similar to some phrack article [1]-[2] but that are for
very old kernels (2.2 or 2.4 series) so i can't use them at all.
i've found more recent document [3] that uses 2.6.22.5 kernel source
but the same functions now request another parameter that is a "struct
net * " .

i've done a simple test module that drop all packets incoming by
setting
pre_hook.hook = watch_in; // this function
will
//return NF_DROP
pre_hook.pf = PF_INET;
pre_hook.priority = NF_IP_PRI_FIRST;
pre_hook.hooknum = NF_INET_PRE_ROUTING;
but i can't make an ip address filter dropping.

now, my questions are:
- in [2] there is "dev_get" function that return a struct device from
a char* , in newer kernels i've found "dev_get_by_name" but that
function wants a "struct net *": it has to be a newly defined struct
or i've to to get existent one? if i've to to get existent one, how
can i do that ?
same question about "struct net *" for "for_each_netdev" function used
in [3]

- to use "for_each_netdev" as told above, i can't use *dev_net
function, defined in netdevice.h, to find a "struct net" from "struct
net_device" because it wants a *net_device (i'm inside a loop!).

- how can i read information in received packet ?
for example, to read the source ip address of a received packet, i've
to do only "ip_hdr(skb)->saddr" ?
can i print it on /var/log/messages ?

- if i want to write in the same field of outgoing packet can i use
"ip_hdr(skb)->saddr" again or there is a defined function to do this ?


[1] "building inte the linux kernel network driver"
[2] "hacking the linux kernel network stack"
[3] http://www.cs.usfca.edu/~cruse/cs686/netdevs.c


Thank you for your answers!
 
Reply With Quote
 
 
 
 
talau
Guest
Posts: n/a

 
      11-16-2008, 11:27 AM
On 7 nov, 13:07, 84.l...@gmail.com wrote:
> Hi all, i'm a newbie of this list
> i'm studying linux kernel 2.6.26.7 sourcecode for my thesis because
> i've to create a kernel module that reads and writes tcp/ip packets;
> for example i've to read infos from tcp and ip header and then route
> to destination through an interface that i want from those that i've
> installed on my pc (wireless, ethernet...) .
> my work is similar to some phrack article [1]-[2] but that are for
> very old kernels (2.2 or 2.4 series) so i can't use them at all.
> i've found more recent document [3] that uses 2.6.22.5 kernel source
> but the same functions now request another parameter that is a "struct
> net * " .
>
> i've done a simple test module that drop all packets incoming by
> setting
> pre_hook.hook = watch_in; // this function
> will
> //return NF_DROP
> pre_hook.pf = PF_INET;
> pre_hook.priority = NF_IP_PRI_FIRST;
> pre_hook.hooknum = NF_INET_PRE_ROUTING;
> but i can't make an ip address filter dropping.
>
> now, my questions are:
> - in [2] there is "dev_get" function that return a struct device from
> a char* , in newer kernels i've found "dev_get_by_name" but that
> function wants a "struct net *": it has to be a newly defined struct
> or i've to to get existent one? if i've to to get existent one, how
> can i do that ?
> same question about "struct net *" for "for_each_netdev" function used
> in [3]
>
> - to use "for_each_netdev" as told above, i can't use *dev_net
> function, defined in netdevice.h, to find a "struct net" from "struct
> net_device" because it wants a *net_device (i'm inside a loop!).
>
> - how can i read information in received packet ?
> for example, to read the source ip address of a received packet, i've
> to do only "ip_hdr(skb)->saddr" ?
> can i print it on /var/log/messages ?
>
> - if i want to write in the same field of outgoing packet can i use
> "ip_hdr(skb)->saddr" again or there is a defined function to do this ?
>
> [1] "building inte the linux kernel network driver"
> [2] "hacking the linux kernel network stack"
> [3]http://www.cs.usfca.edu/~cruse/cs686/netdevs.c
>
> Thank you for your answers!


Ask on kernelnewbies mailinglist, you'll get more answers :-)

talau.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in Networking at Kernel Level Prafulla T Linux Networking 11 01-02-2007 03:11 AM
Wireless networking and the Linux kernel Gregg C Levine Linux Networking 4 10-08-2004 10:09 AM
Full network level broadcast in Linux amesser39@hotmail.com Linux Networking 1 11-10-2003 03:51 PM
Accessing second level network via linksys router and linux box Dave Linux Networking 1 09-14-2003 02:31 AM
Problem with networking - I am using RedHat 9 Linux kernel 2.4 Graham Jones Linux Networking 1 07-29-2003 01:13 PM



1 2 3 4 5 6 7 8 9 10 11