Re: How can I get the source MAC address from a TCP socket?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dan Searle wrote:
> Hi,
> 
> I am developing a TCP server using the standard, socket(), bind(),
> listen() and accept() calls to implement a TCP server in user land.
> 
> I have searched the web but can't find anything useful regarding a
> problem I am having...
> 
> My question is, given that I have a TCP socket file descriptor as
> returned by accept() as follows:
> 
> sock = accept(s_sock, (struct sockaddr *)addr, (socklen_t *)&addr_length);
> 
> Is there a way, using an IOCTL or SYSCALL to get down the protocol
> stack to retrieve the source MAC address of the new TCP socket that
> accept() returns a file descriptor for?
> 
> My server needs to know the source MAC of TCP connections to it, so
> that I can make decisions on how to handle the request based on the
> source MAC address.
> 
> At present I am using a messy call to popen() calling the arp program
> in a shell. I tried looking up /proc/net/arp directly, but sometimes
> there is no ARP entry in the cache, even though the accept() call
> succeeded and I have a new TCP socket.
> 
> Regards, Dan...
> 
> --

After reading Matti's response, I'd like you to clarify this.  Are you
looking for the MAC address of the machine that the code is running on,
or some remote client?

- --
Topher Fischer
GnuPG Fingerprint: 3597 1B8D C7A5 C5AF 2E19  EFF5 2FC3 BE99 D123 6674
javert42@xxxxxxxxxx | http://www.thetopher.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGhDhQL8O+mdEjZnQRAj2MAJ9oNW02NomngIQlghxmXFMccWB0hgCeKe+o
IGq6QgUYpIjMu/t+rg8tS8U=
=lt10
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux