LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-28-2011, 08:21 AM   #1
santosh20
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
How to indenfy the real physical network interface?


Hi,

I have a wireless device running on Linux 2.6.15. (Can't upgrade to latest at this time).

It has 3 interfaces.
ath0 - Radio interface.
eth0 - Ethernet interface.
br0 - Bridge interface joining ath0 and eth0.

I have a user space socket program that listens to the broadcast messages
and responds.
I need this socket program to listen for the messages coming from
Ethernet interface only.
Or, this socket program should be able to figure out the actual
interface the message come from.

I tried below methods but both doesn't help me because it seems like
kernel is not providing real interface name to socket programs.

1. //setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, "br0", 3)
setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, "eth0", 4)

2. setsockopt(sock, SOL_IP, IP_PKTINFO, (char *) &on, sizeof on)
// Use recvmsg instead of recvfrom and read the interface index.
// If interface is not Ethernet do not respond.

Can you please let me know if there is a way to identify the actual
interface in a UDP socket program when traffic is controlled by a
Bridge?


Thanks,
Santosh Yadawar
 
Old 07-28-2011, 02:08 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
What kind of broadcast messages do you tale about, UDP or something else?
 
Old 07-29-2011, 04:12 AM   #3
santosh20
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nini09 View Post
What kind of broadcast messages do you tale about, UDP or something else?
UDP.
My socket is opened as sock = socket(PF_INET, SOCK_DGRAM, 0).


Thanks,
Santosh
 
Old 07-29-2011, 02:46 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
You can use bind() function to indicate what IP address is used. An IP address will associate with one interface.
 
  


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
Virtual Network Interface provided by 2 physical interfaces? ewolf Linux - Networking 1 07-29-2008 12:53 PM
How to determine which physical interface corresonds to eth0, eth1, eth2, and eth3 karrj Linux - Newbie 5 05-01-2008 07:44 AM
how can i shutdown the PHYSICAL interface of an ethernet interface markraem Linux - Networking 2 04-12-2007 02:29 PM
Forwarding from physical to virtual interface? heltendk Linux - Networking 8 01-11-2007 11:22 AM
is there a way to make a 'real' virtual interface? Taishan269 Linux - Networking 0 12-17-2003 02:33 PM

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

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