raw-socket data

I want any ideas from your side about data transfer via raw.
I've client-side, but don't know how to use memcpy() or else for send data?
Please to view any sample that.
I use memcpy for make tcp-packet, but data equal is zero.
memcpy(buff, &ip_hdr, sizeof(ip_hdr));
memcpy(buff+sizeof(ip_hdr), tcp, sizeof(*tcp));
If I make that below, it nothing changed.
1
2
char buffer[32768]="TEST MESSAGE";
 memcpy(buff+sizeof(buffer), buffer, sizeof(buffer));

My sniffer not take that "TEST MESSAGE", just null data.
1
2
3
4
5
6
tcpdump: listening on fxp1, link-type EN10MB (Ethernet), capture size 96 bytes
00:09:57.760539 IP (tos 0x0, ttl 255, id 17767, offset 0, flags [none], length: 40) 10.10.10.254.10000 > 10.10.10.253.http: S [tcp sum ok] 600178688:600178688(0) win 1500
        0x0000:  0090 27af 3426 0007 f66a 53e2 0800 4500  ..'.4&...jS...E.
        0x0010:  0028 4567 0000 ff06 96a8 0a0a 0afe c0a8  .(Eg............
        0x0020:  0a10 000a 0050 23c6 0000 0000 0000 5002  .....P#.......P.
        0x0030:  05dc a626 0000 0000 0000 0000            ...&........ 
1
2
char buffer[32768] = {0}; // null it first
sprintf(buffer, "%s", "TEST MESSAGE"); // write TEST MESSAGE into buffer 


Note. The code you have posted is very C. In C++ you'd use a string and then send it as a const char *

e.g
1
2
3
string buffer = "TEST MESSAGE";

send(buffer.c_str()); // or similar 

Strange, but in sniffer capture don't view that text. The packet checksum is ok. If I try next way is checksum bad.
memcpy(buff+sizeof(*tcp), buffer, sizeof(buffer));
Topic archived. No new replies allowed.