LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-03-2011, 01:24 PM   #1
rrlangly
Member
 
Registered: Dec 2009
Posts: 47

Rep: Reputation: 0
differences betwee socket and sock


I'm writing a protocol to go on top of TCP within a kernel module and defined the (create) callback.

static const struct net_proto_family my_family_ops = {
.family = PF_MYPROTO,
.create = my_create,
.owner = THIS_MODULE,
};

When I create a socket from userspace ...

sockfd = socket(PF_MYPROTO, SOCK_STREAM, NEW_PROTO);

... the (create) callback in the net_proto_family struct is invoked. And within this callback is where I'm assuming I'd make a call like the following in order to create the socket for which I will then later call a connect function to a remote host (from the proto_ops callback).
sock_create(PF_INT, SOCK_STREAM, IPPROTO_TCP, &s)

What's confusing me is the (create) callback function has a signature like ...

static int my_create(struct net *net, struct socket *sock, int protocol, int kern);

My book doesn't say much other than that memory for *sock has been reserved and creates a new instance of a kernel-internal sock socket, intializes it as far as possible, and inserts it in the kernel data structures. I'm not sure if the socket has been created, or if I need to call that sock_create function. I'm not sure what this socket is that's being passed in.

Can someone talk about the differences between sock and socket structures and help with which one I should use and store for other socket calls down the road such as connect, bind, accept, listen, etc...

Last edited by rrlangly; 02-05-2011 at 01:18 PM.
 
Old 02-05-2011, 01:26 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
The question is where you want the header be added. Inside a TCP message? Inside a TCP header? In all TCP packets (ACKS etc)?
 
Old 02-07-2011, 11:06 PM   #3
rrlangly
Member
 
Registered: Dec 2009
Posts: 47

Original Poster
Rep: Reputation: 0
So, by ride on top of TCP, I am trying to add the header of my own transport into the payload of TCP.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Access TCP Header SEQ yaplej Programming 4 08-08-2011 04:01 AM
How to insert header once in bash script manya Programming 1 08-24-2009 04:58 AM
[raw sockets, C] tcp header cut darell Programming 2 10-09-2008 11:04 AM
TCP header checksum live_dont_exist Programming 16 04-13-2005 12:45 PM
catch the tcp header for modification from the kernel mprabhu Linux - Software 2 07-24-2004 04:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration