I tried to construct an IP packet and send that using the RAW Socket, but when I tried to capture the same using packet sniffer (ethereal), it showed malformed packet.
The RAW socket code is as follows:
int sockraw = socket(AF_INET, SOCK_RAW, htons(ETH_P_IP));
setsockopt(sd, SOL_SOCKET, SO_BROADCAST,(char *)&one, sizeof(one);
setsockopt(sd, IPPROTO_IP, IP_HDRINCL,(char *)&one, sizeof(one);
Can anyone plz let me know what exactly I need to do if I want to construct my own packet (IP/UDP/TCP) etc and send that using RAW Socket. I want to using my own values of various header fields such as TOS, TTL, Source IP Address, Destination IP Address, Source Port and Destination POrt (for UDP/TCP).
Please guide me for the same.