Re: how to

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Li, Chanjuan escreveu:
在 2008-12-16二的 07:57 -0200,Alan Menegotto写道:
Li, Chanjuan escreveu:
hi,all:
I am a newbie on linux kernel. now I encountered a problem on socket in kernel space.I create a SOCK_DGRAM socket in kernel space . What I want to do can
be described as follows:
  while(1){
        if( packet received)
                   call packet handler
}

my problem is how to know packet received at kernel space. In user space there is select() to use, but in kernel space, there is no such function. I have read sk_buff and struct sock definition to find some hint, but still have no idea. I think it is a good place to ask for help. thanks in advance.


lily
Are you writing a protocol or sending/receiving datagrams on kernel space?
I am writing a protocol. but because I am newbie on linux kernel,so I do a simple exercise first.

lily
Best Regards

Alan Menegotto


So you must create a struct proto (see an example on net/ipv4/tcp_ipv4.c) where you'll register a handler for every protocol operation (connect, sendmsg, recvmsg, etc...). Then you'll use the created struct on net/ipv4/af_inet.c. There are some constants to define too.

Look the source code of another protocol (like tcp, udp or dccp) to guide you thru' the structs creation and protocol initialization. It's kinda like a cook recipe.

When the structs are created and the protocol inserted on the kernel, just write the action handlers defined on your structures.


Best Regards

Alan Menegotto



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux