Tiny Core Linux

Off-Topic => Off-Topic - Tiny Core Lounge => Topic started by: TTT on February 24, 2020, 08:37:17 PM

Title: tc to support raw socket?
Post by: TTT on February 24, 2020, 08:37:17 PM
good day,

i test tinycore and want to use raw socket.
but seems it donest support raw socket.

anyone know to how to use raw socket for tinycore?

thanks in advance.
Title: Re: tc to support raw socket?
Post by: Rich on February 24, 2020, 08:54:00 PM
Hi TTT
Welcome to the forum.
... but seems it donest support raw socket. ...
I don't know why you would think that. This is how I set up a raw socket:
Code: [Select]
/******************************************************************/
/* Configures the socket for the Sniffer routine */
static void SetupRawSockets(void)
{
sniffersock=socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
fcntl(sniffersock, F_SETFL, fcntl(sniffersock, F_GETFL) | O_NONBLOCK);
return;
}
/******************************************************************/
sniffersock is defined as an int.

You can find the source code it came from here:
http://forum.tinycorelinux.net/index.php/topic,22646.msg141958.html#msg141958
Title: Re: tc to support raw socket?
Post by: TTT on February 25, 2020, 07:02:03 AM
thanks so much. i solve my problem now. ;)
Title: Re: tc to support raw socket?
Post by: Rich on February 25, 2020, 10:33:48 AM
Hi TTT
thanks so much. ...
You are welcome.

If you are new to network programming, this is worth checking out. It doesn't cover raw sockets, but it's easy to understand and
covers important concepts. It also has coding samples:
http://beej.us/guide/bgnet/

Raw sockets means you will likely be packing data structures. This large site covers many protocols and the data layout of
their respective packets:
http://www.tcpipguide.com/free/index.htm