LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-14-2006, 01:52 PM   #1
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Rep: Reputation: 31
Accessing TCP flags in TCP packets on Linux using C !!


Hi to all,

i would like some help regarding the following:

I'm trying myself at network programming and I want to access the TCP flags in a TCP packet. I know that in C programming language, the TCP header can be accessed in the following manner:

Code:
const struct ethernet_header *ethernet;
const struct tcp_header *tcp;
const u_char *packet;
ethernet = (struct ethernet_header*) (packet)
tcp = (struct tcp_header*) (packet + size_ethernet + size_ip)
We kind of skip past the ethernet frame and IP packet headers. But I'm having problems with how to access the TCP flags (SYN, ACK, URG, FIN...).

Can anyone help me with this? Any help will be very much appreciated.

Warm regards,
Visham
 
Old 10-14-2006, 06:24 PM   #2
wwwdev
LQ Newbie
 
Registered: Sep 2006
Posts: 6

Rep: Reputation: 0
hi vishamr2000,

Quote:
Originally Posted by vishamr2000

We kind of skip past the ethernet frame and IP packet headers. But I'm having problems with how to access the TCP flags (SYN, ACK, URG, FIN...).

Can anyone help me with this? Any help will be very much appreciated.

Warm regards,
Visham
struct tcpheader {
unsigned short int th_sport;
unsigned short int th_dport;
unsigned int th_seq;
unsigned int th_ack;
unsigned char th_x2:4, th_off:4;
unsigned char th_flags; // TCP flags (SYN, ACK,...)
unsigned short int th_win;
unsigned short int th_sum;
unsigned short int th_urp;
};

See here http://linux.sys-con.com/read/34589_1.htm or google "raw sockets programming".
 
Old 10-16-2006, 09:46 AM   #3
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Many thx for the reply wwwdev..i'll try it and see how it goes.

Warm regards,
Visham
 
  


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
Unusual TCP Packets when running Linux kellinjar Linux - Networking 0 05-23-2006 01:37 AM
what are the ymas and xmas tcp flags used for? crash88 Linux - Networking 1 05-12-2006 12:50 AM
tcp flags Ammad Linux - Security 1 02-02-2006 01:13 PM
TCP-Flags?? X11 Linux - Networking 1 04-09-2002 02:41 AM
--tcp-flags bbenz3 Linux - Networking 2 03-12-2002 04:07 PM


All times are GMT -5. The time now is 03:15 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration