RE: kernel socket programming

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

 



Hi Don,

Correction. The sock already contains the correct proto_ops to use. You
have to decided beforehand which is the sock you want to use. Some
protocols uses int protocol and may include process id to match the
correct sock.

Cheers,
Jonathan

-----Original Message-----
From: owner-kernelnewbies@nl.linux.org
[mailto:owner-kernelnewbies@nl.linux.org] On Behalf Of Jonathan Khoo
Sent: Thursday, October 04, 2001 9:49 AM
To: 'Lee Hock Nang, Don'; kernelnewbies@nl.linux.org
Subject: RE: kernel socket programming


Hi Don,

I recommend Steven's book on TCP/IP Illustrated Vol 2. It is mostly on
BSD, but it gives you an idea on some of the structures you may find in
Linux as well. msghdr and iovec are some examples of similar structures
for Linux and BSD.

Anyway, /usr/src/linux/net/socket.c contains the portion for
sock_sendmsg and sock_recvmsg.

Basically, when you call sock_sendmsg, it calls sock->ops->sendmsg. For
sock_recvmsg, it's sock->ops->recvmsg. sock is struct sock and ops is
struct proto_ops. Depending on what sock you passed into sock_sendmsg,
it searches the correct proto_ops to use.

iovec contains a pointer to iov_base. You may define your own messaging
buffer and pass it into msghdr.

Cheers,
Jonathan

-----Original Message-----
From: owner-kernelnewbies@nl.linux.org
[mailto:owner-kernelnewbies@nl.linux.org] On Behalf Of Lee Hock Nang,
Don
Sent: Thursday, October 04, 2001 9:47 AM
To: kernelnewbies@nl.linux.org
Subject: kernel socket programming



Hi,

I'm new to kernel space socket programming. Searched the web for some
pointers, and only found an article from Linux Magazine on ktftpd.

The source code for ktftpd is no longer available in the ftp server as
stated in the article. Does anyone have the source code?

I wonder is there any sites that I can find more info on kernel space
socket programming. I am currently having problem understanding the
sock_sendmsg() and sock_recvmsg(). And the struct mshhdr, struct iovec.
Also the socket buffer.

Many thanks, and have a nice day.

Don

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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