LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 04-01-2015, 02:37 AM   #1
moonsaint
LQ Newbie
 
Registered: Mar 2015
Posts: 1

Rep: Reputation: Disabled
How can I get conntrack info by C function?


Now we can use conntrack tool to get these info, but if I want to get these info in my program, how can I get conntrack info such as "conntrack -L". My program is running on user space, so kernel module is an unuseful choice. And use cmd mode will lack efficiency.

e.g. I use iptables nat to revert all the tcp connection of some users to port 10000, and my program is listening to this port, I want to get the original ports of the accepted tcp connection, so I need conntrack info.

Last edited by moonsaint; 04-01-2015 at 02:44 AM. Reason: add the example
 
Old 04-01-2015, 06:00 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,881
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
You can do a couple of things. You could do it direct and messy, which is to say that you can run conntrack from within your C program, cause the results to be piped to a file, and then open that file from within your C program and process the results. Another variation of that would be to run conntrack periodically by the use of a script or service, monitor updates to an output log file or have a signal of some sort to your C program and then process the newest results. Another option is to download the conntrack sources and use the relevant parts of that within your own C program.
 
  


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
Javascript/AJAX - TABS - href info based on function() calls - HOW TO GET DATA??? pizzipie Programming 3 06-16-2015 09:00 PM
[Powershell] Function Invocation Info nikunjbadjatya Programming 3 03-27-2013 05:10 PM
info() function WayneK Linux - Kernel 1 07-20-2010 03:14 PM
conntrack and connmark rhine2 Linux - Networking 6 11-25-2009 07:05 AM
IPTables/Conntrack MikeQ Linux - Server 1 08-04-2009 01:02 PM

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

All times are GMT -5. The time now is 08:18 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