Skip to contentSkip to conversation

Raw Sockets

DISCUSSION Igor A. Deruga 2 participants 2 messages Dec 19, 2004

lore
Share & tools
lore
#0 lore raw

Greetings, fellows!

Hope you'll be able to help me with your useful advice...
I need to establish a connection using a Raw socket. That's what I'm doing:

int sock = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);

 sockaddr_ll addr;
        addr.sll_family = AF_PACKET;
        addr.sll_protocol = 0;
        addr.sll_ifindex = 0;
        addr.sll_hatype = 0;
        addr.sll_pkttype = 0;
        addr.sll_halen = 0;

But where can I get a value for addr.sll_addr? And what is it? "man 7 packet" sais it's a Physical layer address, which is MAC, i guess... so, how do I retreive it?

If it's possible, could anybody send me an example that uses sockaddr_ll to SEND packets via RAW SOCKET? That'd be great!

Sincerely
Igor

P.S.: I've set the encoding to iso-8859-5. Hope this time it goes through...

#1 lore raw

i dont know how to use raw sockets....
but u could try using "ifconfig" (located usually in the /sbin directory) to get the mach address...

*the mach address(or hwaddr is usually shown on the first line of the output)

hope this helps.

Quoted 31 lines · Igor A. Deruga

Greetings, fellows!

Hope you'll be able to help me with your useful advice...
I need to establish a connection using a Raw socket. That's what I'm doing:

int sock = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);

sockaddr_ll addr;
       addr.sll_family = AF_PACKET;
       addr.sll_protocol = 0;
       addr.sll_ifindex = 0;
       addr.sll_hatype = 0;
       addr.sll_pkttype = 0;
       addr.sll_halen = 0;

But where can I get a value for addr.sll_addr? And what is it? "man 7 packet" sais it's a Physical layer address, which is MAC, i guess... so, how do I retreive it?

If it's possible, could anybody send me an example that uses sockaddr_ll to SEND packets via RAW SOCKET? That'd be great!

Sincerely
Igor

P.S.: I've set the encoding to iso-8859-5. Hope this time it goes through... -
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html