raw_socket в linux
вот примерный код:
int main()
{
unsigned char message[] = "hello from barmaley!!!\n";
unsigned char buffer[128];
int sock;
int result;
sock = socket(PF_PACKET, SOCK_RAW, ETH_P_802_3);
if(sock < 0)
{
printf("error code - %d, error description - %s\n", errno, strerror(errno));
// perror("socket");
exit(1);
}
memset(buffer, 0, sizeof(buffer));
/*
buffer[0] = 0x01;
buffer[1] = 0x0C;
buffer[2] = 0xCD;
buffer[3] = 0x01;
buffer[4] = 0x00;
buffer[5] = 0x00;
*/
buffer[0] = 0xE0;
buffer[1] = 0xCB;
buffer[2] = 0x4E;
buffer[3] = 0xD6;
buffer[4] = 0x79;
buffer[5] = 0x2A;
buffer[6] = 0x84;
buffer[7] = 0xB5;
buffer[8] = 0x93;
buffer[9] = 0x2D;
buffer[10] = 0xB0;
buffer[11] = 0x95;
buffer[12] = 0x88;
buffer[13] = 0xB8;
memcpy(buffer + 14, message, sizeof(message));
while(1)
{
// result = sendto(sock, msgbuf, sizeof(header)+sizeof(message), 0, (struct sockaddr *)&addr, sizeof(addr));
result = send(sock, buffer, 128, 0);
if(result != -1)
printf("sended is %d bytes\n", result);
else
printf("error code - %d, error description - %s\n", errno, strerror(errno));
sleep(1);
}
close(sock);
return 0;
}
бинго! задачу решил, всем спасибо.