Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-22-2014, 04:35 AM   #1
Registered: Jul 2014
Posts: 65

Rep: Reputation: Disabled
Question how to set the crc for the frame of raw socket programming

how to set the crc for the frame of raw socket programming

after googled the following function

which input are valid for it?

if frame size = 14 (header) + 46(data) + 4 (crc)

is the length parameter = 46?
is *data = the data in char[46] data, memcpy(&data, &msg[14], 46) ?

what is foxes?

ether_crc_le(int length, u8_t *data, int foxes)

// Generating polynomial:
const uint32_t ethernet_polynomial_le = 0xedb88320U;

//bit-oriented implementation: processes a byte array.
unsigned ether_crc_le(int length, u8_t *data, int foxes)
unsigned int crc = (foxes) ? 0xffffffff: 0; /* Initial value. */
while(--length >= 0)
unsigned char current_octet = *data++;
int bit;
// printf("%02X, %08X, inv %08X\n", current_octet, crc, ~crc);

for (bit = 8; --bit >= 0; current_octet >>= 1) {
if ((crc ^ current_octet) & 1) {
crc >>= 1;
crc ^= ethernet_polynomial_le;
} else
crc >>= 1;
// printf("crc final %x\n", crc);
return crc;


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
Raw socket programming with C arabindav Programming 17 06-09-2011 12:58 PM
Raw socket - max frame length supported by sendto call for tag frames muruga86 Linux - Networking 0 06-17-2010 07:45 AM
raw socket programming bigboss360 Linux - Networking 2 10-17-2009 10:11 AM
Raw socket programming homePBX Linux - Networking 6 05-02-2008 01:25 PM
Help with raw socket programming tuxfood Programming 2 07-25-2005 02:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration