LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-22-2009, 05:45 AM   #1
abhishek@LQ
LQ Newbie
 
Registered: May 2009
Posts: 5

Rep: Reputation: 0
How to get reference to "sock" structure related to particular socket descriptor


Hi,

I am developing an application which requires me to add some more variable in struct sock inside linux kernel. (like adding a new int auth_level, int key etc.)

Now to set these fields, I am writing a system call which the applications need to invoke whenever they want to set values of these newly added varialbe. My system call is like

modifySocket(int sockfd, value1, value2 ...)

So, now to set values newly added variables in sock structure, i need have referece to that sock structure. As input I can not ask anything more than sockfd (socket descriptor).

Can anybody help by suggesting a way to accomplish this?

By following kernel codes of sys_send and sys_sendto functions I came to know about sockfd_lookup() function. But this is of no use to me as it returns reference to socket structure and not to sock structure.

Is there any way to get reference to sock structure from socket structure?

Sorry if questions are silly, but I am very new to kernel programming and dont know about structures and functionalities available.

Thank You.
 
Old 05-24-2009, 11:07 AM   #2
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 299

Rep: Reputation: 62
You can get to the sock structure from the socket structure. Look for the structure member defined as "struct sock *" i.e. a pointer to a sock structure.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Socket Programming making use of "select()" and "writefds" johncsl82 Programming 10 11-13-2011 12:27 PM
"Multiple definition of" and "undefined reference to" in QT Creator with QJson lib echelon89 Programming 1 05-01-2009 06:48 AM
differences between "struct sock" and "struct socket" ahm_irf Programming 4 03-30-2009 10:29 AM
Buzilla issue: "Can't connect to local MySQL server through socket '/tmp/mysql.sock'" vitopn Linux - General 3 05-21-2007 10:13 AM
Wireless : cardmgr[4292] : Open sock(socket 1) failed: Bad file descriptor mahendra Fedora 1 12-07-2004 04:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:05 PM.

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